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

#include <IIntrospectableData.h>

Inheritance diagram for zserio::IIntrospectableData< I, ALLOC >:

Public Types

using ConstPtr = std::shared_ptr< const I >
 

Public Member Functions

virtual ~IIntrospectableData ()=default
 
virtual const IBasicTypeInfo< ALLOC > & 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 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< ALLOC > & 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 ConstPtr operator[] (std::string_view path) const =0
 
virtual BasicAny< ALLOC > getAnyValue (const ALLOC &allocator) const =0
 
virtual BasicAny< ALLOC > getAnyValue () const =0
 
virtual BasicString< RebindAlloc< ALLOC, char > > toString (const ALLOC &allocator) const =0
 
virtual BasicString< RebindAlloc< ALLOC, char > > toString () const =0
 

Detailed Description

template<typename I, typename ALLOC = std::allocator<uint8_t>>
class zserio::IIntrospectableData< I, ALLOC >

Interface to introspect Data abstraction of the Zserio objects.

This is read-only interface which offers all information available from the Data abstraction of the Zserio objects.

Definition at line 27 of file IIntrospectableData.h.

Member Typedef Documentation

◆ ConstPtr

template<typename I , typename ALLOC = std::allocator<uint8_t>>
using zserio::IIntrospectableData< I, ALLOC >::ConstPtr = std::shared_ptr<const I>

Shared pointer to the constant introspectable interface.

Definition at line 31 of file IIntrospectableData.h.

Constructor & Destructor Documentation

◆ ~IIntrospectableData()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual zserio::IIntrospectableData< I, ALLOC >::~IIntrospectableData ( )
virtualdefault

Destructor.

Member Function Documentation

◆ at()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual ConstPtr zserio::IIntrospectableData< I, ALLOC >::at ( size_t  index) const
pure virtual

Gets the introspectable to an array element.

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

◆ find()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual ConstPtr zserio::IIntrospectableData< I, ALLOC >::find ( std::string_view  path) const
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 I , typename ALLOC = std::allocator<uint8_t>>
virtual BasicAny<ALLOC> zserio::IIntrospectableData< I, ALLOC >::getAnyValue ( ) const
pure virtual

Gets any value within the introspective 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 I , typename ALLOC = std::allocator<uint8_t>>
virtual BasicAny<ALLOC> zserio::IIntrospectableData< I, ALLOC >::getAnyValue ( const ALLOC &  allocator) const
pure virtual

Gets any value within the introspective 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.

◆ getBitBuffer()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual const BasicBitBuffer<ALLOC>& zserio::IIntrospectableData< I, ALLOC >::getBitBuffer ( ) const
pure virtual

Gets reference to the introspective bit buffer.

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

◆ getBool()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual bool zserio::IIntrospectableData< I, ALLOC >::getBool ( ) const
pure virtual

Gets bool value of the bool introspectable.

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

◆ getBytes()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual BytesView zserio::IIntrospectableData< I, ALLOC >::getBytes ( ) const
pure virtual

Gets byte value of the bytes introspectable.

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

◆ getChoice()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual std::string_view zserio::IIntrospectableData< I, ALLOC >::getChoice ( ) const
pure virtual

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

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

◆ getDouble()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual double zserio::IIntrospectableData< I, ALLOC >::getDouble ( ) const
pure virtual

Gets double value of the double introspectable.

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

◆ getField()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual ConstPtr zserio::IIntrospectableData< I, ALLOC >::getField ( std::string_view  name) const
pure virtual

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

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

◆ getFloat()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual float zserio::IIntrospectableData< I, ALLOC >::getFloat ( ) const
pure virtual

Gets float value of the float introspectable.

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

◆ getInt16()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual int16_t zserio::IIntrospectableData< I, ALLOC >::getInt16 ( ) const
pure virtual

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

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

◆ getInt32()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual int32_t zserio::IIntrospectableData< I, ALLOC >::getInt32 ( ) const
pure virtual

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

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

◆ getInt64()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual int64_t zserio::IIntrospectableData< I, ALLOC >::getInt64 ( ) const
pure virtual

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

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

◆ getInt8()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual int8_t zserio::IIntrospectableData< I, ALLOC >::getInt8 ( ) const
pure virtual

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

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

◆ getStringView()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual std::string_view zserio::IIntrospectableData< I, ALLOC >::getStringView ( ) const
pure virtual

Gets reference to the string value of the string introspectable.

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

◆ getTypeInfo()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual const IBasicTypeInfo<ALLOC>& zserio::IIntrospectableData< I, ALLOC >::getTypeInfo ( ) const
pure virtual

Gets type info for the current zserio object.

Returns
Reference to the static instance of type info.

◆ getUInt16()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual uint16_t zserio::IIntrospectableData< I, ALLOC >::getUInt16 ( ) const
pure virtual

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

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

◆ getUInt32()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual uint32_t zserio::IIntrospectableData< I, ALLOC >::getUInt32 ( ) const
pure virtual

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

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

◆ getUInt64()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual uint64_t zserio::IIntrospectableData< I, ALLOC >::getUInt64 ( ) const
pure virtual

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

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

◆ getUInt8()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual uint8_t zserio::IIntrospectableData< I, ALLOC >::getUInt8 ( ) const
pure virtual

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

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

◆ isArray()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual bool zserio::IIntrospectableData< I, ALLOC >::isArray ( ) const
pure virtual

Gets whether the introspective object is an array.

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

◆ operator[]() [1/2]

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual ConstPtr zserio::IIntrospectableData< I, ALLOC >::operator[] ( size_t  index) const
pure virtual

Gets the introspectable to an array element.

Note
Can be called only when the introspective object is an array.
Returns
The introspectable to an array element on the given index.
Exceptions
CppRuntimeExceptionWhen the introspective 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 I , typename ALLOC = std::allocator<uint8_t>>
virtual ConstPtr zserio::IIntrospectableData< I, ALLOC >::operator[] ( std::string_view  path) const
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.

◆ size()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual size_t zserio::IIntrospectableData< I, ALLOC >::size ( ) const
pure virtual

Gets size of the introspective array.

Note
Can be called only when the introspective object is an array.
Returns
Size of the introspective array.
Exceptions
CppRuntimeExceptionWhen the introspective object is not an array.

◆ toDouble()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual double zserio::IIntrospectableData< I, ALLOC >::toDouble ( ) const
pure virtual

Converts any numeric value to double.

Works also for bitmask and enum types.

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

◆ toInt()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual int64_t zserio::IIntrospectableData< I, ALLOC >::toInt ( ) const
pure virtual

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 introspective object cannot be converted to a signed integral value.

◆ toString() [1/2]

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual BasicString<RebindAlloc<ALLOC, char> > zserio::IIntrospectableData< I, ALLOC >::toString ( ) const
pure virtual

Converts an introspective 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 introspective object.

◆ toString() [2/2]

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual BasicString<RebindAlloc<ALLOC, char> > zserio::IIntrospectableData< I, ALLOC >::toString ( const ALLOC &  allocator) const
pure virtual

Converts an introspective 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 introspective object.

◆ toUInt()

template<typename I , typename ALLOC = std::allocator<uint8_t>>
virtual uint64_t zserio::IIntrospectableData< I, ALLOC >::toUInt ( ) const
pure virtual

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 introspective object cannot be converted to an unsigned integral value.

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