Contents Up Previous Next

wxVariantData

The wxVariantData class is used to implement a new type for wxVariant. Derive from wxVariantData, and override the pure virtual functions.

wxVariantData is reference counted, but you don't normally have to care about this, as wxVariant manages the count automatically. However, in case your application needs to take ownership of wxVariantData, be aware that the object is created with reference count of 1, and passing it to wxVariant will not increase this. In other words, IncRef needs to be called only if you both take ownership of wxVariantData and pass it to a wxVariant. Also note that the destructor is protected, so you can never explicitly delete a wxVariantData instance. Instead, DecRef will delete the object automatically when the reference count reaches zero.

Derived from

wxObject

Include files

<wx/variant.h>

See also

wxVariant

Members

wxVariantData::wxVariantData
wxVariantData::DecRef
wxVariantData::Eq
wxVariantData::GetType
wxVariantData::GetValueClassInfo
wxVariantData::IncRef
wxVariantData::Read
wxVariantData::Write
wxGetVariantCast


wxVariantData::wxVariantData

wxVariantData()

Default constructor.


wxVariantData::DecRef

void DecRef()

Decreases reference count. If the count reaches zero, the object is automatically deleted.

Note that destructor of wxVariantData is protected, so delete cannot be used as normal. Instead, DecRef should be called.


wxVariantData::Eq

bool Eq(wxVariantData& data) const

Returns true if this object is equal to data.


wxVariantData::GetType

wxString GetType() const

Returns the string type of the data.


wxVariantData::GetValueClassInfo

wxClassInfo* GetValueClassInfo() const

If the data is a wxObject returns a pointer to the objects wxClassInfo structure, if the data isn't a wxObject the method returns NULL.


wxVariantData::IncRef

void IncRef()

Increases reference count. Note that initially wxVariantData has reference count of 1.


wxVariantData::Read

bool Read(ostream& stream)

bool Read(wxString& string)

Reads the data from stream or string.


wxVariantData::Write

bool Write(ostream& stream) const

bool Write(wxString& string) const

Writes the data to stream or string.


wxGetVariantCast

classname * wxGetVariantCast(wxVariant&, classname)

This macro returns the data stored in variant cast to the type classname * if the data is of this type (the check is done during the run-time) or NULL otherwise.

See also

RTTI overview
wxDynamicCast