Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FX::FXVariant Class Reference

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>

List of all members.

Classes

union  VValue

Public Types

enum  VType {
  VNull = 0, VBool, VChar, VInt,
  VUInt, VLong, VULong, VFloat,
  VDouble, VPointer, VString, VArray,
  VMap
}

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.
 FXVariant (const FXVariantArray &val)
 Construct and initialize with array.
 FXVariant (const FXVariantMap &val)
 Construct and initialize with map.
void setType (VType t)
 Change type.
VType 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 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.
const FXchar * toChars () const
 Convert to char pointer.
FXint toInt (FXbool *ok=NULL) const
 Convert to int.
FXuint toUInt (FXbool *ok=NULL) const
 Convert to unsigned int.
FXlong toLong (FXbool *ok=NULL) const
 Convert to long.
FXulong toULong (FXbool *ok=NULL) const
 Convert to unsigned long.
FXfloat toFloat (FXbool *ok=NULL) const
 Convert to float.
FXdouble toDouble (FXbool *ok=NULL) const
 Convert to double.
FXString toString (FXbool *ok=NULL) 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 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.
FXVariantoperator= (FXbool val)
 Assign with bool.
FXVariantoperator= (FXchar val)
 Assign with char.
FXVariantoperator= (FXint val)
 Assign with int.
FXVariantoperator= (FXuint val)
 Assign with unsigned int.
FXVariantoperator= (FXlong val)
 Assign with long.
FXVariantoperator= (FXulong val)
 Assign with unsigned long.
FXVariantoperator= (FXfloat val)
 Assign with float.
FXVariantoperator= (FXdouble val)
 Assign with double.
FXVariantoperator= (FXptr val)
 Assign with pointer.
FXVariantoperator= (const FXchar *val)
 Assign with constant string.
FXVariantoperator= (const FXString &val)
 Assign with string.
FXVariantoperator= (const FXVariantArray &val)
 Assign with array.
FXVariantoperator= (const FXVariantMap &val)
 Assign with map.
FXVariantoperator= (const FXVariant &val)
 Assign with variant.
FXVariantadopt (FXVariant &other)
 Adopt variant from another.
FXVariantadopt (FXVariantArray &other)
 Adopt variant array.
FXVariantadopt (FXVariantMap &other)
 Adopt a variant map.
FXVariantat (const FXchar *key)
 Return value of object member.
const FXVariantat (const FXchar *key) const
 Return value of object member.
FXVariantoperator[] (const FXchar *key)
 Return value of object member.
const FXVariantoperator[] (const FXchar *key) const
 Return value of object member.
FXVariantat (const FXString &key)
 Return value of object member.
const FXVariantat (const FXString &key) const
 Return value of object member.
FXVariantoperator[] (const FXString &key)
 Return value of object member.
const FXVariantoperator[] (const FXString &key) const
 Return value of object member.
FXVariantat (FXival idx)
 Return value of array member.
const FXVariantat (FXival idx) const
 Return value of array member.
FXVariantoperator[] (FXint idx)
 Return value of array member.
const FXVariantoperator[] (FXint idx) const
FXVariantoperator[] (FXival idx)
 Return value of array member.
const FXVariantoperator[] (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 a VPointer.
const FXptr & asPtr () const
 Return the value of the variant as a pointer; variant type MUST be a VPointer.
FXlong & asLong ()
 Return the value of the variant as a long; variant type MUST be a VLong.
const FXlong & asLong () const
 Return the value of the variant as a long; variant type MUST be a VLong.
FXulong & asULong ()
 Return the value of the variant as an unsigned long; variant type MUST be a VULong.
const FXulong & asULong () const
 Return the value of the variant as an unsigned long; variant type MUST be a VULong.
FXdouble & asDouble ()
 Return the value of the variant as a double; variant type MUST be a VDouble.
const FXdouble & asDouble () const
 Return the value of the variant as a double; variant type MUST be a VDouble.
const FXchar * asChars () const
 Return the value of the variant as a char pointer; variant type MUST be a VString.
FXStringasString ()
 Return the value of the variant as a string-reference; variant type MUST be a VString.
const FXStringasString () const
 Return the value of the variant as a const string-reference; variant type MUST be a VString.
FXVariantArrayasArray ()
 Return the value of the variant as an array-reference; variant type MUST be a VArray.
const FXVariantArrayasArray () const
 Return the value of the variant as a const array-reference; variant type MUST be a VArray.
FXVariantMapasMap ()
 Return the value of the variant as an map-reference; variant type MUST be VMap.
const FXVariantMapasMap () const
 Return the value of the variant as a const map-reference; variant type MUST be VMap.
void clear ()
 Clear the data.
void reset ()
 Reset to null.
 ~FXVariant ()
 Destroy.

Static Public Attributes

static const FXVariant null
 Default constant variant.

Detailed Description

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 (for arrays), or empty dictionaries or arrays. 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.


The documentation for this class was generated from the following file:

Copyright © 1997-2016 Jeroen van der Zijp