Avogadro::Core::Variant#
-
class 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
Public Functions
-
inline Variant()#
Creates a null variant.
-
inline Variant(double x, double y, double z)#
Creates a variant to store a 3D vector
-
inline ~Variant()#
Destroys the variant object.
-
inline bool isNull() const#
- Returns:
true
if the variant is null.
-
inline bool setValue(double x, double y, double z)#
Sets the value of the variant to a 3D vector
-
inline bool setValue(const std::vector<double> &v)#
Sets the value of the variant to a vector<double>
-
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 Vector3 toVector3() const#
- Returns:
the value of the variant as a Vector3
-
inline std::vector<double> toList() const#
- Returns:
the value as a vector<double>
-
inline const MatrixX &toMatrixRef() const#
- Returns:
a reference to the value of the variant as a MatrixX. This method will not perform any casting — if type() is not exactly MatrixX, the function will fail and return a reference to an empty MatrixX.
-
template<>
inline Variant(const char *v)#
-
template<>
inline Variant(const MatrixXf &v)#
-
template<>
inline Variant(const Vector3 &v)#
-
template<>
inline Variant(const Vector3f &v)#
-
template<>
inline Variant(const std::vector<double> &v)#
-
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 setValue(Vector3 vector)#
-
template<>
inline bool setValue(Vector3f vector)#
-
template<>
inline bool value() const#
-
inline Variant()#