| Version: 3.3.1

Public Member Functions | List of all members
wxVariant Class Reference
Class List by Category » Data Structures

`#include <wx/variant.h>`

Inheritance diagram for wxVariant:
[legend]

## Detailed Description

The wxVariant class represents a container for any type.

A variant's value can be changed at run time, possibly to a different type of value.

Note
  As of wxWidgets 2.9.1, wxAny has become the preferred variant class. While most controls still use wxVariant in their interface, you can start using wxAny in your code because of an implicit conversion layer. See below for more information.

As standard, wxVariant can store values of type bool, wxChar, double, long, string, string list, time, date, void pointer, list of strings, and list of variants. However, an application can extend wxVariant's capabilities by deriving from the class wxVariantData and using the wxVariantData form of the wxVariant constructor or assignment operator to assign this data to a variant. Actual values for user-defined types will need to be accessed via the wxVariantData object, unlike the case for basic data types where convenience functions such as GetLong() can be used.

Under Microsoft Windows, three additional wxVariantData-derived classes – wxVariantDataCurrency, wxVariantDataErrorCode and wxVariantDataSafeArray – are available for interoperation with OLE VARIANT when using wxAutomationObject.

Pointers to any wxObject derived class can also easily be stored in a wxVariant. wxVariant will then use wxWidgets' built-in RTTI system to set the type name (returned by GetType()) and to perform type-safety checks at runtime.

This class is useful for reducing the programming for certain tasks, such as an editor for different data types, or a remote procedure call protocol.

An optional name member is associated with a wxVariant. This might be used, for example, in CORBA or OLE automation classes, where named parameters are required.

Note that as of wxWidgets 2.7.1, wxVariant is reference counted.

Convenience macros wxDECLARE_VARIANT_OBJECT() and wxIMPLEMENT_VARIANT_OBJECT() allow easily adding support for conversion to and from wxVariant to custom classes. The first of these macros must be used inside the class declaration and the second one outside of it in the implementation file, e.g.

// in the header file
class MyClass : public wxObject {
...
wxDECLARE_VARIANT_OBJECT(MyClass);
};
// in the implementation file
wxIMPLEMENT_VARIANT_OBJECT(MyClass);
// and then objects of MyClass can be used with wxVariant like this:
wxVariant variant;
MyClass value;
variant << value;
// or
value << variant;
wxObject
This is the root class of many of the wxWidgets classes.
Definition: object.h:233
wxVariant
The wxVariant class represents a container for any type.
Definition: variant.h:170

For this to work, MyClass must derive from wxObject, implement the wxWidgets RTTI system and support the assignment operator and equality operator for itself. Ideally, it should also be reference counted to make copying operations cheap and fast. This can be most easily implemented using the reference counting support offered by wxObject itself. By default, wxWidgets already implements the shift operator conversion for a few of its drawing related classes:

- wxColour
- wxImage
- wxIcon
- wxBitmap
- wxBitmapBundle

Note
  There also are legacy versions of the above macros without `wx` prefix, working in a slightly different way. Please use the new versions in the new code and consider replacing any existing use of the legacy macros with the new ones.

Note that as of wxWidgets 2.9.0, wxVariantData no longer inherits from wxObject and wxVariant no longer uses the type-unsafe wxList class for list operations but the type-safe wxVariantList class. Also, wxVariantData now supports the wxVariantData::Clone() function for implementing the Unshare() function. wxVariantData::Clone() is implemented automatically by IMPLEMENT_VARIANT_OBJECT().

Since wxVariantData no longer derives from wxObject, any code that tests the type of the data using wxDynamicCast() will require adjustment. You can use the macro wxDynamicCastVariantData() with the same arguments as wxDynamicCast(), to use C++ RTTI type information instead of wxWidgets RTTI.

# wxVariant to wxAny Conversion Layer

wxAny is a more modern, template-based variant class. It is not directly compatible with wxVariant, but there is a transparent conversion layer.

Following is an example how to use these conversions with wxPropertyGrid's property class wxPGProperty (which currently uses wxVariants both internally and in the public API):

// Get property value as wxAny instead of wxVariant
wxAny value = property->GetValue();
// Do something with it
DoSomethingWithString(value.As<wxString>());
// Write back new value to property
value = "New Value";
property->SetValue(value);
wxAny
The wxAny class represents a container for any type.
Definition: any.h:61
wxString
String class for passing textual data to or receiving it from wxWidgets.
Definition: string.h:372

