-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparser.h
81 lines (58 loc) · 1.5 KB
/
parser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef PARSER_H
#define PARSER_H
#include <vector>
#include <list>
#include <map>
enum eElementType
{
e_elem_int,
e_elem_string,
e_elem_list,
e_elem_dict,
e_elem_unknown
};
struct BElement
{
eElementType m_eType;
BElement *m_parent;
std::string static Parse(const std::string& file_path, BElement** virtual_root);
static std::vector<BElement *> GLOBAL_ENV;
static BElement* CreateElement(eElementType eType);
static eElementType PeekType(std::ifstream& ifs);
static BElement* Peek(std::ifstream& ifs);
virtual void Construct(std::ifstream& ifs) {}
virtual void Destruct() {}
virtual ~BElement() {}
};
struct BElementInt : public BElement
{
__int64 m_n;
BElementInt() { m_eType = e_elem_int; }
virtual void Construct(std::ifstream& ifs);
};
struct BElementString : public BElement
{
__int64 m_nLen;
char *m_str;
BElementString() { m_eType = e_elem_string; m_str = NULL; }
virtual void Construct(std::ifstream& ifs);
virtual void Destruct();
virtual ~BElementString() { Destruct(); }
};
struct BElementList : public BElement
{
std::list<BElement *> m_list;
BElementList() { m_eType = e_elem_list; }
virtual void Construct(std::ifstream& ifs);
virtual void Destruct();
virtual ~BElementList() { Destruct(); }
};
struct BElementDict : public BElement
{
std::map<BElementString *, BElement *> m_dict;
BElementDict() { m_eType = e_elem_dict; }
virtual void Construct(std::ifstream& ifs);
virtual void Destruct();
virtual ~BElementDict() { Destruct(); }
};
#endif // PARSER_H