Zserio C++ runtime library  1.2.0
Built for Zserio 2.16.0
zserio::ReflectableUtil Class Reference

#include <ReflectableUtil.h>

Static Public Member Functions

template<typename ALLOC = std::allocator<uint8_t>>
static bool equal (const IBasicReflectableConstPtr< ALLOC > &lhs, const IBasicReflectableConstPtr< 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 IBasicReflectableConstPtr< 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 IBasicReflectableConstPtr< 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 IBasicReflectablePtr< 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 IBasicReflectablePtr< ALLOC > &reflectable, const ALLOC &allocator=ALLOC())
 

Detailed Description

Utilities on zserio reflectable interface.

Definition at line 34 of file ReflectableUtil.h.

Member Function Documentation

◆ equal()

template<typename ALLOC >
bool zserio::ReflectableUtil::equal ( const IBasicReflectableConstPtr< ALLOC > &  lhs,
const IBasicReflectableConstPtr< 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 146 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 IBasicReflectableConstPtr< 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 63 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 IBasicReflectableConstPtr< 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 83 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 IBasicReflectablePtr< 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 106 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 IBasicReflectablePtr< 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 AnyHolder").

Definition at line 124 of file ReflectableUtil.h.


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