X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/530ecef01f7e33c2ec1b8b1ad8025484709bef1d..cbc9145c04bd3ea0a228906c8363fa8f47e3acf9:/src/common/variant.cpp?ds=inline diff --git a/src/common/variant.cpp b/src/common/variant.cpp index a45b3d7489..b17b2c1f66 100644 --- a/src/common/variant.cpp +++ b/src/common/variant.cpp @@ -18,8 +18,11 @@ #include "wx/variant.h" +#if wxUSE_VARIANT + #ifndef WX_PRECOMP #include "wx/string.h" + #include "wx/math.h" #if wxUSE_STREAMS #include "wx/stream.h" #endif @@ -44,7 +47,6 @@ using namespace std ; #include "wx/string.h" #include "wx/tokenzr.h" -#include "wx/math.h" IMPLEMENT_ABSTRACT_CLASS(wxVariantData, wxObject) @@ -60,7 +62,7 @@ DECLARE_DYNAMIC_CLASS(wxVariantDataList) public: wxVariantDataList() {} wxVariantDataList(const wxList& list); - ~wxVariantDataList(); + virtual ~wxVariantDataList(); wxList& GetValue() { return m_value; } void SetValue(const wxList& value) ; @@ -738,7 +740,7 @@ public: virtual bool Read(wxString& str); virtual bool Write(wxString& str) const; #if wxUSE_STD_IOSTREAM - virtual bool Read(wxSTD istream& str); + virtual bool Read(wxSTD istream& WXUNUSED(str)) { return false; }; #endif #if wxUSE_STREAMS virtual bool Read(wxInputStream& str); @@ -782,14 +784,6 @@ bool wxVariantDataString::Write(wxString& str) const return true; } -#if wxUSE_STD_IOSTREAM -bool wxVariantDataString::Read(wxSTD istream& str) -{ - str >> m_value; - return true; -} -#endif - #if wxUSE_STREAMS bool wxVariantDataString::Write(wxOutputStream& str) const { @@ -985,7 +979,7 @@ bool wxVariantDataWxObjectPtr::Write(wxSTD ostream& str) const bool wxVariantDataWxObjectPtr::Write(wxString& str) const { - str.Printf(wxT("%s(%p)"), GetType().c_str(), m_value); + str.Printf(wxT("%s(%p)"), GetType().c_str(), wx_static_cast(void*, m_value)); return true; } @@ -1634,6 +1628,23 @@ void wxVariant::operator= (void* value) } } +bool wxVariant::operator== (wxObject* value) const +{ + return (value == ((wxVariantDataWxObjectPtr*)GetData())->GetValue()); +} + +bool wxVariant::operator!= (wxObject* value) const +{ + return (!((*this) == (void*) value)); +} + +void wxVariant::operator= (wxObject* value) +{ + if (m_data) + delete m_data; + m_data = new wxVariantDataWxObjectPtr(value); +} + #if wxUSE_DATETIME bool wxVariant::operator== (const wxDateTime& value) const { @@ -1900,7 +1911,7 @@ void* wxVariant::GetVoidPtr() const return (void*) ((wxVariantDataVoidPtr*) m_data)->GetValue(); } -wxObject* wxVariant::GetWxObjectPtr() +wxObject* wxVariant::GetWxObjectPtr() const { wxASSERT(wxIsKindOf(m_data, wxVariantDataWxObjectPtr)); return (wxObject*) ((wxVariantDataWxObjectPtr*) m_data)->GetValue(); @@ -2108,6 +2119,8 @@ bool wxVariant::Convert(wxDateTime* value) const // Fallback to string conversion wxString val; return Convert(&val) && - (value->ParseDateTime(val) || value->ParseDate(val)); + (value->ParseDateTime(val) || value->ParseDate(val) || value->ParseTime(val)); } #endif // wxUSE_DATETIME + +#endif // wxUSE_VARIANT