Some caveats:

- In wxAny, there are no separate types for handling integers of different sizes, so converting wxAny with 'long long' value will yield wxVariant of "long" type when the value is small enough to fit in without overflow. Otherwise, variant type "longlong" is used. Also note that wxAny holding unsigned integer will always be converted to "ulonglong" wxVariant type.

- Unlike wxVariant, wxAny does not store a (rarely needed) name string.

- Because of implicit conversion of wxVariant to wxAny, wxAny cannot usually contain value of type wxVariant. In other words, any.CheckType<wxVariant>() can never return true.

Supplied conversion functions will automatically work with all built-in wxVariant types, and also with all user-specified types generated using IMPLEMENT_VARIANT_OBJECT(). For hand-built wxVariantData classes, you will need to use supplied macros in a following manner:

// Declare wxVariantData for data type Foo
class wxVariantDataFoo: public wxVariantData
{
public:
// interface
// ...
DECLARE_WXANY_CONVERSION()
protected:
// data storage etc
// ...
};
IMPLEMENT_TRIVIAL_WXANY_CONVERSION(Foo, wxVariantDataFoo)
wxVariantData
The wxVariantData class is used to implement a new type for wxVariant.
Definition: variant.h:613

##

Library: wxBase
Category: Data Structures

See also
  wxVariantData, wxAny

