1 #ifndef EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 #define EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 4 #if defined(_MSC_VER) || \ 5 (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 15 #include "yaml-cpp/binary.h" 16 #include "yaml-cpp/dll.h" 17 #include "yaml-cpp/emitterdef.h" 18 #include "yaml-cpp/emittermanip.h" 19 #include "yaml-cpp/noncopyable.h" 20 #include "yaml-cpp/null.h" 21 #include "yaml-cpp/ostream_wrapper.h" 34 explicit Emitter(std::ostream& stream);
38 const char* c_str()
const;
39 std::size_t size()
const;
43 const std::string GetLastError()
const;
46 bool SetOutputCharset(EMITTER_MANIP value);
47 bool SetStringFormat(EMITTER_MANIP value);
48 bool SetBoolFormat(EMITTER_MANIP value);
49 bool SetIntBase(EMITTER_MANIP value);
50 bool SetSeqFormat(EMITTER_MANIP value);
51 bool SetMapFormat(EMITTER_MANIP value);
52 bool SetIndent(std::size_t n);
53 bool SetPreCommentIndent(std::size_t n);
54 bool SetPostCommentIndent(std::size_t n);
55 bool SetFloatPrecision(std::size_t n);
56 bool SetDoublePrecision(std::size_t n);
59 Emitter& SetLocalValue(EMITTER_MANIP value);
64 Emitter& Write(
const std::string& str);
75 Emitter& WriteIntegralType(T value);
78 Emitter& WriteStreamable(T value);
82 void SetStreamablePrecision(std::stringstream&) {}
83 std::size_t GetFloatPrecision()
const;
84 std::size_t GetDoublePrecision()
const;
86 void PrepareIntegralStream(std::stringstream& stream)
const;
98 void EmitTag(
bool verbatim,
const _Tag& tag);
100 void PrepareNode(EmitterNodeType::value child);
101 void PrepareTopNode(EmitterNodeType::value child);
102 void FlowSeqPrepareNode(EmitterNodeType::value child);
103 void BlockSeqPrepareNode(EmitterNodeType::value child);
105 void FlowMapPrepareNode(EmitterNodeType::value child);
107 void FlowMapPrepareLongKey(EmitterNodeType::value child);
108 void FlowMapPrepareLongKeyValue(EmitterNodeType::value child);
109 void FlowMapPrepareSimpleKey(EmitterNodeType::value child);
110 void FlowMapPrepareSimpleKeyValue(EmitterNodeType::value child);
112 void BlockMapPrepareNode(EmitterNodeType::value child);
114 void BlockMapPrepareLongKey(EmitterNodeType::value child);
115 void BlockMapPrepareLongKeyValue(EmitterNodeType::value child);
116 void BlockMapPrepareSimpleKey(EmitterNodeType::value child);
117 void BlockMapPrepareSimpleKeyValue(EmitterNodeType::value child);
119 void SpaceOrIndentTo(
bool requireSpace, std::size_t indent);
121 const char* ComputeFullBoolName(
bool b)
const;
122 bool CanEmitNewline()
const;
125 std::unique_ptr<EmitterState> m_pState;
129 template <
typename T>
130 inline Emitter& Emitter::WriteIntegralType(T value) {
134 PrepareNode(EmitterNodeType::Scalar);
136 std::stringstream stream;
137 PrepareIntegralStream(stream);
139 m_stream << stream.str();
146 template <
typename T>
147 inline Emitter& Emitter::WriteStreamable(T value) {
151 PrepareNode(EmitterNodeType::Scalar);
153 std::stringstream stream;
154 SetStreamablePrecision<T>(stream);
156 m_stream << stream.str();
164 inline void Emitter::SetStreamablePrecision<float>(std::stringstream& stream) {
165 stream.precision(static_cast<std::streamsize>(GetFloatPrecision()));
169 inline void Emitter::SetStreamablePrecision<double>(std::stringstream& stream) {
170 stream.precision(static_cast<std::streamsize>(GetDoublePrecision()));
174 inline Emitter& operator<<(
Emitter& emitter,
const std::string& v) {
175 return emitter.Write(v);
178 return emitter.Write(v);
181 return emitter.Write(v);
184 return emitter.Write(static_cast<char>(v));
187 return emitter.Write(v);
190 return emitter.Write(v);
193 return emitter.Write(v);
196 return emitter.Write(v);
199 return emitter.Write(v);
202 return emitter.Write(b);
206 return emitter.Write(std::string(v));
210 return emitter.WriteIntegralType(v);
213 return emitter.WriteIntegralType(v);
216 return emitter.WriteIntegralType(v);
219 return emitter.WriteIntegralType(v);
222 return emitter.WriteIntegralType(v);
225 return emitter.WriteIntegralType(v);
228 return emitter.WriteIntegralType(v);
230 inline Emitter& operator<<(
Emitter& emitter,
unsigned long long v) {
231 return emitter.WriteIntegralType(v);
235 return emitter.WriteStreamable(v);
238 return emitter.WriteStreamable(v);
241 inline Emitter& operator<<(
Emitter& emitter, EMITTER_MANIP value) {
242 return emitter.SetLocalValue(value);
246 return emitter.SetLocalIndent(indent);
250 return emitter.SetLocalPrecision(precision);
254 #endif // EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 Definition: emittermanip.h:122
Definition: emittermanip.h:86
Definition: emittermanip.h:72
Definition: emittermanip.h:65
Definition: noncopyable.h:14
Definition: DrawableObjectLoader.h:10
Definition: emittermanip.h:79
Definition: ostream_wrapper.h:16