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