Zserio C++17 runtime library  0.5.0
Built for Zserio 2.17.0
zserio::BasicZserioTreeCreator< ALLOC > Class Template Reference

#include <ZserioTreeCreator.h>

Inheritance diagram for zserio::BasicZserioTreeCreator< ALLOC >:
Collaboration diagram for zserio::BasicZserioTreeCreator< ALLOC >:

Public Member Functions

 BasicZserioTreeCreator (const IBasicTypeInfo< ALLOC > &typeInfo, const ALLOC &allocator=ALLOC())
 
void beginRoot ()
 
IBasicReflectableDataPtr< ALLOC > endRoot ()
 
void beginArray (const BasicString< RebindAlloc< ALLOC, char >> &name)
 
void endArray ()
 
void beginCompound (const BasicString< RebindAlloc< ALLOC, char >> &name)
 
void endCompound ()
 
template<typename T >
void setValue (const BasicString< RebindAlloc< ALLOC, char >> &name, T &&value)
 
void setValue (const BasicString< RebindAlloc< ALLOC, char >> &name, std::nullptr_t nullValue)
 
const IBasicTypeInfo< ALLOC > & getFieldType (const BasicString< RebindAlloc< ALLOC, char >> &name) const
 
void beginCompoundElement ()
 
void endCompoundElement ()
 
template<typename T >
void addValueElement (T &&value)
 
const IBasicTypeInfo< ALLOC > & getElementType () const
 

Detailed Description

template<typename ALLOC>
class zserio::BasicZserioTreeCreator< ALLOC >

Allows to build zserio object tree defined by the given type info.

Definition at line 423 of file ZserioTreeCreator.h.

Constructor & Destructor Documentation

◆ BasicZserioTreeCreator()

template<typename ALLOC >
zserio::BasicZserioTreeCreator< ALLOC >::BasicZserioTreeCreator ( const IBasicTypeInfo< ALLOC > &  typeInfo,
const ALLOC &  allocator = ALLOC() 
)
explicit

Constructor.

Parameters
typeInfoType info defining the tree.

Definition at line 568 of file ZserioTreeCreator.h.

Member Function Documentation

◆ addValueElement()

template<typename ALLOC >
template<typename T >
void zserio::BasicZserioTreeCreator< ALLOC >::addValueElement ( T &&  value)

Adds the value to the array.

Parameters
valueValue to add.
Exceptions
CppRuntimeExceptionWhen the creator is not in an array of simple values.

Definition at line 796 of file ZserioTreeCreator.h.

◆ beginArray()

template<typename ALLOC >
void zserio::BasicZserioTreeCreator< ALLOC >::beginArray ( const BasicString< RebindAlloc< ALLOC, char >> &  name)

Creates an array field within the current compound.

Parameters
nameName of the array field.
Exceptions
CppRuntimeExceptionWhen the field doesn't exist or when the creator is not in a compound.

Definition at line 603 of file ZserioTreeCreator.h.

◆ beginCompound()

template<typename ALLOC >
void zserio::BasicZserioTreeCreator< ALLOC >::beginCompound ( const BasicString< RebindAlloc< ALLOC, char >> &  name)

Creates a compound field within the current compound.

Parameters
nameName of the compound field.
Exceptions
CppRuntimeExceptionWhen the field doesn't exist or when the creator is not in a compound.

Definition at line 645 of file ZserioTreeCreator.h.

◆ beginCompoundElement()

template<typename ALLOC >
void zserio::BasicZserioTreeCreator< ALLOC >::beginCompoundElement

Creates compound array element within the current array.

Exceptions
CppRuntimeExceptionWhen the creator is not in an array of compounds.

Definition at line 754 of file ZserioTreeCreator.h.

◆ beginRoot()

template<typename ALLOC >
void zserio::BasicZserioTreeCreator< ALLOC >::beginRoot

Creates the top level compound element and move to state of building its children.

Definition at line 577 of file ZserioTreeCreator.h.

◆ endArray()

template<typename ALLOC >
void zserio::BasicZserioTreeCreator< ALLOC >::endArray

Finishes the array field.

Exceptions
CppRuntimeExceptionWhen the creator is not in an array field.

Definition at line 632 of file ZserioTreeCreator.h.

◆ endCompound()

template<typename ALLOC >
void zserio::BasicZserioTreeCreator< ALLOC >::endCompound

Finishes the compound.

Exceptions
CppRuntimeExceptionWhen the creator is not in a compound.

Definition at line 680 of file ZserioTreeCreator.h.

◆ endCompoundElement()

template<typename ALLOC >
void zserio::BasicZserioTreeCreator< ALLOC >::endCompoundElement

Finishes the compound element.

Exceptions
CppRuntimeExceptionWhen the creator is not in a compound element.

Definition at line 776 of file ZserioTreeCreator.h.

◆ endRoot()

template<typename ALLOC >
IBasicReflectableDataPtr< ALLOC > zserio::BasicZserioTreeCreator< ALLOC >::endRoot

Finishes building and returns the created tree.

Returns
Zserio object tree.
Exceptions
CppRuntimeExceptionWhen the creator is not in state of building the root object.

Definition at line 589 of file ZserioTreeCreator.h.

◆ getElementType()

template<typename ALLOC >
const IBasicTypeInfo< ALLOC > & zserio::BasicZserioTreeCreator< ALLOC >::getElementType

Gets type info of the expected array element.

Returns
Type info of the expected array element.
Exceptions
CppRuntimeExceptionWhen the creator is not in an array.

Definition at line 808 of file ZserioTreeCreator.h.

◆ getFieldType()

template<typename ALLOC >
const IBasicTypeInfo< ALLOC > & zserio::BasicZserioTreeCreator< ALLOC >::getFieldType ( const BasicString< RebindAlloc< ALLOC, char >> &  name) const

Gets type info of the expected field.

Parameters
nameField name.
Returns
Type info of the expected field.
Exceptions
CppRuntimeExceptionWhen the creator is not in a compound.

Definition at line 742 of file ZserioTreeCreator.h.

◆ setValue() [1/2]

template<typename ALLOC >
void zserio::BasicZserioTreeCreator< ALLOC >::setValue ( const BasicString< RebindAlloc< ALLOC, char >> &  name,
std::nullptr_t  nullValue 
)

Overload for setting of a null value.

Note that this does nothing in C++ since non-optional fields are always present (default initialized).

Parameters
nameName of the field.
nullValueNull value.
Exceptions
CppRuntimeExceptionWhen the field doesn't exist or when the creator is not in a compound.

Definition at line 719 of file ZserioTreeCreator.h.

◆ setValue() [2/2]

template<typename ALLOC >
template<typename T >
void zserio::BasicZserioTreeCreator< ALLOC >::setValue ( const BasicString< RebindAlloc< ALLOC, char >> &  name,
T &&  value 
)

Sets field value within the current compound.

Parameters
nameName of the field.
valueValue to set.
Exceptions
CppRuntimeExceptionWhen the field doesn't exist or when the creator is not in a compound.

Definition at line 700 of file ZserioTreeCreator.h.


The documentation for this class was generated from the following file: