AvogadroLibs 1.98.1
|
The Variant class represents a union of data values. More...
#include <avogadro/core/variant.h>
Public Types | |
enum | Type { Null , Bool , Int , Long , Float , Double , Pointer , String , Matrix } |
Public Member Functions | |
Variant () | |
template<typename T > | |
Variant (T value) | |
Variant (const Variant &variant) | |
~Variant () | |
Type | type () const |
bool | isNull () const |
template<typename T > | |
bool | setValue (T value) |
template<typename T > | |
T | value () const |
void | clear () |
bool | toBool () const |
char | toChar () const |
unsigned char | toUChar () const |
short | toShort () const |
unsigned short | toUShort () const |
int | toInt () const |
unsigned int | toUInt () const |
long | toLong () const |
unsigned long | toULong () const |
float | toFloat () const |
double | toDouble () const |
Real | toReal () const |
void * | toPointer () const |
std::string | toString () const |
MatrixX | toMatrix () const |
const MatrixX & | toMatrixRef () const |
Variant & | operator= (const Variant &variant) |
template<> | |
bool | setValue (bool v) |
template<> | |
bool | setValue (char v) |
template<> | |
bool | setValue (short v) |
template<> | |
bool | setValue (int v) |
template<> | |
bool | setValue (long v) |
template<> | |
bool | setValue (float v) |
template<> | |
bool | setValue (double v) |
template<> | |
bool | setValue (std::string string) |
template<> | |
bool | setValue (const char *string) |
template<> | |
bool | setValue (void *pointer) |
template<> | |
bool | setValue (MatrixX matrix) |
template<> | |
bool | value () const |
template<> | |
char | value () const |
template<> | |
short | value () const |
template<> | |
int | value () const |
template<> | |
long | value () const |
template<> | |
float | value () const |
template<> | |
double | value () const |
template<> | |
void * | value () const |
template<> | |
std::string | value () const |
template<> | |
MatrixX | value () const |
template<> | |
const MatrixX & | value () const |
Variant objects allow for the storage of and conversion between a variety of different data types.
Variant | ( | ) |
Creates a null variant.
Variant | ( | T | value | ) |
Creates a variant to store value
.
~Variant | ( | ) |
Destroys the variant object.
Variant::Type type | ( | ) | const |
Returns variant's type.
bool isNull | ( | ) | const |
Returns true
if the variant is null.
bool setValue | ( | T | value | ) |
Sets the value of the variant to value
.
T value | ( | ) | const |
Returns the value of the variant in the type given by T
.
void clear | ( | ) |
Clears the variant's data and sets the variant to null.
bool toBool | ( | ) | const |
Returns the value of the variant as a bool
.
char toChar | ( | ) | const |
Returns the value of the variant as a char
.
unsigned char toUChar | ( | ) | const |
Returns the value of the variant as an unsigned
char
.
short toShort | ( | ) | const |
Returns the value of the variant as a short
.
unsigned short toUShort | ( | ) | const |
Returns the value of the variant as an unsigned
short
.
int toInt | ( | ) | const |
Returns the value of the variant as an int
.
unsigned int toUInt | ( | ) | const |
Returns the value of the variant as an unsigned
int
.
long toLong | ( | ) | const |
Returns the value of the variant as a long
.
unsigned long toULong | ( | ) | const |
Returns the value of the variant as an unsigned
long
.
float toFloat | ( | ) | const |
Returns the value of the variant as a float
.
double toDouble | ( | ) | const |
Returns the value of the variant as a double
.
Real toReal | ( | ) | const |
Returns the value of the variant as a Real
.
void * toPointer | ( | ) | const |
Returns the value of the variant as a pointer.
std::string toString | ( | ) | const |
Returns the value of the variant as a string.
MatrixX toMatrix | ( | ) | const |
Returns the value of the variant as a MatrixX.
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.