## Public Member Functions
| wxVariant ()
| Default constructor. More...
| wxVariant (wxVariantData *data, const wxString &name=wxEmptyString)
| Constructs a variant directly with a wxVariantData object. More...
| wxVariant (const wxVariant &variant)
| Constructs a variant from another variant by increasing the reference count. More...
| wxVariant (const wxAny &any)
| Constructs a variant by converting it from wxAny. More...
| wxVariant (const wxChar *value, const wxString &name=wxEmptyString)
| Constructs a variant from a wide string literal. More...
| wxVariant (const wxString &value, const wxString &name=wxEmptyString)
| Constructs a variant from a string. More...
| wxVariant (wxChar value, const wxString &name=wxEmptyString)
| Constructs a variant from a wide char. More...
| wxVariant (long value, const wxString &name=wxEmptyString)
| Constructs a variant from a long. More...
| wxVariant (bool value, const wxString &name=wxEmptyString)
| Constructs a variant from a bool. More...
| wxVariant (double value, const wxString &name=wxEmptyString)
| Constructs a variant from a double. More...
| wxVariant (wxLongLong value, const wxString &name=wxEmptyString)
| Constructs a variant from a wxLongLong. More...
| wxVariant (wxULongLong value, const wxString &name=wxEmptyString)
| Constructs a variant from a wxULongLong. More...
| wxVariant (const wxVariantList &value, const wxString &name=wxEmptyString)
| Constructs a variant from a list of variants. More...
| wxVariant (void *value, const wxString &name=wxEmptyString)
| Constructs a variant from a void pointer. More...
| wxVariant (wxObject *value, const wxString &name=wxEmptyString)
| Constructs a variant from a pointer to a wxObject derived class. More...
| wxVariant (const wxDateTime &val, const wxString &name=wxEmptyString)
| Constructs a variant from a wxDateTime. More...
| wxVariant (const wxArrayString &val, const wxString &name=wxEmptyString)
| Constructs a variant from a wxArrayString. More...
virtual | ~wxVariant ()
| Destructor. More...
wxAny | GetAny () const
| Converts wxVariant into wxAny. More...
wxArrayString | GetArrayString () const
| Returns the string array value. More...
bool | GetBool () const
| Returns the boolean value. More...
wxUniChar | GetChar () const
| Returns the character value. More...
wxVariantData * | GetData () const
| Returns a pointer to the internal variant data. More...
wxDateTime | GetDateTime () const
| Returns the date value. More...
double | GetDouble () const
| Returns the floating point value. More...
long | GetLong () const
| Returns the integer value. More...
wxLongLong | GetLongLong () const
| Returns the signed 64-bit integer value. More...
const wxString & | GetName () const
| Returns a constant reference to the variant name. More...
wxString | GetString () const
| Gets the string value. More...
wxString | GetType () const
| Returns the value type as a string. More...
wxULongLong | GetULongLong () const
| Returns the unsigned 64-bit integer value. More...
void * | GetVoidPtr () const
| Gets the void pointer value. More...
wxObject * | GetWxObjectPtr () const
| Gets the wxObject pointer value. More...
bool | IsNull () const
| Returns true if there is no data associated with this variant, false if there is data. More...
bool | IsType (const wxString &type) const
| Returns true if type matches the type of the variant, false otherwise. More...
bool | IsValueKindOf (const wxClassInfo *type) const
| Returns true if the data is derived from the class described by type, false otherwise. More...
void | MakeNull ()
| Makes the variant null by deleting the internal data. More...
wxString | MakeString () const
| Makes a string representation of the variant value (for any type). More...
bool | Member (const wxVariant &value) const
| Returns true if value matches an element in the list. More...
void | SetData (wxVariantData *data)
| Sets the internal variant data, deleting the existing data if there is any. More...
bool | Unshare ()
| Makes sure that any data associated with this variant is not shared with other variants. More...
void * | operator void * () const
| Operator for implicit conversion to a pointer to a void, using GetVoidPtr(). More...
char | operator wxChar () const
| Operator for implicit conversion to a wxChar, using GetChar(). More...
void * | operator wxDateTime () const
| Operator for implicit conversion to a pointer to a wxDateTime, using GetDateTime(). More...
wxString | operator wxString () const
| Operator for implicit conversion to a string, using MakeString(). More...
List Functionality
wxVariant | operator[] (size_t idx) const
| Returns the value at idx (zero-based). More...
wxVariant & | operator[] (size_t idx)
| Returns a reference to the value at idx (zero-based). More...
void | Append (const wxVariant &value)
| Appends a value to the list. More...
void | Clear ()
| Makes the variant null by deleting the internal data and set the name to wxEmptyString. More...
void | ClearList ()
| Deletes the contents of the list. More...
bool | Delete (size_t item)
| Deletes the zero-based item from the list. More...
size_t | GetCount () const
| Returns the number of elements in the list. More...
wxVariantList & | GetList () const
| Returns a reference to the wxVariantList class used by wxVariant if this wxVariant is currently a list of variants. More...
void | Insert (const wxVariant &value)
| Inserts a value at the front of the list. More...
void | NullList ()
| Makes an empty list. More...
bool | Convert (long *value) const
| Retrieves and converts the value of this variant to the type that value is. More...
bool | Convert (bool *value) const
| Retrieves and converts the value of this variant to the type that value is. More...
bool | Convert (double *value) const
| Retrieves and converts the value of this variant to the type that value is. More...
bool | Convert (wxString *value) const
| Retrieves and converts the value of this variant to the type that value is. More...
bool | Convert (wxChar *value) const
| Retrieves and converts the value of this variant to the type that value is. More...
bool | Convert (wxLongLong *value) const
| Retrieves and converts the value of this variant to the type that value is. More...
bool | Convert (wxULongLong *value) const
| Retrieves and converts the value of this variant to the type that value is. More...
bool | Convert (wxDateTime *value) const
| Retrieves and converts the value of this variant to the type that value is. More...
bool | operator!= (const wxVariant &value) const
| Inequality test operator. More...
bool | operator!= (const wxString &value) const
| Inequality test operator. More...
bool | operator!= (const wxChar *value) const
| Inequality test operator. More...
bool | operator!= (wxChar value) const
| Inequality test operator. More...
bool | operator!= (long value) const
| Inequality test operator. More...
bool | operator!= (bool value) const
| Inequality test operator. More...
bool | operator!= (double value) const
| Inequality test operator. More...
bool | operator!= (wxLongLong value) const
| Inequality test operator. More...
bool | operator!= (wxULongLong value) const
| Inequality test operator. More...
bool | operator!= (void *value) const
| Inequality test operator. More...
bool | operator!= (wxObject *value) const
| Inequality test operator. More...
bool | operator!= (const wxVariantList &value) const
| Inequality test operator. More...
bool | operator!= (const wxArrayString &value) const
| Inequality test operator. More...
bool | operator!= (const wxDateTime &value) const
| Inequality test operator. More...
void | operator= (const wxVariant &value)
| Assignment operator, using reference counting if possible. More...
void | operator= (wxVariantData *value)
| Assignment operator, using reference counting if possible. More...
void | operator= (const wxString &value)
| Assignment operator, using reference counting if possible. More...
void | operator= (const wxChar *value)
| Assignment operator, using reference counting if possible. More...
void | operator= (wxChar value)
| Assignment operator, using reference counting if possible. More...
void | operator= (long value)
| Assignment operator, using reference counting if possible. More...
void | operator= (bool value)
| Assignment operator, using reference counting if possible. More...
void | operator= (double value)
| Assignment operator, using reference counting if possible. More...
bool | operator= (wxLongLong value) const
| Assignment operator, using reference counting if possible. More...
bool | operator= (wxULongLong value) const
| Assignment operator, using reference counting if possible. More...
void | operator= (void *value)
| Assignment operator, using reference counting if possible. More...
void | operator= (wxObject *value)
| Assignment operator, using reference counting if possible. More...
void | operator= (const wxVariantList &value)
| Assignment operator, using reference counting if possible. More...
void | operator= (const wxDateTime &value)
| Assignment operator, using reference counting if possible. More...
void | operator= (const wxArrayString &value)
| Assignment operator, using reference counting if possible. More...
bool | operator== (const wxVariant &value) const
| Equality test operator. More...
bool | operator== (const wxString &value) const
| Equality test operator. More...
bool | operator== (const wxChar *value) const
| Equality test operator. More...
bool | operator== (wxChar value) const
| Equality test operator. More...
bool | operator== (long value) const
| Equality test operator. More...
bool | operator== (bool value) const
| Equality test operator. More...
bool | operator== (double value) const
| Equality test operator. More...
bool | operator== (wxLongLong value) const
| Equality test operator. More...
bool | operator== (wxULongLong value) const
| Equality test operator. More...
bool | operator== (void *value) const
| Equality test operator. More...
bool | operator== (wxObject *value) const
| Equality test operator. More...
bool | operator== (const wxVariantList &value) const
| Equality test operator. More...
bool | operator== (const wxArrayString &value) const
| Equality test operator. More...
bool | operator== (const wxDateTime &value) const
| Equality test operator. More...
double | operator double () const
| Operators for implicit conversion, using appropriate getter member function. More...
long | operator long () const
| Operators for implicit conversion, using appropriate getter member function. More...
wxLongLong | operator wxLongLong () const
| Operators for implicit conversion, using appropriate getter member function. More...
wxULongLong | operator wxULongLong () const
| Operators for implicit conversion, using appropriate getter member function. More...
Public Member Functions inherited from wxObject
| wxObject ()
| Default ctor; initializes to nullptr the internal reference data. More...
| wxObject (const wxObject &other)
| Copy ctor. More...
virtual | ~wxObject ()
| Destructor. More...
virtual wxClassInfo * | GetClassInfo () const
| This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar). More...
wxObjectRefData * | GetRefData () const
| Returns the wxObject::m_refData pointer, i.e. the data referenced by this object. More...
bool | IsKindOf (const wxClassInfo *info) const
| Determines whether this class is a subclass of (or the same class as) the given class. More...
bool | IsSameAs (const wxObject &obj) const
| Returns true if this object has the same data pointer as obj. More...
void | Ref (const wxObject &clone)
| Makes this object refer to the data in clone. More...
void | SetRefData (wxObjectRefData *data)
| Sets the wxObject::m_refData pointer. More...
void | UnRef ()
| Decrements the reference count in the associated data, and if it is zero, deletes the data. More...
void | UnShare ()
| This is the same of AllocExclusive() but this method is public. More...
void | operator delete (void *buf)
| The delete operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined. More...
void * | operator new (size_t size, const wxString &filename=nullptr, int lineNum=0)
| The new operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined. More...

