Class Variant

Nested Relationships

Class Documentation

class Variant

storage container for data types as e.g. int, float, string, etc.

Allows storage of multiple data types in one base class. used to construct a map of `arbitrarry’ data types.

Public Types

enum Type

Values:

TYPE_NONE = 0
TYPE_BOOL
TYPE_CHAR
TYPE_UCHAR
TYPE_INT16
TYPE_UINT16
TYPE_INT32
TYPE_UINT32
TYPE_INT64
TYPE_UINT64
TYPE_FLOAT
TYPE_DOUBLE
TYPE_STRING

Public Functions

Variant()
~Variant()
Variant(const Variant &a)
const std::type_info &getTypeInfo() const
const char *getTypeName() const
size_t copyToBuffer(void *buffer)
size_t getSize() const

returns size of used data type in bytes

template <class T>
T to() const
Type getType() const
bool operator==(const Variant &a) const
bool operator!=(const Variant &a) const
Variant &operator=(const Variant &a)
bool isValid()
VARIANT_ADD_TYPE_DECL_POD(Bool, TYPE_BOOL, bool)
char VARIANT_ADD_TYPE_DECL_POD(UChar, TYPE_UCHAR, unsigned char)
char int16_t VARIANT_ADD_TYPE_DECL_POD(UInt16, TYPE_UINT16, uint16_t)
char int16_t int32_t VARIANT_ADD_TYPE_DECL_POD(UInt32, TYPE_UINT32, uint32_t)
char int16_t int32_t int64_t VARIANT_ADD_TYPE_DECL_POD(UInt64, TYPE_UINT64, uint64_t)
char int16_t int32_t int64_t float VARIANT_ADD_TYPE_DECL_POD(Double, TYPE_DOUBLE, double)
Variant(const char *s)
std::string toString() const
operator std::string() const
bool operator!=(const char *a) const
void clear()

Public Members

TYPE_CHAR
char TYPE_INT16
char int16_t TYPE_INT32
char int16_t int32_t TYPE_INT64
char int16_t int32_t int64_t TYPE_FLOAT
char int16_t int32_t int64_t float TYPE_STRING
bool _Bool
char _Char
unsigned char _UChar
int16_t _Int16
uint16_t _UInt16
int32_t _Int32
uint32_t _UInt32
int64_t _Int64
uint64_t _UInt64
double _Double
float _Float
std::string *_String

Public Static Functions

Variant::Type toType(const std::string &name)
const char *getTypeName(Type type)
Variant fromString(const std::string &str, Type type)

Protected Attributes

Type type
union crpropa::Variant::@3 data
class bad_conversion : public exception

Public Functions

const char *what() const
bad_conversion(Type f, Type t)
~bad_conversion()