6 #ifndef JSON_WRITER_H_INCLUDED
7 #define JSON_WRITER_H_INCLUDED
9 #if !defined(JSON_IS_AMALGAMATION)
11 #endif // if !defined(JSON_IS_AMALGAMATION)
18 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
20 #pragma warning(disable : 4251)
21 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
52 virtual int write(
Value const& root, std::ostream* sout) = 0;
124 Value& operator[](std::string key);
141 virtual std::string write(
const Value& root) = 0;
159 void enableYAMLCompatibility();
166 void dropNullPlaceholders();
168 void omitEndingLineFeed();
171 virtual std::string write(
const Value& root);
174 void writeValue(
const Value& value);
176 std::string document_;
177 bool yamlCompatiblityEnabled_;
178 bool dropNullPlaceholders_;
179 bool omitEndingLineFeed_;
216 virtual std::string write(
const Value& root);
219 void writeValue(
const Value& value);
220 void writeArrayValue(
const Value& value);
221 bool isMultineArray(
const Value& value);
222 void pushValue(
const std::string& value);
224 void writeWithIndent(
const std::string& value);
227 void writeCommentBeforeValue(
const Value& root);
228 void writeCommentAfterValueOnSameLine(
const Value& root);
229 bool hasCommentForValue(
const Value& value);
230 static std::string
normalizeEOL(
const std::string& text);
232 typedef std::vector<std::string> ChildValues;
234 ChildValues childValues_;
235 std::string document_;
236 std::string indentString_;
239 bool addChildValues_;
280 void write(std::ostream& out,
const Value& root);
283 void writeValue(
const Value& value);
284 void writeArrayValue(
const Value& value);
285 bool isMultineArray(
const Value& value);
286 void pushValue(
const std::string& value);
288 void writeWithIndent(
const std::string& value);
291 void writeCommentBeforeValue(
const Value& root);
292 void writeCommentAfterValueOnSameLine(
const Value& root);
293 bool hasCommentForValue(
const Value& value);
294 static std::string
normalizeEOL(
const std::string& text);
296 typedef std::vector<std::string> ChildValues;
298 ChildValues childValues_;
299 std::ostream* document_;
300 std::string indentString_;
302 std::string indentation_;
303 bool addChildValues_ : 1;
307 #if defined(JSON_HAS_INT64)
310 #endif // if defined(JSON_HAS_INT64)
323 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
325 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
327 #endif // JSON_WRITER_H_INCLUDED
Outputs a Value in JSON format without formatting (not human friendly).
A simple abstract factory.
Writes a Value in JSON format in a human friendly way.
#define JSON_API
If defined, indicates that the source file is amalgated to prevent private header inclusion...
std::string valueToQuotedString(const char *value)
std::string valueToString(Int value)
JSON (JavaScript Object Notation).
Json::Value settings_
Configuration of this builder.
Abstract class for writers.
static std::string normalizeEOL(Reader::Location begin, Reader::Location end)
Writes a Value in JSON format in a human friendly way, to a stream rather than to a string...
std::string writeString(StreamWriter::Factory const &factory, Value const &root)
Write into stringstream, then return string, for convenience.
std::ostream & operator<<(std::ostream &, const Value &root)
Output using the StyledStreamWriter.
Build a StreamWriter implementation.