Class Variant

Nested Relationships

Nested Types

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 arbitrary data types. Note that most default C++ types allow default conversions from Variant to the corresponding type. Types that require an explicit call via toTargetType() are: complex (float and double), Vector3, and vector<Variant>.

Public Types

enum Type

Values:

enumerator TYPE_NONE
enumerator TYPE_BOOL
enumerator TYPE_CHAR
enumerator TYPE_UCHAR
enumerator TYPE_INT16
enumerator TYPE_UINT16
enumerator TYPE_INT32
enumerator TYPE_UINT32
enumerator TYPE_INT64
enumerator TYPE_UINT64
enumerator TYPE_FLOAT
enumerator TYPE_DOUBLE
enumerator TYPE_LONGDOUBLE
enumerator TYPE_COMPLEXF
enumerator TYPE_COMPLEXD
enumerator TYPE_STRING
enumerator TYPE_VECTOR3F
enumerator TYPE_VECTOR3D
enumerator TYPE_VECTOR3C
enumerator TYPE_VECTOR
typedef std::complex<float> complex_f
typedef std::complex<double> complex_d
typedef Vector3<std::complex<double>> Vector3c
typedef std::vector<Variant> vector_t

Public Functions

Variant()
Variant(Type t)
Variant(const Variant &v)
Variant(const char *s)
~Variant()
inline Type getType() const
const char *getTypeName() const
const std::type_info &getTypeInfo() const
std::string toString(const std::string &delimiter = "\t") const
std::complex<float> toComplexFloat() const
std::complex<double> toComplexDouble() const
Vector3f toVector3f() const
Vector3d toVector3d() const
Vector3c toVector3c() const
vector_t toVector() const
void clear(Type t = TYPE_NONE)
bool isValid() const
size_t size() const
size_t getSizeOf() const
size_t getSize() const
void resize(size_t i)
size_t copyToBuffer(void *buffer)
inline operator std::string() const
Variant &operator=(const Variant &v)
bool operator==(const Variant &v) const
bool operator!=(const Variant &v) const
bool operator!=(const char *a) const
Variant &operator[](size_t i)
inline Variant &operator[](int i)
const Variant &operator[](size_t i) const
inline const Variant &operator[](int i) const
operator vector_t&()
operator const vector_t&() const
template<class T>
inline T to() const
VARIANT_ADD_TYPE_DECL_POD (Bool, TYPE_BOOL, bool, bool) VARIANT_ADD_TYPE_DECL_POD(Char
char VARIANT_ADD_TYPE_DECL_POD (UChar, TYPE_UCHAR, unsigned char, uchar) VARIANT_ADD_TYPE_DECL_POD(Int16
char int16 VARIANT_ADD_TYPE_DECL_POD (UInt16, TYPE_UINT16, uint16_t, uint16) VARIANT_ADD_TYPE_DECL_POD(Int32
char int16 int32 VARIANT_ADD_TYPE_DECL_POD (UInt32, TYPE_UINT32, uint32_t, uint32) VARIANT_ADD_TYPE_DECL_POD(Int64
char int16 int32 int64 VARIANT_ADD_TYPE_DECL_POD (UInt64, TYPE_UINT64, uint64_t, uint64) VARIANT_ADD_TYPE_DECL_POD(Float
char int16 int32 int64 float VARIANT_ADD_TYPE_DECL_POD (Double, TYPE_DOUBLE, double, double) VARIANT_ADD_TYPE_DECL_POD(LongDouble
char int16 int32 int64 float long ldouble VARIANT_ADD_TYPE_DECL_PTR (ComplexFloat, TYPE_COMPLEXF, std::complex< float >, complex_f) VARIANT_ADD_TYPE_DECL_PTR(ComplexDouble
char int16 int32 int64 float long ldouble complex_d VARIANT_ADD_TYPE_DECL_PTR (String, TYPE_STRING, std::string, string) VARIANT_ADD_TYPE_DECL_PTR(Vector3f
char int16 int32 int64 float long ldouble complex_d vector3f VARIANT_ADD_TYPE_DECL_PTR (Vector3d, TYPE_VECTOR3D, Vector3d, vector3d) VARIANT_ADD_TYPE_DECL_PTR(Vector3c
char int16 int32 int64 float long ldouble complex_d vector3f vector3c VARIANT_ADD_TYPE_DECL_PTR (Vector, TYPE_VECTOR, vector_t, vector) VARIANT_ADD_ITER_DECL_PTR(Vector

Public Members

bool _t_bool
char _t_char
unsigned char _t_uchar
int16_t _t_int16
uint16_t _t_uint16
int32_t _t_int32
uint32_t _t_uint32
int64_t _t_int64
uint64_t _t_uint64
float _t_float
double _t_double
long double _t_ldouble
complex_f *_t_complex_f
complex_d *_t_complex_d
std::string *_t_string
Vector3f *_t_vector3f
Vector3d *_t_vector3d
Vector3c *_t_vector3c
vector_t *_t_vector
TYPE_CHAR
char
char TYPE_INT16
char int16_t
char int16 TYPE_INT32
char int16 int32_t
char int16 int32 TYPE_INT64
char int16 int32 int64_t
char int16 int32 int64 TYPE_FLOAT
char int16 int32 int64 float
char int16 int32 int64 float TYPE_LONGDOUBLE
char int16 int32 int64 float long double
char int16 int32 int64 float long ldouble TYPE_COMPLEXD
char int16 int32 int64 float long ldouble complex_d TYPE_VECTOR3F
char int16 int32 int64 float long ldouble complex_d Vector3f
char int16 int32 int64 float long ldouble complex_d vector3f TYPE_VECTOR3C
char int16 int32 int64 float long ldouble complex_d vector3f Vector3c
char int16 int32 int64 float long ldouble complex_d vector3f vector3c TYPE_VECTOR

Public Static Functions

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

Protected Attributes

Type type
union crpropa::Variant::[anonymous] data
class bad_conversion : public exception

Public Functions

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

Protected Attributes

std::string msg