2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: variant.h
|
|
|
|
// Purpose: documentation for wxVariant class
|
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxVariant
|
|
|
|
@wxheader{variant.h}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
The @b 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.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
As standard, wxVariant can store values of type bool, wxChar, double, long,
|
|
|
|
string,
|
2008-03-08 14:43:31 +00:00
|
|
|
string list, time, date, void pointer, list of strings, and list of variants.
|
2008-03-08 13:52:38 +00:00
|
|
|
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
|
|
|
|
wxVariant::GetLong can be used.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
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
|
2008-03-08 14:43:31 +00:00
|
|
|
type name (returned by wxVariant::GetType) and to perform
|
2008-03-08 13:52:38 +00:00
|
|
|
type-safety checks at runtime.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
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.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
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.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Note that as of wxWidgets 2.7.1, wxVariant is @ref overview_trefcount
|
2008-03-08 14:43:31 +00:00
|
|
|
"reference counted".
|
|
|
|
Additionally, the convenience macros @b DECLARE_VARIANT_OBJECT and
|
|
|
|
@b IMPLEMENT_VARIANT_OBJECT were added so that adding (limited) support
|
2008-03-08 13:52:38 +00:00
|
|
|
for conversion to and from wxVariant can be very easily implemented without
|
2008-03-08 14:43:31 +00:00
|
|
|
modifying
|
2008-03-08 13:52:38 +00:00
|
|
|
either wxVariant or the class to be stored by wxVariant. Since assignment
|
2008-03-08 14:43:31 +00:00
|
|
|
operators
|
2008-03-08 13:52:38 +00:00
|
|
|
cannot be declared outside the class, the shift left operators are used like
|
|
|
|
this:
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@code
|
|
|
|
// in the header file
|
|
|
|
DECLARE_VARIANT_OBJECT(MyClass)
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
// in the implementation file
|
|
|
|
IMPLEMENT_VARIANT_OBJECT(MyClass)
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
// in the user code
|
|
|
|
wxVariant variant;
|
|
|
|
MyClass value;
|
|
|
|
variant value;
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
// or
|
|
|
|
value variant;
|
|
|
|
@endcode
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
For this to work, MyClass must derive from wxObject, implement
|
|
|
|
the @ref overview_runtimeclassoverview "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:
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@code
|
|
|
|
IMPLEMENT_VARIANT_OBJECT(wxColour)
|
|
|
|
IMPLEMENT_VARIANT_OBJECT(wxImage)
|
|
|
|
IMPLEMENT_VARIANT_OBJECT(wxIcon)
|
|
|
|
IMPLEMENT_VARIANT_OBJECT(wxBitmap)
|
|
|
|
@endcode
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
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 Clone function for implementing the wxVariant::Unshare function.
|
|
|
|
Clone is implemented automatically by IMPLEMENT_VARIANT_OBJECT.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
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.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxbase}
|
|
|
|
@category{data}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@seealso
|
|
|
|
wxVariantData
|
|
|
|
*/
|
|
|
|
class wxVariant : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Construction from a ODBC timestamp value. Represented internally by a
|
|
|
|
wxDateTime value.
|
|
|
|
*/
|
|
|
|
wxVariant();
|
2008-03-08 14:43:31 +00:00
|
|
|
wxVariant(const wxVariant& variant);
|
|
|
|
wxVariant(const wxChar* value, const wxString& name = "");
|
|
|
|
wxVariant(const wxString& value, const wxString& name = "");
|
|
|
|
wxVariant(wxChar value, const wxString& name = "");
|
|
|
|
wxVariant(long value, const wxString& name = "");
|
|
|
|
wxVariant(bool value, const wxString& name = "");
|
|
|
|
wxVariant(double value, const wxString& name = "");
|
|
|
|
wxVariant(const wxVariantList& value,
|
|
|
|
const wxString& name = "");
|
|
|
|
wxVariant(void* value, const wxString& name = "");
|
|
|
|
wxVariant(wxObject* value, const wxString& name = "");
|
|
|
|
wxVariant(wxVariantData* data, const wxString& name = "");
|
|
|
|
wxVariant(wxDateTime& val, const wxString& name = "");
|
|
|
|
wxVariant(wxArrayString& val, const wxString& name = "");
|
|
|
|
wxVariant(DATE_STRUCT* val, const wxString& name = "");
|
|
|
|
wxVariant(TIME_STRUCT* val, const wxString& name = "");
|
|
|
|
wxVariant(TIMESTAMP_STRUCT* val, const wxString& name = "");
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
Note that destructor is protected, so wxVariantData cannot usually
|
|
|
|
be deleted. Instead, wxVariantData::DecRef should be called.
|
|
|
|
See @ref overview_refcountdestruct "reference-counted object destruction" for
|
|
|
|
more info.
|
|
|
|
*/
|
|
|
|
~wxVariant();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Appends a value to the list.
|
|
|
|
*/
|
|
|
|
void Append(const wxVariant& value);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Makes the variant null by deleting the internal data and
|
|
|
|
set the name to @e wxEmptyString.
|
|
|
|
*/
|
|
|
|
void Clear();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Deletes the contents of the list.
|
|
|
|
*/
|
|
|
|
void ClearList();
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Retrieves and converts the value of this variant to the type that @a value is.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool Convert(long* value) const;
|
|
|
|
const bool Convert(bool* value) const;
|
|
|
|
const bool Convert(double* value) const;
|
|
|
|
const bool Convert(wxString* value) const;
|
|
|
|
const bool Convert(wxChar* value) const;
|
|
|
|
const bool Convert(wxDateTime* value) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Deletes the zero-based @a item from the list.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool Delete(size_t item);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the string array value.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxArrayString GetArrayString() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the boolean value.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool GetBool() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the character value.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxChar GetChar() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the number of elements in the list.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
size_t GetCount() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
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 likewise called.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxVariantData* GetData() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the date value.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxDateTime GetDateTime() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the floating point value.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
double GetDouble() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a reference to the wxVariantList class used by
|
|
|
|
wxVariant if this wxVariant is currently a list of variants.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxVariantList GetList() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the integer value.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
long GetLong() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a constant reference to the variant name.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
const wxString GetName() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the string value.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString GetString() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the value type as a string. The built-in types are: bool, char,
|
|
|
|
datetime, double, list, long, string, arrstring, void*.
|
|
|
|
If the variant is null, the value type returned is the string "null" (not the
|
|
|
|
empty string).
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString GetType() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the void pointer value.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
void* GetVoidPtr() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the wxObject pointer value.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxObject* GetWxObjectPtr() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Inserts a value at the front of the list.
|
|
|
|
*/
|
|
|
|
void Insert(const wxVariant& value);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if there is no data associated with this variant, @false if there
|
|
|
|
is data.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool IsNull() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Returns @true if @a type matches the type of the variant, @false otherwise.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool IsType(const wxString& type) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the data is derived from the class described by @e type, @false
|
|
|
|
otherwise.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool IsValueKindOf(const wxClassInfo* type type) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Makes the variant null by deleting the internal data.
|
|
|
|
*/
|
|
|
|
void MakeNull();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Makes a string representation of the variant value (for any type).
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString MakeString() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Returns @true if @a value matches an element in the list.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool Member(const wxVariant& value) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
void NullList();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the internal variant data, deleting the existing data if there is any.
|
|
|
|
*/
|
|
|
|
void SetData(wxVariantData* data);
|
|
|
|
|
|
|
|
/**
|
|
|
|
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. Clone is implemented
|
|
|
|
for all the default data types.
|
|
|
|
*/
|
|
|
|
bool Unshare();
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Inequality test operators.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool operator !=(const wxVariant& value) const;
|
|
|
|
const bool operator !=(const wxString& value) const;
|
|
|
|
const bool operator !=(const wxChar* value) const;
|
|
|
|
const bool operator !=(wxChar value) const;
|
|
|
|
const bool operator !=(const long value) const;
|
|
|
|
const bool operator !=(const bool value) const;
|
|
|
|
const bool operator !=(const double value) const;
|
|
|
|
const bool operator !=(void* value) const;
|
|
|
|
const bool operator !=(wxObject* value) const;
|
|
|
|
const bool operator !=(const wxVariantList& value) const;
|
|
|
|
const bool operator !=(const wxArrayString& value) const;
|
|
|
|
const bool operator !=(const wxDateTime& value) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Assignment operators, using @ref overview_trefcount "reference counting" when
|
|
|
|
possible.
|
|
|
|
*/
|
|
|
|
void operator =(const wxVariant& value);
|
2008-03-08 14:43:31 +00:00
|
|
|
void operator =(wxVariantData* value);
|
|
|
|
void operator =(const wxString& value);
|
|
|
|
void operator =(const wxChar* value);
|
|
|
|
void operator =(wxChar value);
|
|
|
|
void operator =(const long value);
|
|
|
|
void operator =(const bool value);
|
|
|
|
void operator =(const double value);
|
|
|
|
void operator =(void* value);
|
|
|
|
void operator =(wxObject* value);
|
|
|
|
void operator =(const wxVariantList& value);
|
|
|
|
void operator =(const wxDateTime& value);
|
|
|
|
void operator =(const wxArrayString& value);
|
|
|
|
void operator =(const DATE_STRUCT* value);
|
|
|
|
void operator =(const TIME_STRUCT* value);
|
|
|
|
void operator =(const TIMESTAMP_STRUCT* value);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Equality test operators.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool operator ==(const wxVariant& value) const;
|
|
|
|
const bool operator ==(const wxString& value) const;
|
|
|
|
const bool operator ==(const wxChar* value) const;
|
|
|
|
const bool operator ==(wxChar value) const;
|
|
|
|
const bool operator ==(const long value) const;
|
|
|
|
const bool operator ==(const bool value) const;
|
|
|
|
const bool operator ==(const double value) const;
|
|
|
|
const bool operator ==(void* value) const;
|
|
|
|
const bool operator ==(wxObject* value) const;
|
|
|
|
const bool operator ==(const wxVariantList& value) const;
|
|
|
|
const bool operator ==(const wxArrayString& value) const;
|
|
|
|
const bool operator ==(const wxDateTime& value) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Returns a reference to the value at @a idx (zero-based). This can be used
|
2008-03-08 13:52:38 +00:00
|
|
|
to change the value at this index.
|
|
|
|
*/
|
|
|
|
wxVariant operator [](size_t idx);
|
2008-03-09 16:24:26 +00:00
|
|
|
const wxVariant& operator [](size_t idx);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Operator for implicit conversion to a long, using GetLong().
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
double operator double() const;
|
|
|
|
const long operator long() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Operator for implicit conversion to a pointer to a void, using GetVoidPtr().
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
void* operator void*() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Operator for implicit conversion to a wxChar, using GetChar().
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
char operator wxChar() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Operator for implicit conversion to a pointer to a wxDateTime, using
|
|
|
|
GetDateTime().
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
void* operator wxDateTime() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Operator for implicit conversion to a string, using MakeString().
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString operator wxString() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxVariantData
|
|
|
|
@wxheader{variant.h}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
|
|
|
The @b wxVariantData class is used to implement a new type for wxVariant.
|
2008-03-08 13:52:38 +00:00
|
|
|
Derive from wxVariantData, and override the pure virtual functions.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
wxVariantData is @ref overview_refcount "reference counted", but you don't
|
2008-03-08 14:43:31 +00:00
|
|
|
normally have to care about this,
|
2008-03-08 13:52:38 +00:00
|
|
|
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,
|
|
|
|
wxVariantData::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, wxVariantData::DecRef will delete the object automatically
|
|
|
|
when the reference count reaches zero.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxbase}
|
|
|
|
@category{FIXME}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@seealso
|
|
|
|
wxVariant
|
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
class wxVariantData
|
2008-03-08 13:52:38 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Default constructor.
|
|
|
|
*/
|
|
|
|
wxVariantData();
|
|
|
|
|
|
|
|
/**
|
|
|
|
This function can be overridden to clone the data.
|
|
|
|
Implement Clone if you wish wxVariant::Unshare to work
|
|
|
|
for your data. This function is implemented for all built-in data types.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxVariantData* Clone() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
void DecRef();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if this object is equal to @e data.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool Eq(wxVariantData& data) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the string type of the data.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString GetType() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
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.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxClassInfo* GetValueClassInfo() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Increases reference count. Note that initially wxVariantData has reference
|
|
|
|
count of 1.
|
|
|
|
*/
|
|
|
|
void IncRef();
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Reads the data from @a stream or @e string.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool Read(ostream& stream);
|
2008-03-08 14:43:31 +00:00
|
|
|
bool Read(wxString& string);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Writes the data to @a stream or @e string.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool Write(ostream& stream) const;
|
|
|
|
const bool Write(wxString& string) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
This macro returns the data stored in @e variant cast to the type @e classname
|
|
|
|
* if
|
|
|
|
the data is of this type (the check is done during the run-time) or
|
|
|
|
@NULL otherwise.
|
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
classname* wxGetVariantCast();
|
2008-03-08 13:52:38 +00:00
|
|
|
};
|