]> git.tdb.fi Git - libs/datafile.git/blob - source/writer.h
c8d75e32dcd643bb09e3ec281331800691c99e02
[libs/datafile.git] / source / writer.h
1 #ifndef MSP_DATAFILE_WRITER_H_
2 #define MSP_DATAFILE_WRITER_H_
3
4 #include <map>
5 #include <msp/io/base.h>
6 #include "binarydict.h"
7
8 namespace Msp {
9 namespace DataFile {
10
11 class Statement;
12 class WriterMode;
13
14 /**
15 Frontend for writing data.
16 */
17 class Writer
18 {
19 private:
20         IO::Base &out;
21         WriterMode *mode;
22         bool binary;
23
24 public:
25         Writer(IO::Base &o);
26         ~Writer();
27
28         /**
29         Writes a statement to the output.  This function always writes a complete
30         statement, so it's not possible to add substatements later.
31         */
32         void write(const Statement &st);
33
34         /**
35         Sets binary or text mode.  While it is possible to enter and exit binary
36         mode multiple times, doing so produces sub-optimal output.
37
38         @param  b  true for binary mode, false for text
39         */
40         void set_binary(bool b);
41
42         /** Sets the precision of floating point numbers in bits.  Depending on the
43         mode not all values may be valid, but any value between 16 and 64 that is
44         divisible by 8 is guaranteed to work. */
45         void set_float_precision(unsigned);
46 };
47
48 } // namespace DataFile
49 } // namespace Msp
50
51 #endif