]> git.tdb.fi Git - libs/datafile.git/blob - source/binarywriter.h
Drop copyright and license notices from source files
[libs/datafile.git] / source / binarywriter.h
1 #ifndef MSP_DATAFILE_BINARYWRITER_H_
2 #define MSP_DATAFILE_BINARYWRITER_H_
3
4 #include <map>
5 #include "binarydict.h"
6 #include "writermode.h"
7
8 namespace Msp {
9 namespace DataFile {
10
11 /**
12 Writes data in binary format.
13 */
14 class BinaryWriter: public WriterMode
15 {
16 private:
17         typedef std::map<DictEntry, unsigned> Dictionary;
18         typedef std::map<std::string, unsigned> StringMap;
19
20         Dictionary dict;
21         unsigned next_kwd_id;
22         StringMap strings;
23         unsigned next_str_id;
24
25 public:
26         BinaryWriter(IO::Base &o);
27
28         virtual void write(const Statement &st);
29 private:
30         void write_(const Statement &st);
31         void collect_keywords(const Statement &st);
32         void write_int(long long n);
33         void write_string(const std::string &s);
34         void write_float(float f);
35         void write_enum(const std::string &e);
36 };
37
38 } // namespace DataFile
39 } // namespace Msp
40
41 #endif