]> git.tdb.fi Git - libs/datafile.git/blob - source/writer.h
Fix a memory leak
[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         ~Writer();
34
35         /**
36         Writes a statement to the output.  This function always writes a complete
37         statement, so it's not possible to add substatements later.
38         */
39         void write(const Statement &st);
40
41         /**
42         Sets binary or text mode.  While it is possible to enter and exit binary
43         mode multiple times, doing so produces sub-optimal output.
44
45         @param  b  true for binary mode, false for text
46         */
47         void set_binary(bool b);
48 };
49
50 } // namespace DataFile
51 } // namespace Msp
52
53 #endif