Zserio C++ runtime library  1.1.0
Built for Zserio 2.15.0
zserio::ReflectableArrayBase< ALLOC > Class Template Reference

#include <Reflectable.h>

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

Public Member Functions

bool isArray () const override
 
void initializeChildren () override
 
void initialize (const vector< AnyHolder< ALLOC >, ALLOC > &typeArguments) override
 
size_t initializeOffsets (size_t bitPosition) override
 
size_t bitSizeOf (size_t bitPosition) const override
 
void write (BitStreamWriter &writer) const override
 
IBasicReflectableConstPtr< ALLOC > getField (StringView name) const override
 
IBasicReflectablePtr< ALLOC > getField (StringView name) override
 
IBasicReflectablePtr< ALLOC > createField (StringView name) override
 
void setField (StringView name, const AnyHolder< ALLOC > &value) override
 
IBasicReflectableConstPtr< ALLOC > getParameter (StringView name) const override
 
IBasicReflectablePtr< ALLOC > getParameter (StringView name) override
 
IBasicReflectableConstPtr< ALLOC > callFunction (StringView name) const override
 
IBasicReflectablePtr< ALLOC > callFunction (StringView name) override
 
StringView getChoice () const override
 
IBasicReflectableConstPtr< ALLOC > operator[] (size_t index) const override
 
IBasicReflectablePtr< ALLOC > operator[] (size_t index) override
 
bool getBool () const override
 
int8_t getInt8 () const override
 
int16_t getInt16 () const override
 
int32_t getInt32 () const override
 
int64_t getInt64 () const override
 
uint8_t getUInt8 () const override
 
uint16_t getUInt16 () const override
 
uint32_t getUInt32 () const override
 
uint64_t getUInt64 () const override
 
float getFloat () const override
 
double getDouble () const override
 
Span< const uint8_t > getBytes () const override
 
StringView getStringView () const override
 
const BasicBitBuffer< ALLOC > & getBitBuffer () const override
 
int64_t toInt () const override
 
uint64_t toUInt () const override
 
double toDouble () const override
 
string< ALLOC > toString (const ALLOC &allocator) const override
 
- Public Member Functions inherited from zserio::ReflectableAllocatorHolderBase< ALLOC >
 ReflectableAllocatorHolderBase (const IBasicTypeInfo< ALLOC > &typeInfo, const ALLOC &allocator)
 
- Public Member Functions inherited from zserio::ReflectableBase< ALLOC >
 ReflectableBase (const IBasicTypeInfo< ALLOC > &typeInfo)
 
 ~ReflectableBase () override=0
 
const IBasicTypeInfo< ALLOC > & getTypeInfo () const override
 
size_t initializeOffsets () override
 
size_t bitSizeOf () const override
 
IBasicReflectableConstPtr< ALLOC > find (StringView path) const override
 
IBasicReflectablePtr< ALLOC > find (StringView path) override
 
IBasicReflectableConstPtr< ALLOC > operator[] (StringView path) const override
 
IBasicReflectablePtr< ALLOC > operator[] (StringView path) override
 
size_t size () const override
 
void resize (size_t size) override
 
IBasicReflectableConstPtr< ALLOC > at (size_t index) const override
 
IBasicReflectablePtr< ALLOC > at (size_t index) override
 
void setAt (const AnyHolder< ALLOC > &value, size_t index) override
 
void append (const AnyHolder< ALLOC > &value) override
 
AnyHolder< ALLOC > getAnyValue (const ALLOC &allocator) const override
 
AnyHolder< ALLOC > getAnyValue (const ALLOC &allocator) override
 
AnyHolder< ALLOC > getAnyValue () const override
 
AnyHolder< ALLOC > getAnyValue () override
 
string< ALLOC > toString () const override
 
const ParsingInfoparsingInfo () const override
 
 ReflectableBase (const ReflectableBase &)=delete
 
ReflectableBaseoperator= (const ReflectableBase &)=delete
 
 ReflectableBase (const ReflectableBase &&)=delete
 
ReflectableBaseoperator= (const ReflectableBase &&)=delete
 
