+bool wxVariantDataChar::Eq(wxVariantData& data) const
+{
+ wxASSERT_MSG( (data.GetType() == wxT("char")), wxT("wxVariantDataChar::Eq: argument mismatch") );
+
+ wxVariantDataChar& otherData = (wxVariantDataChar&) data;
+
+ return (otherData.m_value == m_value);
+}
+
+#if wxUSE_STD_IOSTREAM
+bool wxVariantDataChar::Write(wxSTD ostream& str) const
+{
+ wxString s;
+ Write(s);
+ str << (const char*) s.mb_str();
+ return true;
+}
+#endif
+
+bool wxVariantDataChar::Write(wxString& str) const
+{
+ str.Printf(wxT("%c"), m_value);
+ return true;
+}
+
+#if wxUSE_STD_IOSTREAM
+bool wxVariantDataChar::Read(wxSTD istream& WXUNUSED(str))
+{
+ wxFAIL_MSG(wxT("Unimplemented"));
+
+ return false;
+}
+#endif
+
+#if wxUSE_STREAMS
+bool wxVariantDataChar::Write(wxOutputStream& str) const
+{
+ wxTextOutputStream s(str);
+
+ s << m_value;
+
+ return true;
+}
+
+bool wxVariantDataChar::Read(wxInputStream& str)
+{
+ wxTextInputStream s(str);
+
+ s >> m_value;
+
+ return true;
+}
+#endif // wxUSE_STREAMS
+
+bool wxVariantDataChar::Read(wxString& str)
+{
+ m_value = str[size_t(0)];
+ return true;
+}
+
+wxVariant::wxVariant(wxChar val, const wxString& name)
+{
+ m_data = new wxVariantDataChar(val);
+ m_name = name;
+}
+
+bool wxVariant::operator== (wxChar value) const
+{
+ wxChar thisValue;
+ if (!Convert(&thisValue))
+ return false;
+ else
+ return (value == thisValue);
+}
+
+bool wxVariant::operator!= (wxChar value) const
+{
+ return (!((*this) == value));
+}
+
+void wxVariant::operator= (wxChar value)
+{
+ if (GetType() == wxT("char") &&
+ m_data->GetRefCount() == 1)
+ {
+ ((wxVariantDataChar*)GetData())->SetValue(value);
+ }
+ else
+ {
+ UnRef();
+ m_data = new wxVariantDataChar(value);
+ }
+}
+
+wxChar wxVariant::GetChar() const
+{
+ wxChar value;
+ if (Convert(& value))
+ return value;
+ else
+ {
+ wxFAIL_MSG(wxT("Could not convert to a char"));
+ return 0;
+ }
+}
+
+// ----------------------------------------------------------------------------
+// wxVariantDataString
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_BASE wxVariantDataString: public wxVariantData
+{
+DECLARE_DYNAMIC_CLASS(wxVariantDataString)
+public:
+ wxVariantDataString() { }
+ wxVariantDataString(const wxString& value) { m_value = value; }
+
+ inline wxString GetValue() const { return m_value; }
+ inline void SetValue(const wxString& value) { m_value = value; }
+
+ virtual bool Eq(wxVariantData& data) const;
+#if wxUSE_STD_IOSTREAM
+ virtual bool Write(wxSTD ostream& str) const;
+#endif
+ virtual bool Read(wxString& str);
+ virtual bool Write(wxString& str) const;
+#if wxUSE_STD_IOSTREAM
+ virtual bool Read(wxSTD istream& WXUNUSED(str)) { return false; };
+#endif
+#if wxUSE_STREAMS
+ virtual bool Read(wxInputStream& str);
+ virtual bool Write(wxOutputStream& str) const;
+#endif // wxUSE_STREAMS
+ virtual wxString GetType() const { return wxT("string"); };
+
+protected:
+ wxString m_value;
+};
+
+bool wxVariantDataString::Eq(wxVariantData& data) const
+{
+ wxASSERT_MSG( (data.GetType() == wxT("string")), wxT("wxVariantDataString::Eq: argument mismatch") );
+
+ wxVariantDataString& otherData = (wxVariantDataString&) data;
+
+ return (otherData.m_value == m_value);
+}
+
+#if wxUSE_STD_IOSTREAM
+bool wxVariantDataString::Write(wxSTD ostream& str) const
+{
+ str << (const char*) m_value.mb_str();
+ return true;
+}
+#endif
+
+bool wxVariantDataString::Write(wxString& str) const
+{
+ str = m_value;
+ return true;
+}
+
+#if wxUSE_STREAMS
+bool wxVariantDataString::Write(wxOutputStream& str) const
+{
+ // why doesn't wxOutputStream::operator<< take "const wxString&"
+ wxTextOutputStream s(str);
+ s.WriteString(m_value);
+ return true;
+}
+
+bool wxVariantDataString::Read(wxInputStream& str)
+{
+ wxTextInputStream s(str);
+
+ m_value = s.ReadLine();
+ return true;
+}
+#endif // wxUSE_STREAMS
+
+bool wxVariantDataString::Read(wxString& str)
+{
+ m_value = str;
+ return true;
+}
+
+IMPLEMENT_DYNAMIC_CLASS(wxVariantDataString, wxVariantData)
+
+// wxVariant ****
+
+wxVariant::wxVariant(const wxString& val, const wxString& name)
+{
+ m_data = new wxVariantDataString(val);
+ m_name = name;
+}
+
+wxVariant::wxVariant(const wxChar* val, const wxString& name)
+{
+ m_data = new wxVariantDataString(wxString(val));
+ m_name = name;
+}
+
+bool wxVariant::operator== (const wxString& value) const
+{
+ wxString thisValue;
+ if (!Convert(&thisValue))
+ return false;
+
+ return value == thisValue;
+}
+
+bool wxVariant::operator!= (const wxString& value) const
+{
+ return (!((*this) == value));
+}
+
+void wxVariant::operator= (const wxString& value)
+{
+ if (GetType() == wxT("string") &&
+ m_data->GetRefCount() == 1)
+ {
+ ((wxVariantDataString*)GetData())->SetValue(value);
+ }
+ else
+ {
+ UnRef();
+ m_data = new wxVariantDataString(value);
+ }
+}
+
+void wxVariant::operator= (const wxChar* value)
+{
+ if (GetType() == wxT("string") &&
+ m_data->GetRefCount() == 1)
+ {
+ ((wxVariantDataString*)GetData())->SetValue(wxString(value));
+ }
+ else
+ {
+ UnRef();
+ m_data = new wxVariantDataString(wxString(value));
+ }
+}
+
+wxString wxVariant::GetString() const
+{
+ wxString value;
+ if (!Convert(& value))
+ {
+ wxFAIL_MSG(wxT("Could not convert to a string"));
+ }
+
+ return value;
+}
+
+// ----------------------------------------------------------------------------
+// wxVariantDataWxObjectPtr
+// ----------------------------------------------------------------------------
+
+class wxVariantDataWxObjectPtr: public wxVariantData
+{
+DECLARE_DYNAMIC_CLASS(wxVariantDataWxObjectPtr)
+public:
+ wxVariantDataWxObjectPtr() { }
+ wxVariantDataWxObjectPtr(wxObject* value) { m_value = value; }
+
+ inline wxObject* GetValue() const { return m_value; }
+ inline void SetValue(wxObject* value) { m_value = value; }
+
+ virtual bool Eq(wxVariantData& data) const;
+#if wxUSE_STD_IOSTREAM
+ virtual bool Write(wxSTD ostream& str) const;
+#endif
+ virtual bool Write(wxString& str) const;
+#if wxUSE_STD_IOSTREAM
+ virtual bool Read(wxSTD istream& str);
+#endif
+ virtual bool Read(wxString& str);
+ virtual wxString GetType() const ;
+ virtual wxVariantData* Clone() { return new wxVariantDataWxObjectPtr; }
+
+ virtual wxClassInfo* GetValueClassInfo() ;
+protected:
+ wxObject* m_value;
+
+ DECLARE_NO_COPY_CLASS(wxVariantDataWxObjectPtr)
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxVariantDataWxObjectPtr, wxVariantData)
+
+bool wxVariantDataWxObjectPtr::Eq(wxVariantData& data) const
+{
+ wxASSERT_MSG( wxIsKindOf((&data), wxVariantDataWxObjectPtr), wxT("wxVariantDataWxObjectPtr::Eq: argument mismatch") );
+
+ wxVariantDataWxObjectPtr& otherData = (wxVariantDataWxObjectPtr&) data;
+
+ return (otherData.m_value == m_value);
+}
+
+wxString wxVariantDataWxObjectPtr::GetType() const
+{
+ wxString returnVal(wxT("wxObject"));
+ if (m_value) {
+ returnVal = m_value->GetClassInfo()->GetClassName();
+ }
+ return returnVal;
+}
+
+wxClassInfo* wxVariantDataWxObjectPtr::GetValueClassInfo()
+{
+ wxClassInfo* returnVal=NULL;
+
+ if (m_value) returnVal = m_value->GetClassInfo();
+
+ return returnVal;
+}
+
+#if wxUSE_STD_IOSTREAM
+bool wxVariantDataWxObjectPtr::Write(wxSTD ostream& str) const
+{
+ wxString s;
+ Write(s);
+ str << (const char*) s.mb_str();
+ return true;
+}
+#endif
+
+bool wxVariantDataWxObjectPtr::Write(wxString& str) const