GVariant Class Reference

A class that can be different types. More...

#include <GVariant.h>

Inherited by GNamedVariant.

List of all members.

Public Member Functions

 GVariant ()
 Constructor to null.
 GVariant (int i)
 Constructor for int.
 GVariant (int64 i)
 Constructor for int.
 GVariant (double i)
 Constructor for double.
 GVariant (char *s)
 Constructor for string.
 GVariant (char16 *s)
 Constructor for wide string.
 GVariant (void *p)
 Constructor for ptr.
 GVariant (GDom *p)
 Constructor for DOM ptr.
 GVariant (GDom *p, char *name)
 Constructor for DOM variable reference.
 GVariant (GDateTime *d)
 Constructor for date.
 GVariant (GVariant const &v)
 Constructor for variant.
 GVariant (GOperator Op)
 Construtor for operator.
 ~GVariant ()
 Destructor.
GVariantoperator= (int i)
 Assign int value.
GVariantoperator= (bool i)
 Assign bool value.
GVariantoperator= (int64 i)
 Assign int value.
GVariantoperator= (double i)
 Assign double value.
GVariantoperator= (char *s)
 Assign string value (makes a copy).
GVariantoperator= (char16 *s)
 Assign a wide string value (makes a copy).
GVariantoperator= (GVariant const &i)
 Assign another variant value.
GVariantoperator= (void *p)
 Assign value to a void ptr.
GVariantoperator= (GDom *p)
 Assign value to DOM ptr.
GVariantoperator= (GDateTime *d)
 Assign value to be a date/time.
bool SetDomRef (GDom *obj, char *name)
 Sets the value to a DOM variable reference.
bool SetBinary (int Len, void *Data, bool Own=false)
 Sets the value to a copy of block of binary data.
bool SetList (List< GVariant > *Lst=0)
 Sets the value to a copy of the list.
bool SetHashTable (GHashTable *Table=0, bool Copy=true)
 Sets the value to a hashtable.
char * Str ()
 Returns the string if valid (will convert a GV_WSTRING to utf).
char16WStr ()
 Returns a wide string if valid (will convert a GV_STRING to wide).
char * ReleaseStr ()
char16ReleaseWStr ()
void OwnStr (char *s)
 Sets the variant to a heap string and takes ownership of it.
void OwnStr (char16 *s)
 Sets the variant to a wide heap string and takes ownership of it.
void Empty ()
 Sets the variant to NULL.
bool IsInt ()
 True if currently a int.
bool IsBool ()
 True if currently a bool.
bool IsDouble ()
 True if currently a double.
bool IsString ()
 True if currently a string.
bool IsBinary ()
 True if currently a binary block.
bool IsNull ()
 True if currently null.
GVariantCast (GVariantType NewType)
int32 CastInt32 ()
int64 CastInt64 ()
double CastDouble ()
char * CastString ()
GDomCastDom ()
 Casts to a DOM ptr.
bool CastBool ()
 Casts to a boolean.
void * CastVoidPtr ()
 Returns the pointer if available.

Public Attributes

GVariantType Type
 The type of the variant.
uint32 User
 User data.
union {
   int   Int
 Valid when Type == GV_INT32.
   bool   Bool
 Valid when Type == GV_BOOL.
   int64   Int64
 Valid when Type == GV_INT64.
   double   Dbl
 Valid when Type == GV_DOUBLE.
   char *   String
 Valid when Type == GV_STRING.
   char16 *   WString
 Valid when Type == GV_WSTRING.
   GDom *   Dom
 Valid when Type == GV_DOM.
   void *   Ptr
 Valid when Type is GV_VOID_PTR, GV_GVIEW, GV_GMOUSE or GV_GKEY.
   struct _Binary {
   }   Binary
 Valid when Type == GV_BINARY.
   List< GVariant > *   Lst
 Valid when Type == GV_LIST.
   GHashTable *   Hash
 Valid when Type == GV_HASHTABLE.
   GDateTime *   Date
 Valid when Type == GV_DATETIME.
   struct _Custom {
   }   Custom
 Valid when Type == GV_CUSTOM.
   struct _DomRef {
      GDom *   Dom
 The pointer to the dom object.
      char *   Name
 The name of the variable to set/get in the dom object.
   }   DomRef
 Valid when Type == GV_DOMREF.
   GOperator   Op
 Valid when Type == GV_OPERATOR.
   class GSurface *   Surface
 Valid when Type == GV_GSURFACE.
   class GView *   View
 Valid when Type == GV_GVIEW.
   class GMouse *   Mouse
 Valid when Type == GV_GMOUSE.
   class GKey *   Key
 Valid when Type == GV_GKEY.
Value
 The value of the variant.


Detailed Description

A class that can be different types.

Member Function Documentation

GVariant & GVariant::Cast ( GVariantType  NewType  ) 

Changes the variant's type, maintaining the value where possible. If no conversion is available then nothing happens.

References CastDouble(), CastInt32(), CastInt64(), CastString(), Empty(), GV_BOOL, GV_DATETIME, GV_DOUBLE, GV_INT32, GV_INT64, GV_STRING, GDateTime::Set(), Type, and Value.

double GVariant::CastDouble (  ) 

Casts the value to double, from whatever source type. The GVariant type does not change after calling this.

References CastDouble(), GV_BOOL, GV_DOMREF, GV_DOUBLE, GV_INT32, GV_INT64, GV_STRING, Type, and Value.

Referenced by Cast(), and CastDouble().

int32 GVariant::CastInt32 (  ) 

Casts the value to int, from whatever source type. The GVariant type does not change after calling this.

References CastInt32(), GV_BOOL, GV_DOM, GV_DOMREF, GV_DOUBLE, GV_INT32, GV_INT64, GV_STRING, Type, and Value.

Referenced by Cast(), CastInt32(), and GXmlToUi::Convert().

int64 GVariant::CastInt64 (  ) 

Casts the value to a 64 bit int, from whatever source type. The GVariant type does not change after calling this.

References CastInt64(), GV_BOOL, GV_DOMREF, GV_DOUBLE, GV_INT32, GV_INT64, GV_STRING, Type, and Value.

Referenced by Cast(), and CastInt64().

char * GVariant::CastString (  ) 

Cast to a string from whatever source type, the GVariant will take the type GV_STRING after calling this. This is because returning a static string is not thread safe.

References CastString(), GV_BOOL, GV_DATETIME, GV_DOMREF, GV_DOUBLE, GV_INT32, GV_INT64, GV_STRING, Str(), Type, and Value.

Referenced by Cast(), and CastString().

char * GVariant::ReleaseStr (  ) 

Returns the string, releasing ownership of the memory to caller and changing this GVariant to GV_NULL.

References GV_NULL, Str(), Type, and Value.

char16 * GVariant::ReleaseWStr (  ) 

Returns the wide string, releasing ownership of the memory to caller and changing this GVariant to GV_NULL.

References GV_NULL, Type, Value, and WStr().


Member Data Documentation

Valid when Type == GV_DOM.

The pointer to the dom object.

Referenced by operator=().


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

Generated on Wed Dec 1 15:41:05 2010 for Lgi by  doxygen 1.5.7.1