## Additional Inherited Members
Protected Member Functions inherited from wxObject
void | AllocExclusive ()
| Ensure that this object's data is not shared with any other object. More...
virtual wxObjectRefData * | CreateRefData () const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it. More...
virtual wxObjectRefData * | CloneRefData (const wxObjectRefData *data) const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data. More...
Protected Attributes inherited from wxObject
wxObjectRefData * | m_refData
| Pointer to an object which is the object's reference-counted data. More...

## Constructor & Destructor Documentation

## ◆ wxVariant() [1/17]

wxVariant::wxVariant | ( |  | ) |

Default constructor.

## ◆ wxVariant() [2/17]

wxVariant::wxVariant | ( | wxVariantData * | data,
|  | const wxString & | name = `wxEmptyString`
| ) |  |

Constructs a variant directly with a wxVariantData object.

wxVariant will take ownership of the wxVariantData and will not increase its reference count.

## ◆ wxVariant() [3/17]

wxVariant::wxVariant | ( | const wxVariant & | variant | ) |

Constructs a variant from another variant by increasing the reference count.

## ◆ wxVariant() [4/17]

wxVariant::wxVariant | ( | const wxAny & | any | ) |

Constructs a variant by converting it from wxAny.

## ◆ wxVariant() [5/17]

wxVariant::wxVariant | ( | const wxChar * | value,
|  | const wxString & | name = `wxEmptyString`
| ) |  |

