HDK
|
#include <json.h>
Public Types | |
enum | Style { Style::Compact, Style::Pretty } |
Public Member Functions | |
JS_API | JsWriter (std::ostream &ostr, Style style=Style::Compact) |
JS_API | ~JsWriter () |
Destructor. More... | |
JsWriter (const JsWriter &)=delete | |
Disable copies. More... | |
JsWriter & | operator= (const JsWriter &)=delete |
JS_API bool | WriteValue (std::nullptr_t) |
Write a null value. More... | |
JS_API bool | WriteValue (bool b) |
Write a boolean value. More... | |
JS_API bool | WriteValue (int i) |
Write an integer value. More... | |
JS_API bool | WriteValue (unsigned u) |
Write an unsigned integer value. More... | |
JS_API bool | WriteValue (int64_t i) |
Write a 64-bit integer value. More... | |
JS_API bool | WriteValue (uint64_t u) |
Write a 64-bit unsigned integer value. More... | |
JS_API bool | WriteValue (double d) |
Write a double value. More... | |
JS_API bool | WriteValue (const std::string &s) |
Write a string value. More... | |
JS_API bool | WriteValue (const char *s) |
Write a string value. More... | |
template<size_t N> | |
bool | WriteValue (const char(&s)[N]) |
Write a string value. More... | |
JS_API bool | BeginObject () |
Write the start of an object. More... | |
JS_API bool | WriteKey (const std::string &) |
Write an object key. More... | |
JS_API bool | WriteKey (const char *) |
Write an object key. More... | |
template<size_t N> | |
bool | WriteKey (const char(&s)[N]) |
Write a string literal object key. More... | |
template<class K , class V > | |
void | WriteKeyValue (K &&k, V &&v) |
Convenience function to write an object key and value. More... | |
JS_API bool | EndObject () |
Write the end of an object. More... | |
JS_API bool | BeginArray () |
Write the start of an array. More... | |
JS_API bool | EndArray () |
Write the end of an array. More... | |
template<class Container > | |
void | WriteArray (const Container &c) |
Convenience function to write an array of values. More... | |
template<class Container , class ItemWriteFn > | |
void | WriteArray (const Container &c, const ItemWriteFn &f) |
template<class Iterator , class ItemWriteFn > | |
void | WriteArray (const Iterator &begin, const Iterator &end, const ItemWriteFn &f) |
template<class... T> | |
void | WriteObject (T &&...f) |
This class provides an interface to writing json values directly to a stream. This can be much more efficient than constructing a JsValue instance and using JsWriteToStream if the data size is significant.
|
strong |
JS_API JsWriter::JsWriter | ( | std::ostream & | ostr, |
Style | style = Style::Compact |
||
) |
Constructor. The lifetime of the /p ostr parameter is assumed to be longer than the JsWriter instance.
JS_API JsWriter::~JsWriter | ( | ) |
Destructor.
|
delete |
Disable copies.
JS_API bool JsWriter::BeginArray | ( | ) |
Write the start of an array.
JS_API bool JsWriter::BeginObject | ( | ) |
Write the start of an object.
JS_API bool JsWriter::EndArray | ( | ) |
Write the end of an array.
JS_API bool JsWriter::EndObject | ( | ) |
Write the end of an object.
|
inline |
|
inline |
|
inline |
JS_API bool JsWriter::WriteKey | ( | const std::string & | ) |
Write an object key.
JS_API bool JsWriter::WriteKey | ( | const char * | ) |
Write an object key.
|
inline |
|
inline |
JS_API bool JsWriter::WriteValue | ( | std::nullptr_t | ) |
Write a null value.
JS_API bool JsWriter::WriteValue | ( | bool | b | ) |
Write a boolean value.
JS_API bool JsWriter::WriteValue | ( | unsigned | u | ) |
Write an unsigned integer value.
JS_API bool JsWriter::WriteValue | ( | int64_t | i | ) |
Write a 64-bit integer value.
JS_API bool JsWriter::WriteValue | ( | uint64_t | u | ) |
Write a 64-bit unsigned integer value.
JS_API bool JsWriter::WriteValue | ( | double | d | ) |
Write a double value.
JS_API bool JsWriter::WriteValue | ( | const std::string & | s | ) |
Write a string value.
JS_API bool JsWriter::WriteValue | ( | const char * | s | ) |
Write a string value.
|
inline |