]> git.tdb.fi Git - libs/datafile.git/blob - source/writer.h
e62e8bce2851313d6a9cb10e4df86531920dbd4e
[libs/datafile.git] / source / writer.h
1 /* $Id$
2
3 This file is part of libmspdatafile
4 Copyright © 2006  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_DATAFILE_WRITER_H_
9 #define MSP_DATAFILE_WRITER_H_
10
11 #include <map>
12 #include <msp/io/base.h>
13 #include "binarydict.h"
14
15 namespace Msp {
16 namespace DataFile {
17
18 class Statement;
19 class WriterMode;
20
21 /**
22 Frontend for writing data.
23 */
24 class Writer
25 {
26 private:
27         IO::Base &out;
28         WriterMode *mode;
29         bool binary;
30
31 public:
32         Writer(IO::Base &o);
33
34         /**
35         Writes a statement to the output.  This function always writes a complete
36         statement, so it's not possible to add substatements later.
37         */
38         void write(const Statement &st);
39
40         /**
41         Sets binary or text mode.  While it is possible to enter and exit binary
42         mode multiple times, doing so produces sub-optimal output.
43
44         @param  b  true for binary mode, false for text
45         */
46         void set_binary(bool b);
47 };
48
49 } // namespace DataFile
50 } // namespace Msp
51
52 #endif