Class Avogadro::Core::Variant#

class Avogadro::Core::Variant#

The Variant class represents a union of data values.

Variant objects allow for the storage of and conversion between a variety of different data types.

Public Types

enum Type#

Values:

enumerator Null#
enumerator Bool#
enumerator Int#
enumerator Long#
enumerator Float#
enumerator Double#
enumerator Pointer#
enumerator String#
enumerator Matrix#

Public Functions

inline Variant()#

Creates a null variant.

template<typename T>
inline Variant(T value)#

Creates a variant to store value.

inline Variant(const Variant &variant)#

Creates a new copy of variant.

inline ~Variant()#

Destroys the variant object.

inline Type type() const#

Returns variant’s type.

inline bool isNull() const#

Returns true if the variant is null.

template<typename T>
inline bool setValue(T value)#

Sets the value of the variant to value.

template<typename T>
inline T value() const#

Returns the value of the variant in the type given by T.

inline void clear()#

Clears the variant’s data and sets the variant to null.

inline bool toBool() const#

Returns the value of the variant as a bool.

inline char toChar() const#

Returns the value of the variant as a char.

inline unsigned char toUChar() const#

Returns the value of the variant as an unsigned char.

inline short toShort() const#

Returns the value of the variant as a short.

inline unsigned short toUShort() const#

Returns the value of the variant as an unsigned short.

inline int toInt() const#

Returns the value of the variant as an int.

inline unsigned int toUInt() const#

Returns the value of the variant as an unsigned int.

inline long toLong() const#

Returns the value of the variant as a long.

inline unsigned long toULong() const#

Returns the value of the variant as an unsigned long.

inline float toFloat() const#

Returns the value of the variant as a float.

inline double toDouble() const#

Returns the value of the variant as a double.

inline Real toReal() const#

Returns the value of the variant as a Real.

inline void *toPointer() const#

Returns the value of the variant as a pointer.

inline std::string toString() const#

Returns the value of the variant as a string.

inline MatrixX toMatrix() const#

Returns the value of the variant as a MatrixX.

inline const MatrixX &toMatrixRef() const#

Returns a reference to the value of the variant as a MatrixX. This method will not perform any casting &#8212; if type() is not exactly MatrixX, the function will fail and return a reference to an empty MatrixX.

inline Variant &operator=(const Variant &variant)#
template<>
inline bool setValue(bool v)#
template<>
inline bool setValue(char v)#
template<>
inline bool setValue(short v)#
template<>
inline bool setValue(int v)#
template<>
inline bool setValue(long v)#
template<>
inline bool setValue(float v)#
template<>
inline bool setValue(double v)#
template<>
inline bool setValue(std::string string)#
template<>
inline bool setValue(const char *string)#
template<>
inline bool setValue(void *pointer)#
template<>
inline bool setValue(MatrixX matrix)#
template<>
inline bool value() const#

Public Members

bool _bool#
char _char#
int _int#
long _long#
float _float#
double _double#
void *pointer#
std::string *string#
MatrixX *matrix#