X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f41d5991df3be094fbedc5eb8fd51c87dc0a8aaa..6f41c10973643552837c6bd38b23779e65a2eaa3:/include/wx/any.h?ds=inline diff --git a/include/wx/any.h b/include/wx/any.h index 614cb09db7..6e38772532 100644 --- a/include/wx/any.h +++ b/include/wx/any.h @@ -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: }; @@ -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 @@ -967,6 +989,12 @@ public: return value; } +#if wxUSE_EXTENDED_RTTI + const wxTypeInfo* GetTypeInfo() const + { + return m_type->GetTypeInfo(); + } +#endif /** Template function that retrieves and converts the value of this variant to the type that T* value is. @@ -1007,15 +1035,12 @@ private: // Assignment functions void AssignAny(const wxAny& any) { - if ( m_type != wxAnyNullValueType ) - { - // Must delete value - CopyBuffer() never does that - m_type->DeleteValue(m_buffer); - } + // Must delete value - CopyBuffer() never does that + m_type->DeleteValue(m_buffer); wxAnyValueType* newType = any.m_type; - if ( m_type == wxAnyNullValueType || !newType->IsSameType(m_type) ) + if ( !newType->IsSameType(m_type) ) m_type = newType; newType->CopyBuffer(any.m_buffer, m_buffer);