X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f1156cbb0db33e76e031d05c8823f5c27628b685..a7689c49fe02c0c065facf736ab28b19f5997b7c:/include/wx/any.h diff --git a/include/wx/any.h b/include/wx/any.h index aebc38df55..6e38772532 100644 --- a/include/wx/any.h +++ b/include/wx/any.h @@ -20,7 +20,7 @@ #include "wx/string.h" #include "wx/meta/if.h" #include "wx/typeinfo.h" - +#include "wx/list.h" // Size of the wxAny value buffer. enum @@ -104,7 +104,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. @@ -113,6 +113,10 @@ public: // FIXME-VC6: remove this hack when VC6 is no longer supported template bool CheckType(T* reserved = NULL) const; + +#if wxUSE_EXTENDED_RTTI + virtual const wxTypeInfo* GetTypeInfo() const = 0; +#endif private: }; @@ -215,7 +219,7 @@ public: static const T& GetValue(const wxAnyValueBuffer& buf) { - // Breaking this code into two lines should supress + // Breaking this code into two lines should suppress // GCC's 'type-punned pointer will break strict-aliasing rules' // warning. const T* value = reinterpret_cast(&buf.m_buffer[0]); @@ -314,6 +318,12 @@ public: { return Ops::GetValue(buf); } +#if wxUSE_EXTENDED_RTTI + virtual const wxTypeInfo* GetTypeInfo() const + { + return wxGetTypeInfo((T*)NULL); + } +#endif }; @@ -348,7 +358,7 @@ wxAnyValueTypeScopedPtr wxAnyValueTypeImpl::sm_instance = new wxAnyValueTypeI // Helper macro for using same base value type implementation for multiple // actual C++ data types. // -#define WX_ANY_DEFINE_SUB_TYPE(T, CLSTYPE) \ +#define _WX_ANY_DEFINE_SUB_TYPE(T, CLSTYPE) \ template<> \ class wxAnyValueTypeImpl : public wxAnyValueTypeImpl##CLSTYPE \ { \ @@ -369,9 +379,21 @@ public: \ const UseDataType* sptr = \ reinterpret_cast(voidPtr); \ return static_cast(*sptr); \ + } + +#if wxUSE_EXTENDED_RTTI +#define WX_ANY_DEFINE_SUB_TYPE(T, CLSTYPE) \ +_WX_ANY_DEFINE_SUB_TYPE(T, CLSTYPE)\ + virtual const wxTypeInfo* GetTypeInfo() const \ + { \ + return wxGetTypeInfo((T*)NULL); \ } \ }; - +#else +#define WX_ANY_DEFINE_SUB_TYPE(T, CLSTYPE) \ +_WX_ANY_DEFINE_SUB_TYPE(T, CLSTYPE)\ +}; +#endif // // Integer value types @@ -558,7 +580,7 @@ public: \ // (this is needed only for types that are referred to from wxBase. // currently we may not use any of these types from there, but let's // use the macro on at least one to make sure it compiles since we can't -// really test it properly in unittests since a separate DLL would +// really test it properly in unit tests since a separate DLL would // be needed). #if wxUSE_DATETIME #include "wx/datetime.h" @@ -806,7 +828,7 @@ public: } /** - Tests if wxAny is null (that is, whether there is data). + Tests if wxAny is null (that is, whether there is no data). */ bool IsNull() const { @@ -934,7 +956,7 @@ public: no type conversion is performed, so if the type is incorrect an assertion failure will occur. - @remarks For conveniency, conversion is done when T is wxString. This + @remarks For convenience, 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. @@ -967,11 +989,17 @@ public: return value; } +#if wxUSE_EXTENDED_RTTI + const wxTypeInfo* GetTypeInfo() const + { + return m_type->GetTypeInfo(); + } +#endif /** - Template function that etrieves and converts the value of this + Template function that retrieves and converts the value of this variant 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 @@ -1075,7 +1103,7 @@ inline bool wxAnyValueType::CheckType(T* reserved) const return wxAnyValueTypeImpl::IsSameClass(this); } - +WX_DECLARE_LIST_WITH_DECL(wxAny, wxAnyList, class WXDLLIMPEXP_BASE); #endif // wxUSE_ANY