]> git.tdb.fi Git - libs/datafile.git/blob - source/binaryparser.h
Add reverse name lookup to Collection
[libs/datafile.git] / source / binaryparser.h
1 /* $Id$
2
3 This file is part of libmspdatafile
4 Copyright © 2007  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_DATAFILE_BINARYPARSER_H_
9 #define MSP_DATAFILE_BINARYPARSER_H_
10
11 #include <map>
12 #include "binarydict.h"
13 #include "parsermode.h"
14
15 namespace Msp {
16 namespace DataFile {
17
18 /**
19 Parses data in binary format.
20 */
21 class BinaryParser: public ParserMode
22 {
23 private:
24         typedef std::map<unsigned, DictEntry> Dictionary;
25         typedef std::map<unsigned, std::string> StringMap;
26
27         Dictionary dict;
28         StringMap strings;
29         bool first;
30
31 public:
32         BinaryParser(Input &i, const std::string &s);
33         Statement parse();
34 private:
35         Statement parse_statement();
36         long long parse_int();
37         float parse_float();
38         std::string parse_string();
39         bool parse_bool();
40         std::string parse_enum();
41         const std::string &lookup_string(unsigned) const;
42 };
43
44 } // namespace DataFile
45 } // namespace Msp
46
47 #endif