Constructs a variant from a wide string literal.

## ◆ wxVariant() [6/17]

wxVariant::wxVariant | ( | const wxString & | value,
|  | const wxString & | name = `wxEmptyString`
| ) |  |

Constructs a variant from a string.

## ◆ wxVariant() [7/17]

wxVariant::wxVariant | ( | wxChar | value,
|  | const wxString & | name = `wxEmptyString`
| ) |  |

Constructs a variant from a wide char.

## ◆ wxVariant() [8/17]

wxVariant::wxVariant | ( | long | value,
|  | const wxString & | name = `wxEmptyString`
| ) |  |

Constructs a variant from a long.

## ◆ wxVariant() [9/17]

wxVariant::wxVariant | ( | bool | value,
|  | const wxString & | name = `wxEmptyString`
| ) |  |

Constructs a variant from a bool.

## ◆ wxVariant() [10/17]

wxVariant::wxVariant | ( | double | value,
|  | const wxString & | name = `wxEmptyString`
| ) |  |

Constructs a variant from a double.

## ◆ wxVariant() [11/17]

wxVariant::wxVariant | ( | wxLongLong | value,
|  | const wxString & | name = `wxEmptyString`
| ) |  |

Constructs a variant from a wxLongLong.

## ◆ wxVariant() [12/17]

wxVariant::wxVariant | ( | wxULongLong | value,
|  | const wxString & | name = `wxEmptyString`
| ) |  |

Constructs a variant from a wxULongLong.

## ◆ wxVariant() [13/17]

wxVariant::wxVariant | ( | const wxVariantList & | value,
|  | const wxString & | name = `wxEmptyString`
| ) |  |

Constructs a variant from a list of variants.

## ◆ wxVariant() [14/17]

wxVariant::wxVariant | ( | void * | value,
|  | const wxString & | name = `wxEmptyString`
| ) |  |

Constructs a variant from a void pointer.

## ◆ wxVariant() [15/17]

wxVariant::wxVariant | ( | wxObject * | value,
|  | const wxString & | name = `wxEmptyString`
| ) |  |

Constructs a variant from a pointer to a wxObject derived class.

## ◆ wxVariant() [16/17]

wxVariant::wxVariant | ( | const wxDateTime & | val,
|  | const wxString & | name = `wxEmptyString`
| ) |  |

Constructs a variant from a wxDateTime.

## ◆ wxVariant() [17/17]

wxVariant::wxVariant | ( | const wxArrayString & | val,
|  | const wxString & | name = `wxEmptyString`
| ) |  |

Constructs a variant from a wxArrayString.

## ◆ ~wxVariant()

virtual wxVariant::~wxVariant | ( |  | ) |
| virtual

Destructor.

Note
  wxVariantData's destructor is protected, so wxVariantData cannot usually be deleted. Instead, wxVariantData::DecRef() should be called. See reference-counted object destruction for more info.

## Member Function Documentation

## ◆ Append()

void wxVariant::Append | ( | const wxVariant & | value | ) |

Appends a value to the list.

## ◆ Clear()

void wxVariant::Clear | ( |  | ) |

Makes the variant null by deleting the internal data and set the name to wxEmptyString.

## ◆ ClearList()

void wxVariant::ClearList | ( |  | ) |

Deletes the contents of the list.

## ◆ Convert() [1/8]

bool wxVariant::Convert | ( | bool * | value | ) | const

Retrieves and converts the value of this variant to the type that value is.

## ◆ Convert() [2/8]

bool wxVariant::Convert | ( | double * | value | ) | const

Retrieves and converts the value of this variant to the type that value is.

