X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/39601a7f74796aae377ad1520595f083fdafd7b6..7f4f5e8c24607ead9b5e2f4c60658dcd61f028f4:/interface/wx/any.h?ds=sidebyside diff --git a/interface/wx/any.h b/interface/wx/any.h index acbd9157a2..2a8a22c3e6 100644 --- a/interface/wx/any.h +++ b/interface/wx/any.h @@ -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 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: @@ -66,7 +66,7 @@ @library{wxbase} @category{data} - @see wxAnyValueType, wxVariant + @see wxAnyValueType, wxVariant, @ref overview_cpp_rtti_disabled */ class wxAny { @@ -87,20 +87,34 @@ 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. */ ~wxAny(); /** - This template function converts wxAny into given type. No dynamic - conversion is performed, so if the type is incorrect an assertion - failure will occur in debug builds, and a bogus value is returned - in release ones. + This template function converts wxAny into given type. In most cases + no type conversion is performed, so if the type is incorrect an + assertion failure will occur. - @remarks This template function may not work properly with Visual C++ - 6. For full compiler compatibility, please use - wxANY_AS(any, T) macro instead. + @remarks For conveniency, conversion is done when T is wxString. This + is useful when a string literal (which are treated as + const char* and const wchar_t*) has been assigned to wxAny. + + This template function may not work properly with Visual C++ + 6. For full compiler compatibility, please use + wxANY_AS(any, T) macro instead. */ template T As() const; @@ -122,11 +136,21 @@ public: Template function that retrieves and converts the value of this wxAny to the type that T* value is. - @return Returns @true if conversion was succesfull. + @return Returns @true if conversion was successful. */ template 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 +178,7 @@ public: template wxAny& operator=(const T &value); wxAny& operator=(const wxAny &any); + wxAny& operator=(const wxVariant &variant); //@} //@{ @@ -321,6 +346,8 @@ union wxAnyValueBuffer wxAnyValueBuffer& dst) const { // TODO: Copy value from one buffer to another. + // dst is already uninitialized and does not + // need to be freed. } virtual bool ConvertValue(const wxAnyValueBuffer& src, @@ -376,7 +403,7 @@ public: a specific C++ data type. @remarks This template function does not work on some older compilers - (such as Visual C++ 6.0). For full compiler ccompatibility + (such as Visual C++ 6.0). For full compiler compatibility please use wxANY_VALUE_TYPE_CHECK_TYPE(valueTypePtr, T) macro instead. @@ -394,9 +421,14 @@ public: wxAnyValueBuffer& dst) const = 0; /** - Implement this for buffer-to-buffer copy. src.m_ptr can - be expected to be NULL if value type of previously stored - data was different. + Implement this for buffer-to-buffer copy. + + @param src + This is the source data buffer. + + @param dst + This is the destination data buffer that is in either + uninitialized or freed state. */ virtual void CopyBuffer(const wxAnyValueBuffer& src, wxAnyValueBuffer& dst) const = 0; @@ -407,11 +439,6 @@ public: */ virtual void DeleteValue(wxAnyValueBuffer& buf) const = 0; - /** - This function is used for internal type matching. - */ - virtual wxAnyClassInfo GetClassInfo() const = 0; - /** This function is used for internal type matching. */