- Public Member Functions inherited from zserio::IBasicReflectable< ALLOC >
virtual ~IBasicReflectable ()=default
 
- Public Member Functions inherited from zserio::AllocatorHolder< ALLOC >
 AllocatorHolder ()
 
 AllocatorHolder (const allocator_type &allocator)
 
 AllocatorHolder (allocator_type &&allocator)
 
allocator_type get_allocator () const
 
 ~AllocatorHolder ()=default
 
 AllocatorHolder (const AllocatorHolder &other)=default
 
AllocatorHolderoperator= (const AllocatorHolder &other)=default
 
 AllocatorHolder (AllocatorHolder &&other)=default
 
AllocatorHolderoperator= (AllocatorHolder &&other)=default
 

Additional Inherited Members

- Public Types inherited from zserio::IBasicReflectable< ALLOC >
using Ptr = std::shared_ptr< IBasicReflectable >
 
using ConstPtr = std::shared_ptr< const IBasicReflectable >
 
- Public Types inherited from zserio::AllocatorHolder< ALLOC >
using allocator_type = ALLOC
 
- Protected Member Functions inherited from zserio::AllocatorHolder< ALLOC >
void set_allocator (const allocator_type &allocator)
 
void set_allocator (allocator_type &&allocator)
 
allocator_typeget_allocator_ref ()
 
const allocator_typeget_allocator_ref () const
 

Detailed Description

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

Base class for reflectable arrays.

Overrides all generic methods with default throw behaviour.

Definition at line 2067 of file Reflectable.h.

Member Function Documentation

◆ bitSizeOf()

template<typename ALLOC >
size_t zserio::ReflectableArrayBase< ALLOC >::bitSizeOf ( size_t  bitPosition) const
overridevirtual

Gets the number of bits needed for serialization of the reflected object.

Note
Works for all reflectable types except arrays!
Parameters
bitPositionThe bit stream position to be used for calculation.
Exceptions
CppRuntimeExceptionWhen the reflected object is an array.
Returns
The size of the serialized reflected object in bits.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4452 of file Reflectable.h.

◆ callFunction() [1/2]

template<typename ALLOC >
IBasicReflectableConstPtr< ALLOC > zserio::ReflectableArrayBase< ALLOC >::callFunction ( StringView  name) const
overridevirtual

Calls function with the given name on the reflected zserio object and gets reflectable view to its result.

Note
Can be called only when the reflected object is a zserio compound type.
Parameters
nameFunction schema name.
Returns
Reflectable view to the value returns from the called function.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a compound type or when the function with the given name doesn't exist or the the function call itself throws.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4500 of file Reflectable.h.

◆ callFunction() [2/2]

template<typename ALLOC >
IBasicReflectablePtr< ALLOC > zserio::ReflectableArrayBase< ALLOC >::callFunction ( StringView  name)
overridevirtual

Calls function with the given name on the reflected zserio object and gets reflectable view to its result.

Note
Can be called only when the reflected object is a zserio compound type.
Parameters
nameFunction schema name.
Returns
Reflectable view to the value returns from the called function.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a compound type or when the function with the given name doesn't exist or the the function call itself throws.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4506 of file Reflectable.h.

◆ createField()

template<typename ALLOC >
IBasicReflectablePtr< ALLOC > zserio::ReflectableArrayBase< ALLOC >::createField ( StringView  name)
overridevirtual

Creates a default constructed field within current object and returns reflectable pointer to it.

Note
When the field already exists, it's reset with the new default constructed value.
Parameters
nameName of the optional field to create.
Returns
Reflectable to just created object.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a compound type or when the field with the given name doesn't exists.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4476 of file Reflectable.h.

◆ getBitBuffer()

template<typename ALLOC >
const BasicBitBuffer< ALLOC > & zserio::ReflectableArrayBase< ALLOC >::getBitBuffer
overridevirtual

Gets reference to the reflected bit buffer.

Returns
Reference to the bit buffer.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a bit buffer (i.e. extern type).

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4608 of file Reflectable.h.

◆ getBool()

template<typename ALLOC >
bool zserio::ReflectableArrayBase< ALLOC >::getBool
overridevirtual

