-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDefine.h
75 lines (67 loc) · 1.45 KB
/
Define.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
/*
* Title : Define.h
*/
#ifndef DEFINE_H_
#define DEFINE_H_
enum class JsonType {
ARRAY = 0,
SEQUENCE,
STRING,
INTEGER
};
typedef struct NodeType {
JsonType type;
std::string name;
} NodeType;
const NodeType ARRAY_TYPE = { JsonType::ARRAY, "" };
const NodeType SEQUENCE_TYPE = { JsonType::SEQUENCE, "" };
const NodeType STRING_TYPE = { JsonType::STRING, "" };
const NodeType INTEGER_TYPE = { JsonType::INTEGER, "" };
inline std::ostream& operator<<(std::ostream& os, const JsonType& type)
{
switch (type) {
case JsonType::ARRAY:
os << "array";
break;
case JsonType::STRING:
os << "string";
break;
case JsonType::INTEGER:
os << "integer";
break;
case JsonType::SEQUENCE:
default:
os << "sequence";
break;
}
return os;
}
inline std::ostream& operator<<(std::ostream& os, const NodeType& type)
{
switch (type.type) {
case JsonType::ARRAY:
os << "array(" << type.name << ")";
break;
case JsonType::STRING:
os << "string";
break;
case JsonType::INTEGER:
os << "integer";
break;
case JsonType::SEQUENCE:
default:
os << "sequence";
break;
}
return os;
}
inline std::string setTab(uint8_t tab)
{
std::string tabstr = "";
for (int i = 0; i < tab; i++)
{
tabstr += " ";
}
return tabstr;
}
#endif /* DEFINE_H_ */