Zserio C++ runtime library
1.0.0
Built for Zserio 2.13.0
|
#include <JsonWriter.h>
Public Types | |
enum | EnumerableFormat { EnumerableFormat::NUMBER, EnumerableFormat::STRING } |
![]() | |
using | allocator_type = ALLOC |
Public Member Functions | |
BasicJsonWriter (std::ostream &out, const ALLOC &allocator=ALLOC()) | |
BasicJsonWriter (std::ostream &out, uint8_t indent, const ALLOC &allocator=ALLOC()) | |
BasicJsonWriter (std::ostream &out, const string< ALLOC > &indent, const ALLOC &allocator=ALLOC()) | |
~BasicJsonWriter () override=default | |
void | setItemSeparator (const string< ALLOC > &itemSeparator) |
void | setKeySeparator (const string< ALLOC > &keySeparator) |
void | setEnumerableFormat (EnumerableFormat enumerableFormat) |
void | beginRoot (const IBasicReflectableConstPtr< ALLOC > &compound) override |
void | endRoot (const IBasicReflectableConstPtr< ALLOC > &compound) override |
void | beginArray (const IBasicReflectableConstPtr< ALLOC > &array, const BasicFieldInfo< ALLOC > &fieldInfo) override |
void | endArray (const IBasicReflectableConstPtr< ALLOC > &array, const BasicFieldInfo< ALLOC > &fieldInfo) override |
void | beginCompound (const IBasicReflectableConstPtr< ALLOC > &compound, const BasicFieldInfo< ALLOC > &fieldInfo, size_t elementIndex) override |
void | endCompound (const IBasicReflectableConstPtr< ALLOC > &compound, const BasicFieldInfo< ALLOC > &fieldInfo, size_t elementIndex) override |
void | visitValue (const IBasicReflectableConstPtr< ALLOC > &value, const BasicFieldInfo< ALLOC > &fieldInfo, size_t elementIndex) override |
BasicJsonWriter (const BasicJsonWriter &other)=delete | |
BasicJsonWriter & | operator= (const BasicJsonWriter &other)=delete |
BasicJsonWriter (BasicJsonWriter &&other)=delete | |
BasicJsonWriter & | operator= (BasicJsonWriter &&other)=delete |
![]() | |
virtual | ~IBasicWalkObserver ()=default |
![]() | |
AllocatorHolder () | |
AllocatorHolder (const allocator_type &allocator) | |
AllocatorHolder (allocator_type &&allocator) | |
allocator_type | get_allocator () const |
~AllocatorHolder ()=default | |
AllocatorHolder (const AllocatorHolder &other)=default | |
AllocatorHolder & | operator= (const AllocatorHolder &other)=default |
AllocatorHolder (AllocatorHolder &&other)=default | |
AllocatorHolder & | operator= (AllocatorHolder &&other)=default |
Static Public Attributes | |
static constexpr const char * | DEFAULT_ITEM_SEPARATOR = ", " |
static constexpr const char * | DEFAULT_ITEM_SEPARATOR_WITH_INDENT = "," |
static constexpr const char * | DEFAULT_KEY_SEPARATOR = ": " |
static constexpr EnumerableFormat | DEFAULT_ENUMERABLE_FORMAT = EnumerableFormat::STRING |
Additional Inherited Members | |
![]() | |
void | set_allocator (const allocator_type &allocator) |
void | set_allocator (allocator_type &&allocator) |
allocator_type & | get_allocator_ref () |
const allocator_type & | get_allocator_ref () const |
Walker observer which dumps zserio objects to JSON format.
Definition at line 19 of file JsonWriter.h.
|
strong |
Configuration for writing of enumerable types.
Definition at line 42 of file JsonWriter.h.
|
explicit |
Constructor.
out | Stream to use for writing. |
allocator | Allocator to use. |
Definition at line 189 of file JsonWriter.h.
zserio::BasicJsonWriter< ALLOC >::BasicJsonWriter | ( | std::ostream & | out, |
uint8_t | indent, | ||
const ALLOC & | allocator = ALLOC() |
||
) |
Constructor.
out | Stream to use for writing. |
indent | Indent as a number of ' ' to be used for indentation. |
allocator | Allocator to use. |
Definition at line 194 of file JsonWriter.h.
zserio::BasicJsonWriter< ALLOC >::BasicJsonWriter | ( | std::ostream & | out, |
const string< ALLOC > & | indent, | ||
const ALLOC & | allocator = ALLOC() |
||
) |
Constructor.
out | Stream to use for writing. |
indent | Indent as a string to be used for indentation. |
allocator | Allocator to use. |
Definition at line 199 of file JsonWriter.h.
|
overridedefault |
Method generated by default.
|
delete |
Copying and moving is disallowed!
|
delete |
Copying and moving is disallowed!
|
overridevirtual |
Called at the beginning of an array.
Note that for unset arrays (i.e. non-present optionals) the visitValue method with nullptr is called instead!
array | Reflectable zserio array. |
fieldInfo | Array field info. |
Implements zserio::IBasicWalkObserver< ALLOC >.
Definition at line 246 of file JsonWriter.h.
|
overridevirtual |
Called at the beginning of an compound field object.
Note that for unset compounds (i.e. non-present optionals) the visitValue method with nullptr is called instead!
compound | Reflectable compound zserio object. |
fieldInfo | Compound field info. |
elementIndex | Element index in array or WALKER_NOT_ELEMENT if the compound is not in array. |
Implements zserio::IBasicWalkObserver< ALLOC >.
Definition at line 265 of file JsonWriter.h.
|
overridevirtual |
Called for the root compound zserio object which is to be walked-through.
compound | Reflectable root compound zserio object. |
Implements zserio::IBasicWalkObserver< ALLOC >.
Definition at line 233 of file JsonWriter.h.
|
overridevirtual |
Called at the end of an array.
array | Reflectable zserio array. |
fieldInfo | Array field info. |
Implements zserio::IBasicWalkObserver< ALLOC >.
Definition at line 257 of file JsonWriter.h.
|
overridevirtual |
Called at the end of just walked compound object.
compound | Reflectable compound zserio object. |
fieldInfo | Compound field info. |
elementIndex | Element index in array or WALKER_NOT_ELEMENT if the compound is not in array. |
Implements zserio::IBasicWalkObserver< ALLOC >.
Definition at line 277 of file JsonWriter.h.
|
overridevirtual |
Called at the end of just walked root compound zserio object.
compound | Reflectable root compound zserio object. |
Implements zserio::IBasicWalkObserver< ALLOC >.
Definition at line 239 of file JsonWriter.h.
|
delete |
Copying and moving is disallowed!
|
delete |
Copying and moving is disallowed!
void zserio::BasicJsonWriter< ALLOC >::setEnumerableFormat | ( | EnumerableFormat | enumerableFormat | ) |
Sets preferred formatting for enumerable types.
enumerableFormat | Enumerable format to use. |
Definition at line 227 of file JsonWriter.h.
void zserio::BasicJsonWriter< ALLOC >::setItemSeparator | ( | const string< ALLOC > & | itemSeparator | ) |
Sets custom item separator.
Use with caution since setting of a wrong separator can lead to invalid JSON output.
itemSeparator | Item separator to set. |
Definition at line 215 of file JsonWriter.h.
void zserio::BasicJsonWriter< ALLOC >::setKeySeparator | ( | const string< ALLOC > & | keySeparator | ) |
Sets custom key separator.
Use with caution since setting of a wrong separator can lead to invalid JSON output.
keySeparator | Key separator to set. |
Definition at line 221 of file JsonWriter.h.
|
overridevirtual |
Called when a simple (or an unset compound or array - i.e. nullptr) value is reached.
value | Reflectable simple value. |
fieldInfo | Field info. |
elementIndex | Element index in array or WALKER_NOT_ELEMENT if the value is not in array. |
Implements zserio::IBasicWalkObserver< ALLOC >.
Definition at line 286 of file JsonWriter.h.
|
static |
Default configuration for enumerable types.
Definition at line 67 of file JsonWriter.h.
|
static |
Default item separator used when indent is not set.
Definition at line 27 of file JsonWriter.h.
|
static |
Default item separator used when indent is set.
Definition at line 32 of file JsonWriter.h.
|
static |
Default key separator.
Definition at line 37 of file JsonWriter.h.