Gets bool value of the bool reflectable.

Returns
Bool value.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a bool type.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4530 of file Reflectable.h.

◆ getBytes()

template<typename ALLOC >
Span< const uint8_t > zserio::ReflectableArrayBase< ALLOC >::getBytes
overridevirtual

Gets byte value of the bytes reflectable.

Returns
Bytes value as a span.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a bytes type.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4596 of file Reflectable.h.

◆ getChoice()

template<typename ALLOC >
StringView zserio::ReflectableArrayBase< ALLOC >::getChoice
overridevirtual

Gets name of the field which is active in the reflected choice type.

Note
Applicable only on zserio unions and choices.
Returns
Name of the active field (i.e. currently selected choice).
Exceptions
CppRuntimeExceptionWhen the reflected object is not a choice type (or union).

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4512 of file Reflectable.h.

◆ getDouble()

template<typename ALLOC >
double zserio::ReflectableArrayBase< ALLOC >::getDouble
overridevirtual

Gets double value of the double reflectable.

Returns
Double value.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a double type.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4590 of file Reflectable.h.

◆ getField() [1/2]

template<typename ALLOC >
IBasicReflectableConstPtr< ALLOC > zserio::ReflectableArrayBase< ALLOC >::getField ( StringView  name) const
overridevirtual

Gets reflectable view to the field (i.e. member) with the given schema name.

Note
Can be called only when the reflected object is a zserio compound type.
Parameters
nameField schema name.
Returns
Reflectable view to the requested field.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a compound type or when the field with the given name doesn't exist or when the field getter itself throws.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4464 of file Reflectable.h.

◆ getField() [2/2]

template<typename ALLOC >
IBasicReflectablePtr< ALLOC > zserio::ReflectableArrayBase< ALLOC >::getField ( StringView  name)
overridevirtual

Gets reflectable view to the field (i.e. member) with the given schema name.

Note
Can be called only when the reflected object is a zserio compound type.
Parameters
nameField schema name.
Returns
Reflectable view to the requested field.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a compound type or when the field with the given name doesn't exist or when the field getter itself throws.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4470 of file Reflectable.h.

◆ getFloat()

template<typename ALLOC >
float zserio::ReflectableArrayBase< ALLOC >::getFloat
overridevirtual

Gets float value of the float reflectable.

Returns
Float value.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a float type.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4584 of file Reflectable.h.

◆ getInt16()

template<typename ALLOC >
int16_t zserio::ReflectableArrayBase< ALLOC >::getInt16
overridevirtual

Gets 16-bit signed integral value of the int16_t reflectable.

Returns
16-bit signed integral value.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a int16_t type.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4542 of file Reflectable.h.

◆ getInt32()

template<typename ALLOC >
int32_t zserio::ReflectableArrayBase< ALLOC >::getInt32
overridevirtual

Gets 32-bit signed integral value of the int32_t reflectable.

Returns
32-bit signed integral value.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a int32_t type.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4548 of file Reflectable.h.

◆ getInt64()

template<typename ALLOC >
int64_t zserio::ReflectableArrayBase< ALLOC >::getInt64
overridevirtual

Gets 64-bit signed integral value of the int64_t reflectable.

Returns
64-bit signed integral value.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a int64_t type.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4554 of file Reflectable.h.

◆ getInt8()

template<typename ALLOC >
int8_t zserio::ReflectableArrayBase< ALLOC >::getInt8
overridevirtual

Gets 8-bit signed integral value of the int8_t reflectable.

Returns
8-bit signed integral value.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a int8_t type.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4536 of file Reflectable.h.

◆ getParameter() [1/2]

template<typename ALLOC >
IBasicReflectableConstPtr< ALLOC > zserio::ReflectableArrayBase< ALLOC >::getParameter ( StringView  name) const
overridevirtual

Gets reflectable view to the parameter (i.e. member) with the given schema name.

Note
Can be called only when the reflected object is a zserio compound type.
Parameters
nameParameter schema name.
Returns
Reflectable view to the requested parameter.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a compound type or when the parameter with the given name doesn't exist or when the parameter getter itself throws.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4488 of file Reflectable.h.

◆ getParameter() [2/2]

template<typename ALLOC >
IBasicReflectablePtr< ALLOC > zserio::ReflectableArrayBase< ALLOC >::getParameter ( StringView  name)
overridevirtual

Gets reflectable view to the parameter (i.e. member) with the given schema name.

Note
Can be called only when the reflected object is a zserio compound type.
Parameters
nameParameter schema name.
Returns
Reflectable view to the requested parameter.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a compound type or when the parameter with the given name doesn't exist or when the parameter getter itself throws.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4494 of file Reflectable.h.

◆ getStringView()

template<typename ALLOC >
StringView zserio::ReflectableArrayBase< ALLOC >::getStringView
overridevirtual

Gets reference to the string value of the string reflectable.

Returns
Reference to the string value.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a string type.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4602 of file Reflectable.h.

◆ getUInt16()

template<typename ALLOC >
uint16_t zserio::ReflectableArrayBase< ALLOC >::getUInt16
overridevirtual

Gets 16-bit unsigned integral value of the uint16_t reflectable.

Returns
16-bit unsigned integral value.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a uint16_t type.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4566 of file Reflectable.h.

◆ getUInt32()

template<typename ALLOC >
uint32_t zserio::ReflectableArrayBase< ALLOC >::getUInt32
overridevirtual

Gets 32-bit unsigned integral value of the uint32_t reflectable.

Returns
32-bit unsigned integral value.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a uint32_t type.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4572 of file Reflectable.h.

◆ getUInt64()

template<typename ALLOC >
uint64_t zserio::ReflectableArrayBase< ALLOC >::getUInt64
overridevirtual

Gets 64-bit unsigned integral value of the uint64_t reflectable.

Returns
64-bit unsigned integral value.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a uint64_t type.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4578 of file Reflectable.h.

◆ getUInt8()

template<typename ALLOC >
uint8_t zserio::ReflectableArrayBase< ALLOC >::getUInt8
overridevirtual

Gets 8-bit unsigned integral value of the uint8_t reflectable.

Returns
8-bit unsigned integral value.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a uint8_t type.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4560 of file Reflectable.h.

◆ initialize()

template<typename ALLOC >
void zserio::ReflectableArrayBase< ALLOC >::initialize ( const vector< AnyHolder< ALLOC >, ALLOC > &  typeArguments)
overridevirtual

Initializes the reflected parameterized compound object. Calls initialize method on the generated C++ object. Note that the arguments must exactly match. In case that the argument is a compound type, which is normally passed as a reference, it must be wrapped in a reference wrapper.

Exceptions
CppRuntimeExceptionWhen the reflected object is not parameterized or when the arguments do not match.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4440 of file Reflectable.h.

◆ initializeChildren()

template<typename ALLOC >
void zserio::ReflectableArrayBase< ALLOC >::initializeChildren
overridevirtual

Initializes children of the reflected compound. Calls initializeChildren method on the generated C++ object, which recursively initializes the whole object tree. When nothing within the object tree is parameterized, does nothing.

Note
This method is designed to be called on the top level object (i.e. root).
Exceptions
CppRuntimeExceptionWhen the reflected object is not a compound type.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4434 of file Reflectable.h.

◆ initializeOffsets()

template<typename ALLOC >
size_t zserio::ReflectableArrayBase< ALLOC >::initializeOffsets ( size_t  bitPosition)
overridevirtual

Initializes indexed offsets of the reflected compound object.

Parameters
bitPositionThe bit stream position to be used for calculation.
Exceptions
CppRuntimeExceptionWhen the reflected object is not a compound.
Returns
Updated bit position which points to the first bit after the compound.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4446 of file Reflectable.h.

◆ isArray()

template<typename ALLOC >
bool zserio::ReflectableArrayBase< ALLOC >::isArray ( ) const
inlineoverridevirtual

Gets whether the reflected object is an array.

Returns
True when the object is an array, false otherwise.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 2076 of file Reflectable.h.

◆ operator[]() [1/2]

template<typename ALLOC >
IBasicReflectableConstPtr< ALLOC > zserio::ReflectableArrayBase< ALLOC >::operator[] ( size_t  index) const
overridevirtual

Gets reflectable view to an array element.

Note
Can be called only when the reflected object is an array.
Returns
Reflectable view to an array element on the given index.
Exceptions
CppRuntimeExceptionWhen the reflected object is not an array or when the given index is out of bounds of the underlying array.

Overloaded method provided for convenience.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4518 of file Reflectable.h.

◆ operator[]() [2/2]

template<typename ALLOC >
IBasicReflectablePtr< ALLOC > zserio::ReflectableArrayBase< ALLOC >::operator[] ( size_t  index)
overridevirtual

Gets reflectable view to an array element.

Note
Can be called only when the reflected object is an array.
Returns
Reflectable view to an array element on the given index.
Exceptions
CppRuntimeExceptionWhen the reflected object is not an array or when the given index is out of bounds of the underlying array.

Overloaded method provided for convenience.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Reimplemented in zserio::ReflectableConstArrayBase< ALLOC >.

Definition at line 4524 of file Reflectable.h.

◆ setField()

template<typename ALLOC >
void zserio::ReflectableArrayBase< ALLOC >::setField ( StringView  name,
const AnyHolder< ALLOC > &  value 
)
overridevirtual

Sets the field (i.e. member) with the given schema name.

Note
For optional fields, the value can be also nullptr of type std::nullptr_t which allows to reset an optional field.
Parameters
nameField schema name.
valueValue to set. The type must exactly match the type of the zserio field mapped to C++!
Exceptions
CppRuntimeExceptionWhen the reflected object is not a compound type or when the field with the given name doesn't exist or when the provided value is of a wrong type or when the field setter itself throws.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4482 of file Reflectable.h.

◆ toDouble()

template<typename ALLOC >
double zserio::ReflectableArrayBase< ALLOC >::toDouble
overridevirtual

Converts any numeric value to double.

Works also for bitmask and enum types.

Returns
Double value.
Exceptions
CppRuntimeExceptionWhen the reflected object cannot be converted to double.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4626 of file Reflectable.h.

◆ toInt()

template<typename ALLOC >
int64_t zserio::ReflectableArrayBase< ALLOC >::toInt
overridevirtual

Converts any signed integral value to 64-bit signed integer.

Works also for enum types defined with signed underlying type.

Returns
64-bit signed integral value.
Exceptions
CppRuntimeExceptionWhen the reflected object cannot be converted to a signed integral value.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4614 of file Reflectable.h.

◆ toString()

template<typename ALLOC >
string< ALLOC > zserio::ReflectableArrayBase< ALLOC >::toString ( const ALLOC &  allocator) const
overridevirtual

Converts an reflected object to string.

Works for all integral types including bool, bitmask and enum types and for string types.

Note
Floating point types are not currently supported!
The conversion to string can be implemented for more types in future versions.
Overload without parameter use default constructed allocator.
Parameters
allocatorAllocator to use for the string allocation.
Returns
String value representing the reflected object.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4632 of file Reflectable.h.

◆ toUInt()

template<typename ALLOC >
uint64_t zserio::ReflectableArrayBase< ALLOC >::toUInt
overridevirtual

Converts any unsigned integral value to 64-bit unsigned integer.

Works also for bitmask and enum typed defined with unsigned underlying type.

Returns
64-bit unsigned integral value.
Exceptions
CppRuntimeExceptionWhen the reflected object cannot be converted to an unsigned integral value.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4620 of file Reflectable.h.

◆ write()

template<typename ALLOC >
void zserio::ReflectableArrayBase< ALLOC >::write ( BitStreamWriter writer) const
overridevirtual

Writes the reflected object to a bit stream using the given bit stream writer.

Note
Works for all reflectable types except arrays!
Parameters
writerBit stream writer to use.
Exceptions
CppRuntimeExceptionWhen the reflected object is an array.

Reimplemented from zserio::ReflectableBase< ALLOC >.

Definition at line 4458 of file Reflectable.h.


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