Classes | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
variant_topic_tools::Variant Class Reference

Variant type. More...

#include <Variant.h>

Inheritance diagram for variant_topic_tools::Variant:
Inheritance graph
[legend]

Classes

class  Value
 Variant value (abstract base) More...
 
class  ValueT
 Variant value (templated abstract base) More...
 

Public Member Functions

ArrayVariant asArray () const
 Retrieve this variant as array. More...
 
BuiltinVariant asBuiltin () const
 Retrieve this variant as builtin. More...
 
CollectionVariant asCollection () const
 Retrieve this variant as collection. More...
 
MessageVariant asMessage () const
 Retrieve this variant as message. More...
 
void clear ()
 Clear the variant. More...
 
Serializer createSerializer () const
 Create a serializer for this variant. More...
 
const DataTypegetType () const
 Retrieve the data type of this variant. More...
 
template<typename T >
type_traits::DataType< T >::ValueType & getValue ()
 Retrieve the variant's value (non-const version) More...
 
template<typename T >
const type_traits::DataType< T >::ValueType & getValue () const
 Retrieve the variant's value (const version) More...
 
const std::type_info & getValueTypeInfo () const
 Retrieve the value type information of this variant. More...
 
bool hasType () const
 True, if the variant has a type. More...
 
bool isArray () const
 True, if this variant represents an array. More...
 
bool isBuiltin () const
 True, if this variant represents a built-in. More...
 
bool isCollection () const
 True, if this variant represents a collection. More...
 
bool isEmpty () const
 True, if the variant is empty, i.e., does not have a value assigned. More...
 
bool isMessage () const
 True, if this variant represents a message. More...
 
template<typename T >
 operator T () const
 Conversion operator. More...
 
template<typename T >
bool operator!= (const T &value) const
 True, if this variant's value does not equal another value. More...
 
template<typename T >
Variantoperator= (const T &src)
 Assignment operator. More...
 
template<typename T >
bool operator== (const T &value) const
 True, if this variant's value equals another value. More...
 
void read (std::istream &stream)
 Read the variant from a stream. More...
 
template<typename T >
void setValue (const T &value)
 Set the variant's value. More...
 
 Variant ()
 Default constructor. More...
 
template<typename T >
 Variant (const T &src)
 Copy constructor. More...
 
void write (std::ostream &stream) const
 Write the variant to a stream. More...
 
 ~Variant ()
 Destructor. More...
 

Protected Types

typedef boost::shared_ptr< ValueValuePtr
 Declaration of the variant value pointer type. More...
 
typedef boost::weak_ptr< ValueValueWPtr
 Declaration of the variant value weak pointer type. More...
 

Protected Member Functions

 Variant (const DataType &type)
 Constructor (overloaded version taking a data type) More...
 

Static Protected Member Functions

template<typename T >
static void assign (Variant &dst, const T &src, typename boost::enable_if< boost::is_base_of< Variant, T > >::type *=0)
 Assign a variant (overloaded version taking a variant) More...
 
template<typename T >
static void assign (Variant &dst, const T &src, typename boost::disable_if< boost::is_base_of< Variant, T > >::type *=0)
 Assign a variant (overloaded version taking a variant value) More...
 
template<typename T >
static bool isEqual (const Variant &variant, const T &value, typename boost::enable_if< boost::is_base_of< Variant, T > >::type *=0)
 True, if a variant's value equals another value (overloaded version taking a variant) More...
 
template<typename T >
static bool isEqual (const Variant &variant, const T &value, typename boost::disable_if< boost::is_base_of< Variant, T > >::type *=0)
 True, if a variant's value equals another value (overloaded version taking a variant value) More...
 
template<typename T >
static void set (Variant &variant, const Pointer< typename type_traits::DataType< T >::ValueType > &value)
 Set a variant's value pointer. More...
 
template<typename T >
static void setValue (Variant &dst, const T &value, typename boost::enable_if< boost::is_base_of< Variant, T > >::type *=0)
 Set a variant's value (overloaded version taking a variant) More...
 
template<typename T >
static void setValue (Variant &dst, const T &value, typename boost::disable_if< boost::is_base_of< Variant, T > >::type *=0)
 Set a variant's value (overloaded version taking a variant value) More...
 

Protected Attributes

DataType type
 The variant's data type. More...
 
ValuePtr value
 The variant's data value. More...
 

Friends

class MessageVariable
 

Detailed Description

Variant type.

Definition at line 39 of file Variant.h.

Member Typedef Documentation

Declaration of the variant value pointer type.

Definition at line 155 of file Variant.h.

typedef boost::weak_ptr<Value> variant_topic_tools::Variant::ValueWPtr
protected

Declaration of the variant value weak pointer type.

Definition at line 163 of file Variant.h.

Constructor & Destructor Documentation

variant_topic_tools::Variant::Variant ( )

Default constructor.

Definition at line 32 of file Variant.cpp.

template<typename T >
variant_topic_tools::Variant::Variant ( const T &  src)

Copy constructor.

variant_topic_tools::Variant::~Variant ( )

Destructor.

Definition at line 39 of file Variant.cpp.

variant_topic_tools::Variant::Variant ( const DataType type)
protected

Constructor (overloaded version taking a data type)

Definition at line 35 of file Variant.cpp.

Member Function Documentation

ArrayVariant variant_topic_tools::Variant::asArray ( ) const

Retrieve this variant as array.

Definition at line 107 of file Variant.cpp.

