wxVariant <-> wxAny conversion functionality. Includes implicit construction of wxAny from wxVariant, and vice versa. wxVariant->wxAny conversion is implemented by adding new virtual member function into wxVariantData. wxAny->wxVariant conversion is implemented by associating wxAnyValueTypes with functions that generate wxVariantData instances (using a hash map).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64000 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Jaakko Salli
2010-04-16 14:33:52 +00:00
parent 75504144d2
commit 0bf14ab8b1
7 changed files with 868 additions and 9 deletions

View File

@@ -13,9 +13,9 @@
The wxAny class represents a container for any type. Its value
can be changed at run time, possibly to a different type of value.
wxAny is a backwards incompatible successor class for wxVariant,
essentially doing the same thing in a more modern, template-based manner
and with transparent support for any user data type.
wxAny is a backwards-incompatible (but convertible) successor class for
wxVariant, essentially doing the same thing in a more modern, template-
based manner and with transparent support for any user data type.
Some pseudo-code'ish example of use with arbitrary user data:
@@ -87,6 +87,17 @@ public:
*/
wxAny(const wxAny& any);
/**
Constructs wxAny, converting value from wxVariant.
@remarks Because of this conversion, it is not usually possible to
have wxAny that actually holds a wxVariant. If wxVariant
cannot be converted to a specific data type, wxAny will then
hold and manage reference to wxVariantData* similar to how
wxVariant does.
*/
wxAny(const wxVariant& variant);
/**
Destructor.
*/
@@ -127,6 +138,16 @@ public:
template<typename T>
bool GetAs(T* value) const;
/**
Specialization of GetAs() that allows conversion of wxAny into
wxVariant.
@return Returns @true if conversion was successful. Conversion usually
only fails if variant used custom wxVariantData that did not
implement the wxAny to wxVariant conversion functions.
*/
bool GetAs(wxVariant* value) const;
/**
Returns the value type as wxAnyValueType instance.
@@ -154,6 +175,7 @@ public:
template<typename T>
wxAny& operator=(const T &value);
wxAny& operator=(const wxAny &any);
wxAny& operator=(const wxVariant &variant);
//@}
//@{