|
join 1.0
lightweight network framework library
|
JSON writer class. More...
#include <json.hpp>
Public Member Functions | |
| BasicJsonWriter (std::ostream &document, size_t indentation=0) | |
| create instance. | |
| BasicJsonWriter (const BasicJsonWriter &other)=delete | |
| copy constructor. | |
| BasicJsonWriter & | operator= (const BasicJsonWriter &other)=delete |
| copy assignment. | |
| BasicJsonWriter (BasicJsonWriter &&other)=delete | |
| move constructor. | |
| BasicJsonWriter & | operator= (BasicJsonWriter &&other)=delete |
| move assignment. | |
| ~BasicJsonWriter ()=default | |
| destroy instance. | |
| int | setNull () |
| set null value. | |
| int | setBool (bool value) |
| set boolean value. | |
| int | setInt (int32_t value) |
| set integer value. | |
| int | setUint (uint32_t value) |
| set unsigned integer value. | |
| int | setInt64 (int64_t value) |
| set 64 bits integer value. | |
| int | setUint64 (uint64_t value) |
| set unsigned 64 bits integer value. | |
| template<JsonWriteMode Mode = WriteMode> requires (Mode == JsonWriteMode::None) | |
| int | setDouble (double value) |
| set real value. | |
| template<JsonWriteMode Mode = WriteMode> requires (Mode == JsonWriteMode::Canonical) | |
| int | setDouble (double value) |
| set real value in canonical form. | |
| int | setString (std::string_view value) |
| set string value. | |
| int | startArray (uint32_t size=0) |
| start array. | |
| int | stopArray () |
| stop array. | |
| int | startObject (uint32_t size=0) |
| start object. | |
| template<JsonWriteMode Mode = WriteMode> requires (Mode == JsonWriteMode::None) | |
| const Object & | members (const Object &object) const noexcept |
| get object members in writing order. | |
| template<JsonWriteMode Mode = WriteMode> requires (Mode == JsonWriteMode::Canonical) | |
| std::vector< std::reference_wrapper< const Member > > | members (const Object &object) const |
| get object members sorted by key in UTF-16 order. | |
| int | setKey (std::nullptr_t key) |
| set null key. | |
| int | setKey (bool key) |
| set boolean key. | |
| int | setKey (int32_t key) |
| set integer key. | |
| int | setKey (uint32_t key) |
| set unsigned integer key. | |
| int | setKey (int64_t key) |
| set 64 bits integer key. | |
| int | setKey (uint64_t key) |
| set unsigned 64 bits integer key. | |
| int | setKey (double key) |
| set real key. | |
| int | setKey (std::string_view key) |
| set string key. | |
| int | setKey (const char *key) |
| set string key. | |
| int | stopObject () |
| stop object. | |
| void | flush () |
| flush buffered data to output stream. | |
| void | reset () noexcept |
| reset the writer state, discarding buffered data. | |
Protected Member Functions | |
| void | writeInt (int32_t value) |
| write integer value. | |
| void | writeUint (uint32_t value) |
| write unsigned integer value. | |
| void | writeInt64 (int64_t value) |
| write 64 bits integer value. | |
| void | writeUint64 (uint64_t value) |
| write 64 bits unsigned integer value. | |
| void | writeDouble (double value) |
| write real value. | |
| void | writeEscaped (std::string_view value) |
| escape string value. | |
| void | append (char data) |
| append character to output stream in batch. | |
| void | append (const char *data, uint32_t size) |
| append data to output stream in batch. | |
| void | appendDigits (const char *digits, size_t length) |
| append the digits of a number, read 20 bytes at a time. | |
| void | comma () |
| write comma. | |
| void | endLine () |
| write end of line. | |
| void | indent () |
| write indentation. | |
| void | newLine () |
| write end of line and indentation. | |
| __attribute__ ((noinline)) void indentLine() | |
| write end of line and indentation, out of the compact writing path. | |
| void | space () |
| write space. | |
| void | array () |
| add comma, go to line and indent if in array. | |
| void | endValue () |
| mark the end of a value, flushing the document once complete. | |
Protected Attributes | |
| std::streambuf * | _out |
| underlying output stream. | |
| char | _buffer [1024] = {} |
| output buffer. | |
| size_t | _size = 0 |
| output buffer size. | |
| uint64_t | _arrays [saxMaxDepth/64] = {} |
| array flags of the open containers, one bit per depth. | |
| size_t | _depth = 0 |
| number of open containers. | |
| size_t | _indentation |
| indentation. | |
| bool | _first = true |
| is first element. | |
JSON writer class.
|
inlineexplicit |
create instance.
| document | JSON document to create. |
| indentation | number of characters used to indent JSON. |
|
delete |
copy constructor.
| other | object to copy. |
|
delete |
move constructor.
| other | object to move. |
|
default |
destroy instance.
|
inlineprotected |
write end of line and indentation, out of the compact writing path.
|
inlineprotected |
append character to output stream in batch.
| data | character to append to output stream. |
|
inlineprotected |
append data to output stream in batch.
| data | data to append to output stream. |
| size | data size. |
|
inlineprotected |
append the digits of a number, read 20 bytes at a time.
| digits | digits followed by enough readable bytes to read 20. |
| length | number of digits. |
|
inlineprotected |
add comma, go to line and indent if in array.
|
inlineprotected |
write comma.
|
inlineprotected |
write end of line.
|
inlineprotected |
mark the end of a value, flushing the document once complete.
|
inline |
flush buffered data to output stream.
|
inlineprotected |
write indentation.
|
inline |
get object members sorted by key in UTF-16 order.
| object | object to write. |
|
inlinenoexcept |
get object members in writing order.
| object | object to write. |
|
inlineprotected |
write end of line and indentation.
|
delete |
move assignment.
| other | object to move. |
|
delete |
copy assignment.
| other | object to copy. |
|
inlinenoexcept |
reset the writer state, discarding buffered data.
|
inline |
set boolean value.
| value | boolean value to set. |
|
inline |
set real value.
| value | real value to set. |
|
inline |
set real value in canonical form.
| value | real value to set. |
|
inline |
set integer value.
| value | integer value to set. |
|
inline |
set 64 bits integer value.
| value | 64 bits integer value to set. |
|
inline |
set boolean key.
| key | object key. |
|
inline |
set string key.
| key | object key. |
|
inline |
set real key.
| key | object key. |
|
inline |
set integer key.
| key | object key. |
|
inline |
set 64 bits integer key.
| key | object key. |
|
inline |
set null key.
| key | object key. |
|
inline |
set string key.
| key | object key. |
|
inline |
set unsigned integer key.
| key | object key. |
|
inline |
set unsigned 64 bits integer key.
| key | object key. |
|
inline |
set null value.
|
inline |
set string value.
| value | string value to set. |
|
inline |
set unsigned integer value.
| value | unsigned integer value to set. |
|
inline |
set unsigned 64 bits integer value.
| value | unsigned 64 bits integer value to set. |
|
inlineprotected |
write space.
|
inline |
start array.
| size | array size (ignored). |
|
inline |
start object.
| size | object size (ignored). |
|
inline |
stop array.
|
inline |
stop object.
|
inlineprotected |
write real value.
| value | real value to write. |
|
inlineprotected |
escape string value.
| value | string value to escape. |
|
inlineprotected |
write integer value.
| value | integer value to write. |
|
inlineprotected |
write 64 bits integer value.
| value | 64 bits integer value to write. |
|
inlineprotected |
write unsigned integer value.
| value | unsigned integer value to write. |
|
inlineprotected |
write 64 bits unsigned integer value.
| value | 64 bits unsigned integer value to write. |
|
protected |
array flags of the open containers, one bit per depth.
|
protected |
output buffer.
|
protected |
number of open containers.
|
protected |
is first element.
|
protected |
indentation.
|
protected |
underlying output stream.
|
protected |
output buffer size.