/src/yaml-cpp/src/token.h
Line | Count | Source |
1 | | #ifndef TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66 |
2 | | #define TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66 |
3 | | |
4 | | #if defined(_MSC_VER) || \ |
5 | | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ |
6 | | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 |
7 | | #pragma once |
8 | | #endif |
9 | | |
10 | | #include "yaml-cpp/mark.h" |
11 | | #include <ostream> |
12 | | #include <string> |
13 | | #include <vector> |
14 | | |
15 | | namespace YAML { |
16 | | constexpr const char* TokenNames[] = { |
17 | | "DIRECTIVE", "DOC_START", "DOC_END", "BLOCK_SEQ_START", |
18 | | "BLOCK_MAP_START", "BLOCK_SEQ_END", "BLOCK_MAP_END", "BLOCK_ENTRY", |
19 | | "FLOW_SEQ_START", "FLOW_MAP_START", "FLOW_SEQ_END", "FLOW_MAP_END", |
20 | | "FLOW_MAP_COMPACT", "FLOW_ENTRY", "KEY", "VALUE", |
21 | | "ANCHOR", "ALIAS", "TAG", "SCALAR", |
22 | | "NON_PLAIN_SCALAR"}; |
23 | | |
24 | | struct Token { |
25 | | // enums |
26 | | enum STATUS { VALID, INVALID, UNVERIFIED }; |
27 | | enum TYPE { |
28 | | DIRECTIVE, |
29 | | DOC_START, |
30 | | DOC_END, |
31 | | BLOCK_SEQ_START, |
32 | | BLOCK_MAP_START, |
33 | | BLOCK_SEQ_END, |
34 | | BLOCK_MAP_END, |
35 | | BLOCK_ENTRY, |
36 | | FLOW_SEQ_START, |
37 | | FLOW_MAP_START, |
38 | | FLOW_SEQ_END, |
39 | | FLOW_MAP_END, |
40 | | FLOW_MAP_COMPACT, |
41 | | FLOW_ENTRY, |
42 | | KEY, |
43 | | VALUE, |
44 | | ANCHOR, |
45 | | ALIAS, |
46 | | TAG, |
47 | | PLAIN_SCALAR, |
48 | | NON_PLAIN_SCALAR |
49 | | }; |
50 | | |
51 | | // data |
52 | | Token(TYPE type_, const Mark& mark_) |
53 | 122M | : status(VALID), type(type_), mark(mark_), value{}, params{}, data(0) {} |
54 | | |
55 | 0 | friend std::ostream& operator<<(std::ostream& out, const Token& token) { |
56 | 0 | out << TokenNames[token.type] << std::string(": ") << token.value; |
57 | 0 | for (const std::string& param : token.params) |
58 | 0 | out << std::string(" ") << param; |
59 | 0 | return out; |
60 | 0 | } |
61 | | |
62 | | STATUS status; |
63 | | TYPE type; |
64 | | Mark mark; |
65 | | std::string value; |
66 | | std::vector<std::string> params; |
67 | | int data; |
68 | | }; |
69 | | } // namespace YAML |
70 | | |
71 | | #endif // TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66 |