BuiltinVariant variant_topic_tools::Variant::asBuiltin ( ) const

Retrieve this variant as builtin.

Definition at line 111 of file Variant.cpp.

CollectionVariant variant_topic_tools::Variant::asCollection ( ) const

Retrieve this variant as collection.

Definition at line 115 of file Variant.cpp.

MessageVariant variant_topic_tools::Variant::asMessage ( ) const

Retrieve this variant as message.

Definition at line 119 of file Variant.cpp.

template<typename T >
static void variant_topic_tools::Variant::assign ( Variant dst,
const T &  src,
typename boost::enable_if< boost::is_base_of< Variant, T > >::type = 0 
)
staticprotected

Assign a variant (overloaded version taking a variant)

template<typename T >
static void variant_topic_tools::Variant::assign ( Variant dst,
const T &  src,
typename boost::disable_if< boost::is_base_of< Variant, T > >::type = 0 
)
staticprotected

Assign a variant (overloaded version taking a variant value)

void variant_topic_tools::Variant::clear ( )

Clear the variant.

Definition at line 123 of file Variant.cpp.

Serializer variant_topic_tools::Variant::createSerializer ( ) const

Create a serializer for this variant.

Definition at line 138 of file Variant.cpp.

const DataType & variant_topic_tools::Variant::getType ( ) const

Retrieve the data type of this variant.

Definition at line 52 of file Variant.cpp.

template<typename T >
type_traits::DataType<T>::ValueType& variant_topic_tools::Variant::getValue ( )

Retrieve the variant's value (non-const version)

template<typename T >
const type_traits::DataType<T>::ValueType& variant_topic_tools::Variant::getValue ( ) const

Retrieve the variant's value (const version)

const std::type_info & variant_topic_tools::Variant::getValueTypeInfo ( ) const

Retrieve the value type information of this variant.

Note
The value type information can be different from the type information associated with this variant's data type.

Definition at line 56 of file Variant.cpp.

bool variant_topic_tools::Variant::hasType ( ) const

True, if the variant has a type.

Definition at line 63 of file Variant.cpp.

bool variant_topic_tools::Variant::isArray ( ) const

True, if this variant represents an array.

Definition at line 67 of file Variant.cpp.

bool variant_topic_tools::Variant::isBuiltin ( ) const

True, if this variant represents a built-in.

Definition at line 74 of file Variant.cpp.

bool variant_topic_tools::Variant::isCollection ( ) const

True, if this variant represents a collection.

Definition at line 81 of file Variant.cpp.

bool variant_topic_tools::Variant::isEmpty ( ) const

True, if the variant is empty, i.e., does not have a value assigned.

Definition at line 95 of file Variant.cpp.

template<typename T >
static bool variant_topic_tools::Variant::isEqual ( const Variant variant,
const T &  value,
typename boost::enable_if< boost::is_base_of< Variant, T > >::type = 0 
)
staticprotected

True, if a variant's value equals another value (overloaded version taking a variant)

template<typename T >
static bool variant_topic_tools::Variant::isEqual ( const Variant variant,
const T &  value,
typename boost::disable_if< boost::is_base_of< Variant, T > >::type = 0 
)
staticprotected

True, if a variant's value equals another value (overloaded version taking a variant value)

bool variant_topic_tools::Variant::isMessage ( ) const

True, if this variant represents a message.

Definition at line 88 of file Variant.cpp.

template<typename T >
variant_topic_tools::Variant::operator T ( ) const

Conversion operator.

template<typename T >
bool variant_topic_tools::Variant::operator!= ( const T &  value) const

True, if this variant's value does not equal another value.

template<typename T >
Variant& variant_topic_tools::Variant::operator= ( const T &  src)

Assignment operator.

template<typename T >
bool variant_topic_tools::Variant::operator== ( const T &  value) const

True, if this variant's value equals another value.

void variant_topic_tools::Variant::read ( std::istream &  stream)

Read the variant from a stream.

Definition at line 128 of file Variant.cpp.

template<typename T >
static void variant_topic_tools::Variant::set ( Variant variant,
const Pointer< typename type_traits::DataType< T >::ValueType > &  value 
)
staticprotected

Set a variant's value pointer.

template<typename T >
void variant_topic_tools::Variant::setValue ( const T &  value)

Set the variant's value.

template<typename T >
static void variant_topic_tools::Variant::setValue ( Variant dst,
const T &  value,
typename boost::enable_if< boost::is_base_of< Variant, T > >::type = 0 
)
staticprotected

Set a variant's value (overloaded version taking a variant)

template<typename T >
static void variant_topic_tools::Variant::setValue ( Variant dst,
const T &  value,
typename boost::disable_if< boost::is_base_of< Variant, T > >::type = 0 
)
staticprotected

Set a variant's value (overloaded version taking a variant value)

void variant_topic_tools::Variant::write ( std::ostream &  stream) const

Write the variant to a stream.

Definition at line 133 of file Variant.cpp.

Friends And Related Function Documentation

friend class MessageVariable
friend

Definition at line 40 of file Variant.h.

Member Data Documentation

DataType variant_topic_tools::Variant::type
protected

The variant's data type.

Definition at line 247 of file Variant.h.

ValuePtr variant_topic_tools::Variant::value
protected

The variant's data value.

Definition at line 251 of file Variant.h.


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


variant_topic_tools
Author(s): Ralf Kaestner
autogenerated on Sat Jan 9 2021 03:56:50