/src/yaml-cpp/include/yaml-cpp/emittermanip.h
Line | Count | Source |
1 | | #ifndef EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 |
2 | | #define EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 |
3 | | |
4 | | |
5 | | |
6 | | |
7 | | #if defined(_MSC_VER) || \ |
8 | | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ |
9 | | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 |
10 | | #pragma once |
11 | | |
12 | | |
13 | | #endif |
14 | | |
15 | | // IWYU pragma: private, include "yaml-cpp/yaml.h" |
16 | | // IWYU pragma: friend "yaml-cpp/.*" |
17 | | |
18 | | |
19 | | #include <string> |
20 | | |
21 | | namespace YAML { |
22 | | enum EMITTER_MANIP { |
23 | | // general manipulators |
24 | | Auto, |
25 | | TagByKind, |
26 | | Newline, |
27 | | |
28 | | // output character set |
29 | | EmitNonAscii, |
30 | | EscapeNonAscii, |
31 | | EscapeAsJson, |
32 | | |
33 | | // string manipulators |
34 | | // Auto, // duplicate |
35 | | SingleQuoted, |
36 | | DoubleQuoted, |
37 | | Literal, |
38 | | |
39 | | // null manipulators |
40 | | LowerNull, |
41 | | UpperNull, |
42 | | CamelNull, |
43 | | TildeNull, |
44 | | |
45 | | // bool manipulators |
46 | | YesNoBool, // yes, no |
47 | | TrueFalseBool, // true, false |
48 | | OnOffBool, // on, off |
49 | | UpperCase, // TRUE, N |
50 | | LowerCase, // f, yes |
51 | | CamelCase, // No, Off |
52 | | LongBool, // yes, On |
53 | | ShortBool, // y, t |
54 | | |
55 | | // int manipulators |
56 | | Dec, |
57 | | Hex, |
58 | | Oct, |
59 | | |
60 | | // document manipulators |
61 | | BeginDoc, |
62 | | EndDoc, |
63 | | |
64 | | // sequence manipulators |
65 | | BeginSeq, |
66 | | EndSeq, |
67 | | Flow, |
68 | | Block, |
69 | | |
70 | | // map manipulators |
71 | | BeginMap, |
72 | | EndMap, |
73 | | Key, |
74 | | Value, |
75 | | // Flow, // duplicate |
76 | | // Block, // duplicate |
77 | | // Auto, // duplicate |
78 | | LongKey |
79 | | }; |
80 | | |
81 | | struct _Indent { |
82 | 0 | _Indent(int value_) : value(value_) {} |
83 | | int value; |
84 | | }; |
85 | | |
86 | 0 | inline _Indent Indent(int value) { return _Indent(value); } |
87 | | |
88 | | struct _Wrap { |
89 | 0 | _Wrap(int value_) : value(value_) {} |
90 | | int value; |
91 | | }; |
92 | | |
93 | 0 | inline _Wrap Wrap(int value) { return _Wrap(value); } |
94 | | |
95 | | struct _Alias { |
96 | 0 | _Alias(const std::string& content_) : content(content_) {} |
97 | | std::string content; |
98 | | }; |
99 | | |
100 | 0 | inline _Alias Alias(const std::string& content) { return _Alias(content); } |
101 | | |
102 | | struct _Anchor { |
103 | 0 | _Anchor(const std::string& content_) : content(content_) {} |
104 | | std::string content; |
105 | | }; |
106 | | |
107 | 0 | inline _Anchor Anchor(const std::string& content) { return _Anchor(content); } |
108 | | |
109 | | struct _Tag { |
110 | | struct Type { |
111 | | enum value { Verbatim, PrimaryHandle, NamedHandle }; |
112 | | }; |
113 | | |
114 | | explicit _Tag(const std::string& prefix_, const std::string& content_, |
115 | | Type::value type_) |
116 | 0 | : prefix(prefix_), content(content_), type(type_) {} |
117 | | std::string prefix; |
118 | | std::string content; |
119 | | Type::value type; |
120 | | }; |
121 | | |
122 | 0 | inline _Tag VerbatimTag(const std::string& content) { |
123 | 0 | return _Tag("", content, _Tag::Type::Verbatim); |
124 | 0 | } |
125 | | |
126 | 0 | inline _Tag LocalTag(const std::string& content) { |
127 | 0 | return _Tag("", content, _Tag::Type::PrimaryHandle); |
128 | 0 | } |
129 | | |
130 | 0 | inline _Tag LocalTag(const std::string& prefix, const std::string content) { |
131 | 0 | return _Tag(prefix, content, _Tag::Type::NamedHandle); |
132 | 0 | } |
133 | | |
134 | 0 | inline _Tag SecondaryTag(const std::string& content) { |
135 | 0 | return _Tag("", content, _Tag::Type::NamedHandle); |
136 | 0 | } |
137 | | |
138 | | struct _Comment { |
139 | 0 | _Comment(const std::string& content_) : content(content_) {} |
140 | | std::string content; |
141 | | }; |
142 | | |
143 | 0 | inline _Comment Comment(const std::string& content) { return _Comment(content); } |
144 | | |
145 | | struct _Precision { |
146 | | _Precision(int floatPrecision_, int doublePrecision_) |
147 | 0 | : floatPrecision(floatPrecision_), doublePrecision(doublePrecision_) {} |
148 | | |
149 | | int floatPrecision; |
150 | | int doublePrecision; |
151 | | }; |
152 | | |
153 | 0 | inline _Precision FloatPrecision(int n) { return _Precision(n, -1); } |
154 | | |
155 | 0 | inline _Precision DoublePrecision(int n) { return _Precision(-1, n); } |
156 | | |
157 | 0 | inline _Precision Precision(int n) { return _Precision(n, n); } |
158 | | } |
159 | | |
160 | | #endif // EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 |