## ◆ Convert() [3/8]

bool wxVariant::Convert | ( | long * | value | ) | const

Retrieves and converts the value of this variant to the type that value is.

## ◆ Convert() [4/8]

bool wxVariant::Convert | ( | wxChar * | value | ) | const

Retrieves and converts the value of this variant to the type that value is.

## ◆ Convert() [5/8]

bool wxVariant::Convert | ( | wxDateTime * | value | ) | const

Retrieves and converts the value of this variant to the type that value is.

## ◆ Convert() [6/8]

bool wxVariant::Convert | ( | wxLongLong * | value | ) | const

Retrieves and converts the value of this variant to the type that value is.

## ◆ Convert() [7/8]

bool wxVariant::Convert | ( | wxString * | value | ) | const

Retrieves and converts the value of this variant to the type that value is.

## ◆ Convert() [8/8]

bool wxVariant::Convert | ( | wxULongLong * | value | ) | const

Retrieves and converts the value of this variant to the type that value is.

## ◆ Delete()

bool wxVariant::Delete | ( | size_t | item | ) |

Deletes the zero-based item from the list.

## ◆ GetAny()

wxAny wxVariant::GetAny | ( |  | ) | const

Converts wxVariant into wxAny.

## ◆ GetArrayString()

wxArrayString wxVariant::GetArrayString | ( |  | ) | const

Returns the string array value.

## ◆ GetBool()

bool wxVariant::GetBool | ( |  | ) | const

Returns the boolean value.

## ◆ GetChar()

wxUniChar wxVariant::GetChar | ( |  | ) | const

Returns the character value.

## ◆ GetCount()

size_t wxVariant::GetCount | ( |  | ) | const

Returns the number of elements in the list.

## ◆ GetData()

wxVariantData* wxVariant::GetData | ( |  | ) | const

Returns a pointer to the internal variant data.

To take ownership of this data, you must call its wxVariantData::IncRef() method. When you stop using it, wxVariantData::DecRef() must be called as well.

## ◆ GetDateTime()

wxDateTime wxVariant::GetDateTime | ( |  | ) | const

Returns the date value.

## ◆ GetDouble()

double wxVariant::GetDouble | ( |  | ) | const

Returns the floating point value.

## ◆ GetList()

wxVariantList& wxVariant::GetList | ( |  | ) | const

Returns a reference to the wxVariantList class used by wxVariant if this wxVariant is currently a list of variants.

## ◆ GetLong()

long wxVariant::GetLong | ( |  | ) | const

Returns the integer value.

## ◆ GetLongLong()

wxLongLong wxVariant::GetLongLong | ( |  | ) | const

Returns the signed 64-bit integer value.

## ◆ GetName()

const wxString& wxVariant::GetName | ( |  | ) | const

Returns a constant reference to the variant name.

## ◆ GetString()

wxString wxVariant::GetString | ( |  | ) | const

Gets the string value.

## ◆ GetType()

wxString wxVariant::GetType | ( |  | ) | const

Returns the value type as a string.

The built-in types are:

- "bool"
- "char"
- "datetime"
- "double"
- "list"
- "long"
- "longlong"
- "string"
- "ulonglong"
- "arrstring"
- "void*"

If the variant is null, the value type returned is the string "null" (not the empty string).

## ◆ GetULongLong()

wxULongLong wxVariant::GetULongLong | ( |  | ) | const

Returns the unsigned 64-bit integer value.

## ◆ GetVoidPtr()

void* wxVariant::GetVoidPtr | ( |  | ) | const

Gets the void pointer value.

Notice that this method can be used for null objects (i.e. those for which IsNull() returns true) and will return nullptr for them.

## ◆ GetWxObjectPtr()

wxObject* wxVariant::GetWxObjectPtr | ( |  | ) | const

Gets the wxObject pointer value.

## ◆ Insert()

void wxVariant::Insert | ( | const wxVariant & | value | ) |

Inserts a value at the front of the list.

## ◆ IsNull()

bool wxVariant::IsNull | ( |  | ) | const

Returns true if there is no data associated with this variant, false if there is data.

## ◆ IsType()

bool wxVariant::IsType | ( | const wxString & | type | ) | const

Returns true if type matches the type of the variant, false otherwise.

## ◆ IsValueKindOf()

