Zserio C++17 runtime library  0.5.0
Built for Zserio 2.17.0
zserio::ReflectableUtil Class Reference

#include <ReflectableUtil.h>

Static Public Member Functions

template<typename ALLOC = std::allocator<uint8_t>>
static bool equal (const IBasicReflectableDataConstPtr< ALLOC > &lhs, const IBasicReflectableDataConstPtr< ALLOC > &rhs)
 
template<typename T , typename ALLOC = std::allocator<uint8_t>, typename std::enable_if< detail::gets_value_by_value< T >::value, int >::type = 0>
static T getValue (const IBasicReflectableDataConstPtr< ALLOC > &reflectable, const ALLOC &allocator=ALLOC())
 
template<typename T , typename ALLOC = std::allocator<uint8_t>, typename std::enable_if<!detail::gets_value_by_value< T >::value, int >::type = 0>
static const T & getValue (const IBasicReflectableDataConstPtr< ALLOC > &reflectable, const ALLOC &allocator=ALLOC())
 
template<typename T , typename ALLOC = std::allocator<uint8_t>, typename std::enable_if<!detail::gets_value_by_value< T >::value &&!std::is_same< BasicBitBuffer< ALLOC >, T >::value, int >::type = 0>
static T & getValue (const IBasicReflectableDataPtr< ALLOC > &reflectable, const ALLOC &allocator=ALLOC())
 
template<typename T , typename ALLOC = std::allocator<uint8_t>, typename std::enable_if< std::is_same< BasicBitBuffer< ALLOC >, T >::value, int >::type = 0>
static const T & getValue (const IBasicReflectableDataPtr< ALLOC > &reflectable, const ALLOC &allocator=ALLOC())
 
template<typename T , typename ALLOC >
static T fromAny (const BasicAny< ALLOC > &any)
 

Detailed Description

Utilities on zserio reflectable interface.

Definition at line 35 of file ReflectableUtil.h.

Member Function Documentation

◆ equal()

template<typename ALLOC >
bool zserio::ReflectableUtil::equal ( const IBasicReflectableDataConstPtr< ALLOC > &  lhs,
const IBasicReflectableDataConstPtr< ALLOC > &  rhs 
)
static

Makes "deep" comparison of given reflectables.

Note
Floating point values are compared using "almost equal" strategy.
Parameters
lhsLeft-hand side reflectable.
rhsRight-hand side reflectable.
Returns
True when the reflectables are equal, false otherwise.

Definition at line 161 of file ReflectableUtil.h.

◆ fromAny()

template<typename T , typename ALLOC >
T zserio::ReflectableUtil::fromAny ( const BasicAny< ALLOC > &  any)
static

Gets a zserio type T from any value.

Parameters
anyAny value.
Returns
Zserio type T from a value stored in the any.
Exceptions
CppRuntimeExceptionWhen wrong type is present in the any value ("Bad type in BasicAny").

Definition at line 314 of file ReflectableUtil.h.

◆ getValue() [1/4]

template<typename T , typename ALLOC = std::allocator<uint8_t>, typename std::enable_if< detail::gets_value_by_value< T >::value, int >::type = 0>
static T zserio::ReflectableUtil::getValue ( const IBasicReflectableDataConstPtr< ALLOC > &  reflectable,
const ALLOC &  allocator = ALLOC() 
)
inlinestatic

Gets native value from the given reflectable.

Overload for types where the value is returned by value:

  • arithmetic types, enums, bitmasks and strings (via string view).
Parameters
reflectableReflectable to use for value extraction.
Returns
Value of the type T.

Definition at line 65 of file ReflectableUtil.h.

◆ getValue() [2/4]

template<typename T , typename ALLOC = std::allocator<uint8_t>, typename std::enable_if<!detail::gets_value_by_value< T >::value, int >::type = 0>
static const T& zserio::ReflectableUtil::getValue ( const IBasicReflectableDataConstPtr< ALLOC > &  reflectable,
const ALLOC &  allocator = ALLOC() 
)
inlinestatic

Gets constant reference to the native value from the given constant reflectable.

Overload for types where the value is returned by const reference:

  • compound, bit buffers and arrays.
Parameters
reflectableConstant reflectable to use for value extraction.
Returns
Constant reference to the value of the type T.
Exceptions
CppRuntimeExceptionWhen wrong type is requested ("Bad type in AnyHolder").

Definition at line 85 of file ReflectableUtil.h.

◆ getValue() [3/4]

template<typename T , typename ALLOC = std::allocator<uint8_t>, typename std::enable_if<!detail::gets_value_by_value< T >::value &&!std::is_same< BasicBitBuffer< ALLOC >, T >::value, int >::type = 0>
static T& zserio::ReflectableUtil::getValue ( const IBasicReflectableDataPtr< ALLOC > &  reflectable,
const ALLOC &  allocator = ALLOC() 
)
inlinestatic

Gets reference to the native value from the given reflectable.

Overload for types where the value is returned by reference:

  • compound, arrays.
Parameters
reflectableReflectable to use for value extraction.
Returns
Reference to the value of the type T.
Exceptions
CppRuntimeExceptionWhen wrong type is requested ("Bad type in AnyHolder").

Definition at line 108 of file ReflectableUtil.h.

◆ getValue() [4/4]

template<typename T , typename ALLOC = std::allocator<uint8_t>, typename std::enable_if< std::is_same< BasicBitBuffer< ALLOC >, T >::value, int >::type = 0>
static const T& zserio::ReflectableUtil::getValue ( const IBasicReflectableDataPtr< ALLOC > &  reflectable,
const ALLOC &  allocator = ALLOC() 
)
inlinestatic

Gets constant reference to the native value from the given reflectable.

Overload for bit buffers which are currently returned only by constant reference.

Parameters
reflectableReflectable to use for value extraction.
Returns
Constant reference to the bit buffer value.
Exceptions
CppRuntimeExceptionWhen wrong type is requested ("Bad type in BasicAny").

Definition at line 126 of file ReflectableUtil.h.


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