JSON writer class.
More...
#include <json.hpp>
|
| virtual void | writeInt (int32_t value) |
| | write integer value.
|
| |
| virtual void | writeUint (uint32_t value) |
| | write unsigned integer value.
|
| |
| virtual void | writeInt64 (int64_t value) |
| | write 64 bits integer value.
|
| |
| virtual void | writeUint64 (uint64_t value) |
| | write 64 bits unsigned integer value.
|
| |
| virtual void | writeDouble (double value) |
| | write real value.
|
| |
| virtual int | utf8Codepoint (std::string::const_iterator &cur, std::string::const_iterator &end, uint32_t &codepoint) |
| | get UTF8 codepoint.
|
| |
| virtual int | writeEscaped (const std::string &value) |
| | escape string value.
|
| |
| void | comma () noexcept |
| | write comma.
|
| |
| void | indent () noexcept |
| | write indentation.
|
| |
| void | space () noexcept |
| | write space.
|
| |
| void | endLine () noexcept |
| | write end of line.
|
| |
| void | array () noexcept |
| | add comma, go to line and indent if in array.
|
| |
| int | setValue (const Value &value) |
| | set value.
|
| |
| virtual int | setArray (const Array &array) |
| | set array value.
|
| |
| virtual int | setObject (const Object &object) |
| | set object value.
|
| |
| void | append (char data) noexcept |
| | append character to output stream in batch.
|
| |
| void | append2 (const char *data) noexcept |
| | append 2-character literal to output stream in batch.
|
| |
| void | append3 (const char *data) noexcept |
| | append 3-character literal to output stream in batch.
|
| |
| void | append4 (const char *data) noexcept |
| | append 4-character literal to output stream in batch.
|
| |
| void | append5 (const char *data) noexcept |
| | append 5-character literal to output stream in batch.
|
| |
| void | append (const char *data, uint32_t size) noexcept |
| | append characters to output stream in batch.
|
| |
|
| std::stack< bool > | _stack |
| | array stack.
|
| |
| size_t | _indentation |
| | indentation.
|
| |
| std::string | _tab |
| | tabulation.
|
| |
| bool | _first = true |
| | is first element.
|
| |
| std::streambuf * | _out |
| | underlying output stream.
|
| |
◆ JsonWriter() [1/3]
| join::JsonWriter::JsonWriter |
( |
std::ostream & | document, |
|
|
size_t | indentation = 0 ) |
|
inline |
create instance.
- Parameters
-
| document | JSON document to create. |
| indentation | number of characters used to indent JSON. |
◆ JsonWriter() [2/3]
| join::JsonWriter::JsonWriter |
( |
const JsonWriter & | other | ) |
|
|
delete |
copy constructor.
- Parameters
-
◆ JsonWriter() [3/3]
| join::JsonWriter::JsonWriter |
( |
JsonWriter && | other | ) |
|
|
delete |
move constructor.
- Parameters
-
◆ ~JsonWriter()
| virtual join::JsonWriter::~JsonWriter |
( |
| ) |
|
|
virtualdefault |
◆ array()
| void join::JsonWriter::array |
( |
| ) |
|
|
inlineprotectednoexcept |
add comma, go to line and indent if in array.
◆ comma()
| void join::JsonWriter::comma |
( |
| ) |
|
|
inlineprotectednoexcept |
◆ endLine()
| void join::JsonWriter::endLine |
( |
| ) |
|
|
inlineprotectednoexcept |
◆ indent()
| void join::JsonWriter::indent |
( |
| ) |
|
|
inlineprotectednoexcept |
◆ operator=() [1/2]
copy assignment.
- Parameters
-
- Returns
- a reference of the current object.
◆ operator=() [2/2]
move assignment.
- Parameters
-
- Returns
- a reference of the current object.
◆ setBool()
| virtual int join::JsonWriter::setBool |
( |
bool | value | ) |
|
|
inlineoverridevirtual |
set boolean value.
- Parameters
-
| value | boolean value to set. |
- Returns
- 0 on success, -1 otherwise.
Implements join::SaxHandler.
◆ setDouble()
| virtual int join::JsonWriter::setDouble |
( |
double | value | ) |
|
|
inlineoverridevirtual |
◆ setInt()
| virtual int join::JsonWriter::setInt |
( |
int32_t | value | ) |
|
|
inlineoverridevirtual |
set integer value.
- Parameters
-
| value | integer value to set. |
- Returns
- 0 on success, -1 otherwise.
Implements join::SaxHandler.
◆ setInt64()
| virtual int join::JsonWriter::setInt64 |
( |
int64_t | value | ) |
|
|
inlineoverridevirtual |
set 64 bits integer value.
- Parameters
-
| value | 64 bits integer value to set. |
- Returns
- 0 on success, -1 otherwise.
Implements join::SaxHandler.
◆ setKey()
| virtual int join::JsonWriter::setKey |
( |
const Value & | key | ) |
|
|
inlineoverridevirtual |
set key.
- Parameters
-
- Returns
- 0 on success, -1 otherwise.
Implements join::SaxHandler.
◆ setNull()
| virtual int join::JsonWriter::setNull |
( |
| ) |
|
|
inlineoverridevirtual |
◆ setString()
| virtual int join::JsonWriter::setString |
( |
const std::string & | value | ) |
|
|
inlineoverridevirtual |
set string value.
- Parameters
-
| value | string value to set. |
- Returns
- 0 on success, -1 otherwise.
Implements join::SaxHandler.
◆ setUint()
| virtual int join::JsonWriter::setUint |
( |
uint32_t | value | ) |
|
|
inlineoverridevirtual |
set unsigned integer value.
- Parameters
-
| value | unsigned integer value to set. |
- Returns
- 0 on success, -1 otherwise.
Implements join::SaxHandler.
◆ setUint64()
| virtual int join::JsonWriter::setUint64 |
( |
uint64_t | value | ) |
|
|
inlineoverridevirtual |
set unsigned 64 bits integer value.
- Parameters
-
| value | unsigned 64 bits integer value to set. |
- Returns
- 0 on success, -1 otherwise.
Implements join::SaxHandler.
◆ space()
| void join::JsonWriter::space |
( |
| ) |
|
|
inlineprotectednoexcept |
◆ startArray()
| virtual int join::JsonWriter::startArray |
( |
uint32_t | size = 0 | ) |
|
|
inlineoverridevirtual |
start array.
- Parameters
-
| size | array size (ignored). |
- Returns
- 0 on success, -1 otherwise.
Implements join::SaxHandler.
◆ startObject()
| virtual int join::JsonWriter::startObject |
( |
uint32_t | size = 0 | ) |
|
|
inlineoverridevirtual |
start object.
- Parameters
-
| size | array size (ignored). |
- Returns
- 0 on success, -1 otherwise.
Implements join::SaxHandler.
◆ stopArray()
| virtual int join::JsonWriter::stopArray |
( |
| ) |
|
|
inlineoverridevirtual |
stop array.
- Returns
- 0 on success, -1 otherwise.
Reimplemented from join::SaxHandler.
◆ stopObject()
| virtual int join::JsonWriter::stopObject |
( |
| ) |
|
|
inlineoverridevirtual |
stop object.
- Returns
- 0 on success, -1 otherwise.
Reimplemented from join::SaxHandler.
◆ utf8Codepoint()
| virtual int join::JsonWriter::utf8Codepoint |
( |
std::string::const_iterator & | cur, |
|
|
std::string::const_iterator & | end, |
|
|
uint32_t & | codepoint ) |
|
inlineprotectedvirtual |
get UTF8 codepoint.
- Parameters
-
| cur | current character. |
| end | end of string. |
| codepoint | calculated UTF8 codepoint. |
- Returns
- 0 on success, -1 otherwise.
◆ writeDouble()
| virtual void join::JsonWriter::writeDouble |
( |
double | value | ) |
|
|
inlineprotectedvirtual |
◆ writeEscaped()
| virtual int join::JsonWriter::writeEscaped |
( |
const std::string & | value | ) |
|
|
inlineprotectedvirtual |
escape string value.
- Parameters
-
| value | string value to escape. |
- Returns
- 0 on success, -1 otherwise.
◆ writeInt()
| virtual void join::JsonWriter::writeInt |
( |
int32_t | value | ) |
|
|
inlineprotectedvirtual |
write integer value.
- Parameters
-
| value | integer value to write. |
◆ writeInt64()
| virtual void join::JsonWriter::writeInt64 |
( |
int64_t | value | ) |
|
|
inlineprotectedvirtual |
write 64 bits integer value.
- Parameters
-
| value | 64 bits integer value to write. |
◆ writeUint()
| virtual void join::JsonWriter::writeUint |
( |
uint32_t | value | ) |
|
|
inlineprotectedvirtual |
write unsigned integer value.
- Parameters
-
| value | unsigned integer value to write. |
◆ writeUint64()
| virtual void join::JsonWriter::writeUint64 |
( |
uint64_t | value | ) |
|
|
inlineprotectedvirtual |
write 64 bits unsigned integer value.
- Parameters
-
| value | 64 bits unsigned integer value to write. |
◆ _first
| bool join::JsonWriter::_first = true |
|
protected |
◆ _indentation
| size_t join::JsonWriter::_indentation |
|
protected |
◆ _stack
| std::stack<bool> join::JsonWriter::_stack |
|
protected |
◆ _tab
| std::string join::JsonWriter::_tab |
|
protected |
The documentation for this class was generated from the following file: