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

#include <IReflectableData.h>

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

Public Types

using Ptr = std::shared_ptr< IBasicReflectableData >
 
using ConstPtr = typename IIntrospectableData< IBasicReflectableData< ALLOC >, ALLOC >::ConstPtr
 
- Public Types inherited from zserio::IIntrospectableData< IBasicReflectableData< std::allocator< uint8_t > >, std::allocator< uint8_t > >
using ConstPtr = std::shared_ptr< const IBasicReflectableData< std::allocator< uint8_t > > >
 

Public Member Functions

 ~IBasicReflectableData () override=default
 
virtual Ptr getField (std::string_view name)=0
 
virtual void setField (std::string_view name, const BasicAny< ALLOC > &value)=0
 
virtual Ptr createField (std::string_view name)=0
 
virtual void resize (size_t size)=0
 
virtual Ptr at (size_t index)=0
 
virtual Ptr operator[] (size_t index)=0
 
virtual void setAt (const BasicAny< ALLOC > &value, size_t index)=0
 
virtual void append (const BasicAny< ALLOC > &value)=0
 
virtual Ptr find (std::string_view path)=0
 
virtual Ptr operator[] (std::string_view path)=0
 
virtual BasicAny< ALLOC > getAnyValue (const ALLOC &allocator)=0
 
virtual BasicAny< ALLOC > getAnyValue ()=0
 
- Public Member Functions inherited from zserio::IIntrospectableData< IBasicReflectableData< std::allocator< uint8_t > >, std::allocator< uint8_t > >
virtual ~IIntrospectableData ()=default
 
virtual const IBasicTypeInfo< std::allocator< uint8_t > > & getTypeInfo () const=0
 
virtual bool isArray () const=0
 
virtual ConstPtr getField (std::string_view name) const=0
 
virtual std::string_view getChoice () const=0
 
virtual size_t size () const=0
 
virtual ConstPtr at (size_t index) const=0
 
virtual ConstPtr operator[] (size_t index) const=0
 
virtual ConstPtr operator[] (std::string_view path) const=0
 
virtual bool getBool () const=0
 
virtual int8_t getInt8 () const=0
 
virtual int16_t getInt16 () const=0
 
virtual int32_t getInt32 () const=0
 
virtual int64_t getInt64 () const=0
 
virtual uint8_t getUInt8 () const=0
 
virtual uint16_t getUInt16 () const=0
 
virtual uint32_t getUInt32 () const=0
 
virtual uint64_t getUInt64 () const=0
 
virtual float getFloat () const=0
 
virtual double getDouble () const=0
 
virtual BytesView getBytes () const=0
 
virtual std::string_view getStringView () const=0
 
virtual const BasicBitBuffer< std::allocator< uint8_t > > & getBitBuffer () const=0
 
virtual int64_t toInt () const=0
 
virtual uint64_t toUInt () const=0
 
virtual double toDouble () const=0
 
virtual ConstPtr find (std::string_view path) const=0
 
virtual BasicAny< std::allocator< uint8_t > > getAnyValue (const std::allocator< uint8_t > &allocator) const=0
 
virtual BasicAny< std::allocator< uint8_t > > getAnyValue () const=0
 
virtual BasicString< RebindAlloc< std::allocator< uint8_t >, char > > toString (const std::allocator< uint8_t > &allocator) const=0
 
virtual BasicString< RebindAlloc< std::allocator< uint8_t >, char > > toString () const=0
 

Detailed Description

template<typename ALLOC = std::allocator<uint8_t>>
class zserio::IBasicReflectableData< ALLOC >

Interface for reflection of the Zserio objects using Data abstraction.

This interface allows modification of all information available in the Data abstraction of the Zserio objects.

Definition at line 19 of file IReflectableData.h.

Member Typedef Documentation

◆ ConstPtr

template<typename ALLOC = std::allocator<uint8_t>>
using zserio::IBasicReflectableData< ALLOC >::ConstPtr = typename IIntrospectableData<IBasicReflectableData<ALLOC>, ALLOC>::ConstPtr

Shared pointer to the constant reflectable interface.

Definition at line 26 of file IReflectableData.h.

◆ Ptr

template<typename ALLOC = std::allocator<uint8_t>>
using zserio::IBasicReflectableData< ALLOC >::Ptr = std::shared_ptr<IBasicReflectableData>

Shared pointer to the reflectable interface.

Definition at line 23 of file IReflectableData.h.

Constructor & Destructor Documentation

◆ ~IBasicReflectableData()

template<typename ALLOC = std::allocator<uint8_t>>
zserio::IBasicReflectableData< ALLOC >::~IBasicReflectableData ( )
overridedefault

Destructor.

Member Function Documentation

◆ append()

template<typename ALLOC = std::allocator<uint8_t>>
virtual void zserio::IBasicReflectableData< ALLOC >::append ( const BasicAny< ALLOC > &  value)
pure virtual

Appends an element at the given index within the reflected array.

Parameters
valueValue to append.
Exceptions
CppRuntimeExceptionWhen the reflected object is not an array.

◆ at()

template<typename ALLOC = std::allocator<uint8_t>>
virtual Ptr zserio::IBasicReflectableData< ALLOC >::at ( size_t  index)
pure virtual

Gets reflectable to an array element.

Note
Can be called only when the reflected object is an array.
Returns
Reflectable 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.

◆ createField()

template<typename ALLOC = std::allocator<uint8_t>>
virtual Ptr zserio::IBasicReflectableData< ALLOC >::createField ( std::string_view  name)
pure virtual

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.

◆ find()

template<typename ALLOC = std::allocator<uint8_t>>
virtual Ptr zserio::IBasicReflectableData< ALLOC >::find ( std::string_view  path)
pure virtual

Universal accessor to zserio entities within the zserio sub-tree represented by the introspectable object.

Supports dot notation corresponding to the tree defined in zserio language. Can access fields or parameters or call functions within the zserio sub-tree.

Examples:

  • 'fieldA.param' - Gets introspectable to parameter 'param' within the parameterized field 'fieldA'.
  • 'child.getValue' - Gets introspectable to result of the function called on field ̈́'child'.
  • 'child.nonexisting.field' - Gets nullptr since the path doesn't represent a valid entity.
Parameters
pathDot notation corresponding to the zserio tree.
Returns
Introspectable to the result of the given path. Returns nullptr when the path doesn't exist or when the requested operation throws CppRuntimeException.

◆ getAnyValue() [1/2]

template<typename ALLOC = std::allocator<uint8_t>>
virtual BasicAny<ALLOC> zserio::IBasicReflectableData< ALLOC >::getAnyValue ( )
pure virtual

Gets any value within the reflected object.

For builtin types, enums and bitmasks the value is "returned by value" - i.e. it's copied into the any holder, but note that for bytes the any holder contains Span, for string the any holder contains an appropriate string_view and for compounds, bit buffers and arrays the value is "returned by reference" - i.e. the any holder contains std::reference_wrapper<T> with the reference to the compound type or the raw array type.

Note
For bit buffers only const reference is available.
Overloads without parameter use default constructed allocator.
Parameters
allocatorAllocator to use for the value allocation.
Returns
Any value.

◆ getAnyValue() [2/2]

template<typename ALLOC = std::allocator<uint8_t>>
virtual BasicAny<ALLOC> zserio::IBasicReflectableData< ALLOC >::getAnyValue ( const ALLOC &  allocator)
pure virtual

Gets any value within the reflected object.

For builtin types, enums and bitmasks the value is "returned by value" - i.e. it's copied into the any holder, but note that for bytes the any holder contains Span, for string the any holder contains an appropriate string_view and for compounds, bit buffers and arrays the value is "returned by reference" - i.e. the any holder contains std::reference_wrapper<T> with the reference to the compound type or the raw array type.

Note
For bit buffers only const reference is available.
Overloads without parameter use default constructed allocator.
Parameters
allocatorAllocator to use for the value allocation.
Returns
Any value.

◆ getField()

template<typename ALLOC = std::allocator<uint8_t>>
virtual Ptr zserio::IBasicReflectableData< ALLOC >::getField ( std::string_view  name)
pure virtual

Gets reflectable 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 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.

◆ operator[]() [1/2]

template<typename ALLOC = std::allocator<uint8_t>>
virtual Ptr zserio::IBasicReflectableData< ALLOC >::operator[] ( size_t  index)
pure virtual

Gets reflectable to an array element.

Note
Can be called only when the reflected object is an array.
Returns
Reflectable 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.

◆ operator[]() [2/2]

template<typename ALLOC = std::allocator<uint8_t>>
virtual Ptr zserio::IBasicReflectableData< ALLOC >::operator[] ( std::string_view  path)
pure virtual

Universal accessor to zserio entities within the zserio sub-tree represented by the introspectable object.

Supports dot notation corresponding to the tree defined in zserio language. Can access fields or parameters or call functions within the zserio sub-tree.

Examples:

  • 'fieldA.param' - Gets introspectable to parameter 'param' within the parameterized field 'fieldA'.
  • 'child.getValue' - Gets introspectable to result of the function called on field ̈́'child'.
  • 'child.nonexisting.field' - Gets nullptr since the path doesn't represent a valid entity.
Parameters
pathDot notation corresponding to the zserio tree.
Returns
Introspectable to the result of the given path. Returns nullptr when the path doesn't exist or when the requested operation throws CppRuntimeException.

Overloaded method provided for convenience.

◆ resize()

template<typename ALLOC = std::allocator<uint8_t>>
virtual void zserio::IBasicReflectableData< ALLOC >::resize ( size_t  size)
pure virtual

Resizes the reflected array.

Note
Can be called only when the reflected object is an array.
Parameters
sizeNew array size.
Exceptions
CppRuntimeExceptionWhen the reflected object is not an array.

◆ setAt()

template<typename ALLOC = std::allocator<uint8_t>>
virtual void zserio::IBasicReflectableData< ALLOC >::setAt ( const BasicAny< ALLOC > &  value,
size_t  index 
)
pure virtual

Sets an element value at the given index within the reflected array.

Parameters
valueValue to set.
indexIndex of the element to set.
Exceptions
CppRuntimeExceptionWhen the reflected object is not an array.

◆ setField()

template<typename ALLOC = std::allocator<uint8_t>>
virtual void zserio::IBasicReflectableData< ALLOC >::setField ( std::string_view  name,
const BasicAny< ALLOC > &  value 
)
pure virtual

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.

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