#include <Variant.h++>

Public Types | |
| enum | Type { TypeNull = 0, TypeBool, TypeChar, TypeWChar, TypeInt, TypeUInt, TypeFloat, TypeDouble, TypeInt64, TypeUInt64, TypeString, TypeWString, TypeBlob, TypeOpaque, TypeList, TypeMap } |
| Variant value types. More... | |
Public Member Functions | |
| Variant () | |
| Construct a new Variant with a null type. | |
| Variant (const Variant &other) | |
| Copy constructor. | |
| Variant (bool val) | |
| Construct a new bool variant. | |
| Variant (char val) | |
| Construct a new char variant. | |
| Variant (wchar_t val) | |
| Construct a new wchar_t variant. | |
| Variant (int32_t val) | |
| Construct a new int32_t variant. | |
| Variant (uint32_t val) | |
| Construct a new uint32_t variant. | |
| Variant (float val) | |
| Construct a new float variant. | |
| Variant (const double &val) | |
| Construct a new double variant. | |
| Variant (const int64_t &val) | |
| Construct a new int64_t variant. | |
| Variant (const uint64_t &val) | |
| Construct a new uint64_t variant. | |
| Variant (const String &val) | |
| Construct a new String variant. | |
| Variant (const WString &val) | |
| Construct a new WString variant. | |
| Variant (const char *val) | |
| Construct a new string variant. | |
| Variant (const wchar_t *val) | |
| Construct a new wide string variant. | |
| Variant (const Blob &val) | |
| Construct a new Blob variant. | |
| Variant (void *val) | |
| Construct a new opaque pointer value variant. | |
| virtual | ~Variant () |
| Destructor. | |
| Type | getType () const |
| Get the type of this Variant. | |
| void | setType (Type type) |
| Set the type of this variant. | |
| bool | isNull () const |
| Test if the Variant is null. | |
| bool | isBool () const |
| Test if the Variant's value is a bool. | |
| bool | isChar () const |
| Test if the Variant's value is a char. | |
| bool | isWChar () const |
| Test if the Variant's value is a wchar_t. | |
| bool | isInt () const |
| Test if the Variant's value is an int32_t. | |
| bool | isUInt () const |
| Test if the Variant's value is a uint32_t. | |
| bool | isFloat () const |
| Test if the Variant's value is a float. | |
| bool | isDouble () const |
| Test if the Variant's value is a double. | |
| bool | isInt64 () const |
| Test if the Variant's value is an int64_t. | |
| bool | isUInt64 () const |
| Test if the Variant's value is a uint64_t. | |
| bool | isString () const |
| Test if the Variant's value is a String. | |
| bool | isWString () const |
| Test if the Variant's value is a WString. | |
| bool | isBlob () const |
| Test if the Variant's value is a Blob. | |
| bool | isOpaque () const |
| Test if the Variant's value is opaque. | |
| bool | isList () const |
| Test if the Variant's value is a list. | |
| bool | isMap () const |
| Test if the Variant's value is a map. | |
| bool | toBool () const |
Return the Variant's value as a bool, converting it if necessary, or return false if a conversion is not possible or not meaningful. | |
| char | toChar () const |
Return the Variant's value as a char, converting it if necessary, or return '\0' if a conversion is not possible or not meaningful. | |
| wchar_t | toWChar () const |
Return the Variant's value as a wchar_t, converting it if necessary, or return L'\0' if a conversion is not possible or not meaningful. | |
| int32_t | toInt () const |
Return the Variant's value as an int32_t, converting it if necessary, or return 0 if a conversion is not possible or not meaningful. | |
| uint32_t | toUInt () const |
Return the Variant's value as a uint32_t, converting it if necessary, or return 0 if a conversion is not possible or not meaningful. | |
| float | toFloat () const |
Return the Variant's value as a float, converting it if necessary, or return 0.0f if a conversion is not possible or not meaningful. | |
| double | toDouble () const |
Return the Variant's value as a double, converting it if necessary, or return 0.0 if a conversion is not possible or not meaningful. | |
| int64_t | toInt64 () const |
Return the Variant's value as an int64_t, converting it if necessary, or return 0 if a conversion is not possible or not meaningful. | |
| uint64_t | toUInt64 () const |
Return the Variant's value as a uint64_t, converting it if necessary, or return 0 if a conversion is not possible or not meaningful. | |
| void * | toOpaque () const |
Return the Variant's value as an opaque pointer, or NULL if the value is not an opaque. | |
| String | toString () const |
Return the Variant's value as a String, converting it if necessary, or return String::null if a conversion is not possible or not meaningful. | |
| WString | toWString () const |
Return the Variant's value as a WString, converting it if necessary, or return WString::null if a conversion is not possible or not meaningful. | |
| Blob | toBlob () const |
Return the Variant's value as a Blob, converting it if necessary, or return Blob::null if a conversion is not possible or not meaningful. | |
| operator bool () const | |
| Cast operator. | |
| operator char () const | |
| Cast operator. | |
| operator wchar_t () const | |
| Cast operator. | |
| operator int32_t () const | |
| Cast operator. | |
| operator uint32_t () const | |
| Cast operator. | |
| operator float () const | |
| Cast operator. | |
| operator double () const | |
| Cast operator. | |
| operator String () const | |
| Cast operator. | |
| operator WString () const | |
| Cast operator. | |
| operator Blob () const | |
| Cast operator. | |
| operator int64_t () const | |
| Cast operator. | |
| operator uint64_t () const | |
| Cast operator. | |
| operator const void * () const throw () | |
| Boolean evaluation cast operator. | |
| bool | operator! () const throw () |
| Equivalent to isNull(). | |
| size_t | length () const |
| Get the length of the value. | |
| void | clear () |
| Clear the Variant. | |
| void | setNull () |
| Set the value to null. | |
| Variant & | operator= (bool val) |
Assign a bool value to the Variant. | |
| Variant & | operator= (char val) |
Assign a char value to the Variant. | |
| Variant & | operator= (wchar_t val) |
Assign a wchar_t value to the Variant. | |
| Variant & | operator= (int32_t val) |
Assign an int32_t value to the Variant. | |
| Variant & | operator= (uint32_t val) |
Assign a uint32_t value to the Variant. | |
| Variant & | operator= (float val) |
Assign a float value to the Variant. | |
| Variant & | operator= (const double &val) |
Assign a double value to the Variant. | |
| Variant & | operator= (const int64_t &val) |
Assign an int64_t value to the Variant. | |
| Variant & | operator= (const uint64_t &val) |
Assign a uint64_t value to the Variant. | |
| Variant & | operator= (const String &val) |
| Assign a String value to the Variant. | |
| Variant & | operator= (const WString &val) |
| Assign a WString value to the Variant. | |
| Variant & | operator= (const char *val) |
| Assign a string value to the Variant. | |
| Variant & | operator= (const wchar_t *val) |
| Assign a wide string value to the Variant. | |
| Variant & | operator= (const Blob &val) |
| Assign a Blob value to the Variant. | |
| Variant & | operator= (void *val) |
| Assign an opaque pointer value to the Variant. | |
| Variant & | operator= (const Variant &other) |
| Assignment operator. | |
| Variant & | operator[] (const String &name) |
| Return the value for the given name from this Variant, whose value is assumed to be a map. | |
| Variant & | operator[] (const char *name) |
| Return the value for the given name from this Variant, whose value is assumed to be a map. | |
| const Variant & | get (const String &name) const |
| Return the value for the given name from this Variant, whose value is assumed to be a map. | |
| const Variant & | operator[] (const String &name) const |
| Return the value for the given name from this Variant, whose value is assumed to be a map. | |
| const Variant & | operator[] (const char *name) const |
| Return the value for the given name from this Variant, whose value is assumed to be a map. | |
| Variant & | operator[] (int index) throw (OutOfBoundsException) |
| Return the value at the given index from this Variant, whose value is assumed to be a list. | |
| const Variant & | get (int index) const throw (OutOfBoundsException) |
| Return the value at the given index from this Variant, whose value is assumed to be a list. | |
| const Variant & | operator[] (int index) const throw (OutOfBoundsException) |
| Return the value at the given index from this Variant, whose value is assumed to be a list. | |
| bool | getKeys (StringVec &vec) const |
| If this Variant is a map, stores a list of the map keys into the supplied vector and returns true. | |
| bool | hasKey (const String &key) const |
| If this Variant is a map, determines if the map contains the specified key. | |
| bool | operator== (const Variant &other) const |
| Equality operator. | |
| bool | operator!= (const Variant &other) const |
| Inequality operator. | |
| void | write (std::ostream &stream) const |
| Write the value of this Variant to a stream. | |
Static Public Attributes | |
| static const Variant | null |
| A null Variant. | |
Variant can hold a value of one of the following types: null, bool, char, wchar_t, int32_t, uint32_t, float, double, int64_t, uint64_t, String, WString, Blob, opaque, list, or map. The latter two allow for the construction of arbitrarily complex data structures composed of Variant objects.
| Variant | ( | bool | val | ) | [explicit] |
Construct a new bool variant.
| val | The initial value. |
| Variant | ( | char | val | ) | [explicit] |
Construct a new char variant.
| val | The initial value. |
| Variant | ( | wchar_t | val | ) | [explicit] |
Construct a new wchar_t variant.
| val | The initial value. |
| Variant | ( | int32_t | val | ) | [explicit] |
Construct a new int32_t variant.
| val | The initial value. |
| Variant | ( | uint32_t | val | ) | [explicit] |
Construct a new uint32_t variant.
| val | The initial value. |
| Variant | ( | float | val | ) | [explicit] |
Construct a new float variant.
| val | The initial value. |
| Variant | ( | const double & | val | ) | [explicit] |
Construct a new double variant.
| val | The initial value. |
| Variant | ( | const int64_t & | val | ) | [explicit] |
Construct a new int64_t variant.
| val | The initial value. |
| Variant | ( | const uint64_t & | val | ) | [explicit] |
Construct a new uint64_t variant.
| val | The initial value. |
Construct a new String variant.
| val | The initial value. |
Construct a new WString variant.
| val | The initial value. |
| Variant | ( | const char * | val | ) | [explicit] |
Construct a new string variant.
| val | The initial value. |
| Variant | ( | const wchar_t * | val | ) | [explicit] |
Construct a new wide string variant.
| val | The initial value. |
| Variant | ( | void * | val | ) | [explicit] |
Construct a new opaque pointer value variant.
| val | The initial value. |
| ~Variant | ( | ) | [virtual] |
Destructor.
| void clear | ( | ) |
Clear the Variant.
Sets the value to the default value for the current type.
| const Variant & get | ( | int | index | ) | const throw (OutOfBoundsException) |
Return the value at the given index from this Variant, whose value is assumed to be a list.
| index | The index. |
| OutOfBoundsException | If the index is negative. |
Return the value for the given name from this Variant, whose value is assumed to be a map.
| name | The name of the value. |
| bool getKeys | ( | StringVec & | vec | ) | const |
If this Variant is a map, stores a list of the map keys into the supplied vector and returns true.
Otherwise, returns false.
| vec | The vector in which to store the keys. |
| bool hasKey | ( | const String & | key | ) | const |
If this Variant is a map, determines if the map contains the specified key.
| key | The key to search for. |
| bool isBlob | ( | ) | const [inline] |
Test if the Variant's value is a Blob.
| bool isBool | ( | ) | const [inline] |
Test if the Variant's value is a bool.
| bool isChar | ( | ) | const [inline] |
Test if the Variant's value is a char.
| bool isDouble | ( | ) | const [inline] |
Test if the Variant's value is a double.
| bool isFloat | ( | ) | const [inline] |
Test if the Variant's value is a float.
| bool isInt | ( | ) | const [inline] |
Test if the Variant's value is an int32_t.
| bool isInt64 | ( | ) | const [inline] |
Test if the Variant's value is an int64_t.
| bool isList | ( | ) | const [inline] |
Test if the Variant's value is a list.
| bool isMap | ( | ) | const [inline] |
Test if the Variant's value is a map.
| bool isNull | ( | ) | const [inline] |
Test if the Variant is null.
| bool isOpaque | ( | ) | const [inline] |
Test if the Variant's value is opaque.
| bool isString | ( | ) | const [inline] |
Test if the Variant's value is a String.
| bool isUInt | ( | ) | const [inline] |
Test if the Variant's value is a uint32_t.
| bool isUInt64 | ( | ) | const [inline] |
Test if the Variant's value is a uint64_t.
| bool isWChar | ( | ) | const [inline] |
Test if the Variant's value is a wchar_t.
| bool isWString | ( | ) | const [inline] |
Test if the Variant's value is a WString.
| size_t length | ( | ) | const |
Get the length of the value.
For scalar types, this method returns 0. For maps and lists, it returns the number of items in the map or list.
| operator bool | ( | ) | const [inline] |
Cast operator.
Equivalent to toBool().
| operator char | ( | ) | const [inline] |
Cast operator.
Equivalent to toChar().
| operator const void * | ( | ) | const throw () [inline] |
Boolean evaluation cast operator.
This is not equivalent to toOpaque().
| operator double | ( | ) | const [inline] |
Cast operator.
Equivalent to toDouble().
| operator float | ( | ) | const [inline] |
Cast operator.
Equivalent to toFloat().
| operator int32_t | ( | ) | const [inline] |
Cast operator.
Equivalent to toInt().
| operator int64_t | ( | ) | const [inline] |
Cast operator.
Equivalent to toInt64().
| operator String | ( | ) | const [inline] |
Cast operator.
Equivalent to toString().
| operator uint32_t | ( | ) | const [inline] |
Cast operator.
Equivalent to toUInt().
| operator uint64_t | ( | ) | const [inline] |
Cast operator.
Equivalent to toUInt64().
| operator wchar_t | ( | ) | const [inline] |
Cast operator.
Equivalent to toWChar().
| operator WString | ( | ) | const [inline] |
Cast operator.
Equivalent to toWString().
| bool operator! | ( | ) | const throw () [inline] |
Equivalent to isNull().
| bool operator!= | ( | const Variant & | other | ) | const [inline] |
Inequality operator.
| bool operator== | ( | const Variant & | other | ) | const |
Equality operator.
| const Variant& operator[] | ( | int | index | ) | const throw (OutOfBoundsException) [inline] |
Return the value at the given index from this Variant, whose value is assumed to be a list.
Equivalent to get().
| index | The index. |
| OutOfBoundsException | If the index is negative. |
| Variant & operator[] | ( | int | index | ) | throw (OutOfBoundsException) |
Return the value at the given index from this Variant, whose value is assumed to be a list.
If the variant is not a list, it is automatically re-initialized as a list. If the index is out of range, the list is automatically extended with new values up to that index.
| index | The index. |
| OutOfBoundsException | If the index is negative. |
| const Variant& operator[] | ( | const char * | name | ) | const [inline] |
Return the value for the given name from this Variant, whose value is assumed to be a map.
Equivalent to get().
| name | The name of the value. |
Return the value for the given name from this Variant, whose value is assumed to be a map.
| name | The name of the value. |
| Variant& operator[] | ( | const char * | name | ) | [inline] |
Return the value for the given name from this Variant, whose value is assumed to be a map.
If the variant is not a map, it is automatically re-initialized as a map. If no value with the given name exists, a new one is automatically inserted into the map.
| name | The name of the value. |
Return the value for the given name from this Variant, whose value is assumed to be a map.
If the variant is not a map, it is automatically re-initialized as a map. If no value with the given name exists, a new one is automatically inserted into the map.
| name | The name of the value. |
| void setNull | ( | ) |
Set the value to null.
Any previous value is deleted.
| void setType | ( | Variant::Type | type | ) |
Set the type of this variant.
The value is initialized to the default value for the given type. Any previous value is deleted.
| type | The new type for the Variant. |
| Blob toBlob | ( | ) | const |
Return the Variant's value as a Blob, converting it if necessary, or return Blob::null if a conversion is not possible or not meaningful.
| bool toBool | ( | ) | const |
Return the Variant's value as a bool, converting it if necessary, or return false if a conversion is not possible or not meaningful.
| char toChar | ( | ) | const |
Return the Variant's value as a char, converting it if necessary, or return '\0' if a conversion is not possible or not meaningful.
| double toDouble | ( | ) | const |
Return the Variant's value as a double, converting it if necessary, or return 0.0 if a conversion is not possible or not meaningful.
| float toFloat | ( | ) | const |
Return the Variant's value as a float, converting it if necessary, or return 0.0f if a conversion is not possible or not meaningful.
| int32_t toInt | ( | ) | const |
Return the Variant's value as an int32_t, converting it if necessary, or return 0 if a conversion is not possible or not meaningful.
| int64_t toInt64 | ( | ) | const |
Return the Variant's value as an int64_t, converting it if necessary, or return 0 if a conversion is not possible or not meaningful.
| void * toOpaque | ( | ) | const |
Return the Variant's value as an opaque pointer, or NULL if the value is not an opaque.
| String toString | ( | ) | const |
Return the Variant's value as a String, converting it if necessary, or return String::null if a conversion is not possible or not meaningful.
| uint32_t toUInt | ( | ) | const |
Return the Variant's value as a uint32_t, converting it if necessary, or return 0 if a conversion is not possible or not meaningful.
| uint64_t toUInt64 | ( | ) | const |
Return the Variant's value as a uint64_t, converting it if necessary, or return 0 if a conversion is not possible or not meaningful.
| wchar_t toWChar | ( | ) | const |
Return the Variant's value as a wchar_t, converting it if necessary, or return L'\0' if a conversion is not possible or not meaningful.
| WString toWString | ( | ) | const |
Return the Variant's value as a WString, converting it if necessary, or return WString::null if a conversion is not possible or not meaningful.
| void write | ( | std::ostream & | stream | ) | const |
| bool boolVal |
| char charVal |
| double doubleVal |
| float floatVal |
| int64_t int64Val |
| int32_t intVal |
| VariantList* listVal |
| VariantMap* mapVal |
| void* opaqueVal |
| uint64_t uint64Val |
| uint32_t uintVal |
| wchar_t wcharVal |
1.5.9