bool wxVariant::IsValueKindOf | ( | const wxClassInfo * | type | ) | const

Returns true if the data is derived from the class described by type, false otherwise.

## ◆ MakeNull()

void wxVariant::MakeNull | ( |  | ) |

Makes the variant null by deleting the internal data.

## ◆ MakeString()

wxString wxVariant::MakeString | ( |  | ) | const

Makes a string representation of the variant value (for any type).

## ◆ Member()

bool wxVariant::Member | ( | const wxVariant & | value | ) | const

Returns true if value matches an element in the list.

## ◆ NullList()

void wxVariant::NullList | ( |  | ) |

Makes an empty list.

This differs from a null variant which has no data; a null list is of type list, but the number of elements in the list is zero.

## ◆ operator double()

double wxVariant::operator double | ( |  | ) | const

Operators for implicit conversion, using appropriate getter member function.

## ◆ operator long()

long wxVariant::operator long | ( |  | ) | const

Operators for implicit conversion, using appropriate getter member function.

## ◆ operator void *()

void* wxVariant::operator void * | ( |  | ) | const

Operator for implicit conversion to a pointer to a void, using GetVoidPtr().

## ◆ operator wxChar()

char wxVariant::operator wxChar | ( |  | ) | const

Operator for implicit conversion to a wxChar, using GetChar().

## ◆ operator wxDateTime()

void* wxVariant::operator wxDateTime | ( |  | ) | const

Operator for implicit conversion to a pointer to a wxDateTime, using GetDateTime().

## ◆ operator wxLongLong()

wxLongLong wxVariant::operator wxLongLong | ( |  | ) | const

Operators for implicit conversion, using appropriate getter member function.

## ◆ operator wxString()

wxString wxVariant::operator wxString | ( |  | ) | const

Operator for implicit conversion to a string, using MakeString().

## ◆ operator wxULongLong()

wxULongLong wxVariant::operator wxULongLong | ( |  | ) | const

Operators for implicit conversion, using appropriate getter member function.

## ◆ operator!=() [1/14]

bool wxVariant::operator!= | ( | bool | value | ) | const

Inequality test operator.

## ◆ operator!=() [2/14]

bool wxVariant::operator!= | ( | const wxArrayString & | value | ) | const

Inequality test operator.

## ◆ operator!=() [3/14]

bool wxVariant::operator!= | ( | const wxChar * | value | ) | const

Inequality test operator.

## ◆ operator!=() [4/14]

bool wxVariant::operator!= | ( | const wxDateTime & | value | ) | const

Inequality test operator.

## ◆ operator!=() [5/14]

bool wxVariant::operator!= | ( | const wxString & | value | ) | const

Inequality test operator.

## ◆ operator!=() [6/14]

bool wxVariant::operator!= | ( | const wxVariant & | value | ) | const

Inequality test operator.

## ◆ operator!=() [7/14]

bool wxVariant::operator!= | ( | const wxVariantList & | value | ) | const

Inequality test operator.

## ◆ operator!=() [8/14]

bool wxVariant::operator!= | ( | double | value | ) | const

Inequality test operator.

## ◆ operator!=() [9/14]

bool wxVariant::operator!= | ( | long | value | ) | const

Inequality test operator.

## ◆ operator!=() [10/14]

bool wxVariant::operator!= | ( | void * | value | ) | const

Inequality test operator.

## ◆ operator!=() [11/14]

bool wxVariant::operator!= | ( | wxChar | value | ) | const

Inequality test operator.

## ◆ operator!=() [12/14]

bool wxVariant::operator!= | ( | wxLongLong | value | ) | const

Inequality test operator.

## ◆ operator!=() [13/14]

bool wxVariant::operator!= | ( | wxObject * | value | ) | const

Inequality test operator.

## ◆ operator!=() [14/14]

bool wxVariant::operator!= | ( | wxULongLong | value | ) | const

Inequality test operator.

## ◆ operator=() [1/15]

void wxVariant::operator= | ( | bool | value | ) |

Assignment operator, using reference counting if possible.

## ◆ operator=() [2/15]

void wxVariant::operator= | ( | const wxArrayString & | value | ) |

Assignment operator, using reference counting if possible.

## ◆ operator=() [3/15]

void wxVariant::operator= | ( | const wxChar * | value | ) |

Assignment operator, using reference counting if possible.

