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