Serialbox  2.2.0
Data serialization library and tools for C/C++, Python and Fortran
serialbox::MetainfoValueImpl Class Reference

Represent an immutable meta information value as a type-id and type-erased data. More...

#include <MetainfoValueImpl.h>

Public Member Functions

 MetainfoValueImpl ()
 Default constructor.
 
 MetainfoValueImpl (const MetainfoValueImpl &)=default
 Copy constructor.
 
 MetainfoValueImpl (MetainfoValueImpl &&)=default
 Move constructor.
 
MetainfoValueImploperator= (const MetainfoValueImpl &)=default
 Copy assignment.
 
MetainfoValueImploperator= (MetainfoValueImpl &&)=default
 Move assignment.
 
template<class ValueType , class DecayedValueType = typename std::decay<ValueType>::type, class PrimitiveType = typename MakePrimitive<DecayedValueType>::type, class = typename std::enable_if< !std::is_same<DecayedValueType, MetainfoValueImpl>::value>::type>
 MetainfoValueImpl (ValueType &&value)
 Construct with given value. More...
 
 MetainfoValueImpl (const char *value)
 
template<class T >
as () const
 Convert the value to type T More...
 
template<class T >
 operator T () const
 Implicitly convert value to type T More...
 
void swap (MetainfoValueImpl &other) noexcept
 Swap with other.
 
bool operator== (const MetainfoValueImpl &right) const noexcept
 Test for equality.
 
bool operator!= (const MetainfoValueImpl &right) const noexcept
 Test for inequality.
 
TypeID type () const noexcept
 Get TypeID.
 
boost::any & any () noexcept
 Get boost::any.
 
const boost::any & any () const noexcept
 
std::string toString () const
 Convert to string.
 
template<>
bool as () const
 
template<>
int as () const
 
template<>
std::int64_t as () const
 
template<>
float as () const
 
template<>
double as () const
 
template<>
std::string as () const
 
template<>
Array< bool > as () const
 
template<>
Array< int > as () const
 
template<>
Array< std::int64_t > as () const
 
template<>
Array< float > as () const
 
template<>
Array< double > as () const
 
template<>
Array< std::string > as () const
 

Detailed Description

Represent an immutable meta information value as a type-id and type-erased data.

The MetainfoValueImpl can be implicitly casted to the supported types.

Definition at line 33 of file MetainfoValueImpl.h.

Constructor & Destructor Documentation

◆ MetainfoValueImpl()

template<class ValueType , class DecayedValueType = typename std::decay<ValueType>::type, class PrimitiveType = typename MakePrimitive<DecayedValueType>::type, class = typename std::enable_if< !std::is_same<DecayedValueType, MetainfoValueImpl>::value>::type>
serialbox::MetainfoValueImpl::MetainfoValueImpl ( ValueType &&  value)
inlineexplicit

Construct with given value.

Template Parameters
ValueTypeType of the captured value (needs to be supported)
Parameters
valueValue to capture

Definition at line 58 of file MetainfoValueImpl.h.

Member Function Documentation

◆ as()

template<class T >
T serialbox::MetainfoValueImpl::as ( ) const
inline

Convert the value to type T

If the type T is different than the internally stored type, the function does its best to convert the value to T in a meaningful way.

Returns
Copy of the value of the element as type T
Exceptions
ExceptionConversion error: Conversion would result in truncation of the value or conversions from primitive to array type

Definition at line 76 of file MetainfoValueImpl.h.

◆ operator T()

template<class T >
serialbox::MetainfoValueImpl::operator T ( ) const
inline

Implicitly convert value to type T

See also
MetainfoValueImpl::as

Definition at line 86 of file MetainfoValueImpl.h.


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