## ◆ operator=() [4/15]

void wxVariant::operator= | ( | const wxDateTime & | value | ) |

Assignment operator, using reference counting if possible.

## ◆ operator=() [5/15]

void wxVariant::operator= | ( | const wxString & | value | ) |

Assignment operator, using reference counting if possible.

## ◆ operator=() [6/15]

void wxVariant::operator= | ( | const wxVariant & | value | ) |

Assignment operator, using reference counting if possible.

## ◆ operator=() [7/15]

void wxVariant::operator= | ( | const wxVariantList & | value | ) |

Assignment operator, using reference counting if possible.

## ◆ operator=() [8/15]

void wxVariant::operator= | ( | double | value | ) |

Assignment operator, using reference counting if possible.

## ◆ operator=() [9/15]

void wxVariant::operator= | ( | long | value | ) |

Assignment operator, using reference counting if possible.

## ◆ operator=() [10/15]

void wxVariant::operator= | ( | void * | value | ) |

Assignment operator, using reference counting if possible.

## ◆ operator=() [11/15]

void wxVariant::operator= | ( | wxChar | value | ) |

Assignment operator, using reference counting if possible.

## ◆ operator=() [12/15]

bool wxVariant::operator= | ( | wxLongLong | value | ) | const

Assignment operator, using reference counting if possible.

## ◆ operator=() [13/15]

void wxVariant::operator= | ( | wxObject * | value | ) |

Assignment operator, using reference counting if possible.

## ◆ operator=() [14/15]

bool wxVariant::operator= | ( | wxULongLong | value | ) | const

Assignment operator, using reference counting if possible.

## ◆ operator=() [15/15]

void wxVariant::operator= | ( | wxVariantData * | value | ) |

Assignment operator, using reference counting if possible.

## ◆ operator==() [1/14]

bool wxVariant::operator== | ( | bool | value | ) | const

Equality test operator.

## ◆ operator==() [2/14]

bool wxVariant::operator== | ( | const wxArrayString & | value | ) | const

Equality test operator.

## ◆ operator==() [3/14]

bool wxVariant::operator== | ( | const wxChar * | value | ) | const

Equality test operator.

## ◆ operator==() [4/14]

bool wxVariant::operator== | ( | const wxDateTime & | value | ) | const

Equality test operator.

## ◆ operator==() [5/14]

bool wxVariant::operator== | ( | const wxString & | value | ) | const

Equality test operator.

## ◆ operator==() [6/14]

bool wxVariant::operator== | ( | const wxVariant & | value | ) | const

Equality test operator.

## ◆ operator==() [7/14]

bool wxVariant::operator== | ( | const wxVariantList & | value | ) | const

Equality test operator.

## ◆ operator==() [8/14]

bool wxVariant::operator== | ( | double | value | ) | const

Equality test operator.

## ◆ operator==() [9/14]

bool wxVariant::operator== | ( | long | value | ) | const

Equality test operator.

## ◆ operator==() [10/14]

bool wxVariant::operator== | ( | void * | value | ) | const

Equality test operator.

## ◆ operator==() [11/14]

bool wxVariant::operator== | ( | wxChar | value | ) | const

Equality test operator.

## ◆ operator==() [12/14]

bool wxVariant::operator== | ( | wxLongLong | value | ) | const

Equality test operator.

## ◆ operator==() [13/14]

bool wxVariant::operator== | ( | wxObject * | value | ) | const

Equality test operator.

## ◆ operator==() [14/14]

bool wxVariant::operator== | ( | wxULongLong | value | ) | const

Equality test operator.

## ◆ operator[]() [1/2]

wxVariant& wxVariant::operator[] | ( | size_t | idx | ) |

Returns a reference to the value at idx (zero-based).

This can be used to change the value at this index.

## ◆ operator[]() [2/2]

wxVariant wxVariant::operator[] | ( | size_t | idx | ) | const

Returns the value at idx (zero-based).

## ◆ SetData()

void wxVariant::SetData | ( | wxVariantData * | data | ) |

Sets the internal variant data, deleting the existing data if there is any.

## ◆ Unshare()

bool wxVariant::Unshare | ( |  | ) |

Makes sure that any data associated with this variant is not shared with other variants.

For this to work, wxVariantData::Clone() must be implemented for the data types you are working with. wxVariantData::Clone() is implemented for all the default data types.