Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
|
A Variant type can hold any kind of object, be it a boolean, integer, real, string, or even array of Variants or dictionaries of variants. More...
#include <FXVariant.h>
Public Types | |
enum | Type { NullType =0, BoolType, CharType, IntType, UIntType, LongType, ULongType, FloatType, DoubleType, PointerType, StringType, ArrayType, MapType } |
Public Member Functions | |
FXVariant () | |
Default constructor makes null type. | |
FXVariant (const FXVariant &other) | |
Copy constructor. | |
FXVariant (FXbool val) | |
Construct and initialize with bool. | |
FXVariant (FXchar val) | |
Construct and initialize with char. | |
FXVariant (FXint val) | |
Construct and initialize with int. | |
FXVariant (FXuint val) | |
Construct and initialize with unsigned int. | |
FXVariant (FXlong val) | |
Construct and initialize with long. | |
FXVariant (FXulong val) | |
Construct and initialize with unsigned long. | |
FXVariant (FXfloat val) | |
Construct and initialize with float. | |
FXVariant (FXdouble val) | |
Construct and initialize with double. | |
FXVariant (FXptr val) | |
Construct and initialize with pointer. | |
FXVariant (const FXchar *val) | |
Construct and initialize with constant string. | |
FXVariant (const FXString &val) | |
Construct and initialize with string. | |
void | setType (Type t) |
Change type. | |
Type | getType () const |
Return type. | |
FXival | no () const |
Return size of array. | |
FXbool | no (FXival n) |
Change number of elements in array. | |
FXbool | isNull () const |
Is it a null? | |
FXbool | isBool () const |
Is it a bool? | |
FXbool | isChar () const |
Is it a character? | |
FXbool | isInt () const |
Is it a int? | |
FXbool | isUInt () const |
Is it a unsigned int? | |
FXbool | isLong () const |
Is it a long? | |
FXbool | isULong () const |
Is it a unsigned long? | |
FXbool | isFloat () const |
Is it a float? | |
FXbool | isDouble () const |
Is it a double? | |
FXbool | isInteger () const |
Is it a integer (bool, char, ..., or long)? | |
FXbool | isReal () const |
Is it a real (float or double)? | |
FXbool | isNumber () const |
Is it any kind of number? | |
FXbool | isPtr () const |
Is it a pointer? | |
FXbool | isString () const |
Is it a string? | |
FXbool | isArray () const |
Is it a array? | |
FXbool | isMap () const |
Is it a map? | |
FXbool | toBool () const |
Convert to bool; always OK. | |
FXptr | toPtr () const |
Convert to pointer. | |
FXint | toInt (FXbool *ok=nullptr) const |
Convert to int. | |
FXuint | toUInt (FXbool *ok=nullptr) const |
Convert to unsigned int. | |
FXlong | toLong (FXbool *ok=nullptr) const |
Convert to long. | |
FXulong | toULong (FXbool *ok=nullptr) const |
Convert to unsigned long. | |
FXfloat | toFloat (FXbool *ok=nullptr) const |
Convert to float. | |
FXdouble | toDouble (FXbool *ok=nullptr) const |
Convert to double. | |
const FXchar * | toChars () const |
Convert to char pointer. | |
FXString | toString (FXbool *ok=nullptr) const |
Convert to string. | |
operator FXbool () const | |
Convert to bool. | |
operator FXptr () const | |
Convert to pointer. | |
operator FXchar () const | |
Convert to char. | |
operator FXuchar () const | |
Convert to unsigned char. | |
operator FXshort () const | |
Convert to short. | |
operator FXushort () const | |
Convert to unsigned short. | |
operator FXint () const | |
Convert to int. | |
operator FXuint () const | |
Convert to unsigned int. | |
operator FXlong () const | |
Convert to long. | |
operator FXulong () const | |
Convert to unsigned long. | |
operator FXfloat () const | |
Convert to float. | |
operator FXdouble () const | |
Convert to double. | |
operator FXString () const | |
Convert to string. | |
FXVariant & | operator= (FXbool val) |
Assign with bool. | |
FXVariant & | operator= (FXchar val) |
Assign with char. | |
FXVariant & | operator= (FXint val) |
Assign with int. | |
FXVariant & | operator= (FXuint val) |
Assign with unsigned int. | |
FXVariant & | operator= (FXlong val) |
Assign with long. | |
FXVariant & | operator= (FXulong val) |
Assign with unsigned long. | |
FXVariant & | operator= (FXfloat val) |
Assign with float. | |
FXVariant & | operator= (FXdouble val) |
Assign with double. | |
FXVariant & | operator= (FXptr val) |
Assign with pointer. | |
FXVariant & | operator= (const FXchar *val) |
Assign with constant string. | |
FXVariant & | operator= (const FXString &val) |
Assign with string. | |
FXVariant & | operator= (const FXVariant &val) |
Assign with variant. | |
FXVariant & | assign (const FXVariant &other) |
Assign with variant. | |
FXVariant & | adopt (FXVariant &other) |
Adopt variant from another. | |
FXVariant & | at (const FXchar *key) |
Return value of object member. | |
const FXVariant & | at (const FXchar *key) const |
Return value of object member. | |
FXVariant & | operator[] (const FXchar *key) |
Return value of object member. | |
const FXVariant & | operator[] (const FXchar *key) const |
Return value of object member. | |
FXVariant & | at (const FXString &key) |
Return value of object member. | |
const FXVariant & | at (const FXString &key) const |
Return value of object member. | |
FXVariant & | operator[] (const FXString &key) |
Return value of object member. | |
const FXVariant & | operator[] (const FXString &key) const |
Return value of object member. | |
FXVariant & | at (FXival idx) |
Return value of array member. | |
const FXVariant & | at (FXival idx) const |
Return value of array member. | |
FXVariant & | operator[] (FXint idx) |
Return value of array member. | |
const FXVariant & | operator[] (FXint idx) const |
FXVariant & | operator[] (FXival idx) |
Return value of array member. | |
const FXVariant & | operator[] (FXival idx) const |
FXbool | has (const FXchar *key) const |
Check if key is mapped. | |
FXbool | has (const FXString &key) const |
Check if key is mapped. | |
FXptr & | asPtr () |
Return the value of the variant as a pointer; variant type MUST be PointerType. | |
const FXptr & | asPtr () const |
Return the value of the variant as a pointer; variant type MUST be PointerType. | |
FXlong & | asLong () |
Return the value of the variant as a long; variant type MUST be LongType. | |
const FXlong & | asLong () const |
Return the value of the variant as a long; variant type MUST be LongType. | |
FXulong & | asULong () |
Return the value of the variant as an unsigned long; variant type MUST be ULongType. | |
const FXulong & | asULong () const |
Return the value of the variant as an unsigned long; variant type MUST be ULongType. | |
FXdouble & | asDouble () |
Return the value of the variant as a double; variant type MUST be DoubleType. | |
const FXdouble & | asDouble () const |
Return the value of the variant as a double; variant type MUST be DoubleType. | |
const FXchar * | asChars () const |
Return the value of the variant as a char pointer; variant type MUST be StringType. | |
FXString & | asString () |
Return the value of the variant as a string-reference; variant type MUST be StringType. | |
const FXString & | asString () const |
Return the value of the variant as a const string-reference; variant type MUST be StringType. | |
FXVariantArray & | asArray () |
Return the value of the variant as an array-reference; variant type MUST be ArrayType. | |
const FXVariantArray & | asArray () const |
Return the value of the variant as a const array-reference; variant type MUST be ArrayType. | |
FXVariantMap & | asMap () |
Return the value of the variant as an map-reference; variant type MUST be MapType. | |
const FXVariantMap & | asMap () const |
Return the value of the variant as a const map-reference; variant type MUST be MapType. | |
FXbool | remove (const FXchar *key) |
Remove variant at key from map. | |
FXbool | remove (const FXString &key) |
Remove variant at key from map. | |
FXbool | erase (FXival idx) |
Erase variant at idx from array. | |
FXbool | clear () |
Clear the data. | |
~FXVariant () | |
Destroy. | |
Static Public Attributes | |
static const FXVariant | null |
Default constant variant. | |
A Variant type can hold any kind of object, be it a boolean, integer, real, string, or even array of Variants or dictionaries of variants.
Complex hierarchies of Variants can be loaded (and saved) using the JSON parser. When writing Variants, dictionaries and arrays are automatically grown. When reading Variants, non-existing dictionary entries or indexes outside arrays will read as 0 (for numbers), the empty string, or as an empty dictionary or array. For efficiency, you can hold references to Variants, for example to avoid repeatedly accessing dictionaries or arrays with the same key or index. However, be aware that adding or removing sub-items to dictionaries or arrays may cause reallocations of existing items and thus some care must be exercised when doing this.
Copyright © 1997-2022 Jeroen van der Zijp |