+ // Not implemented
+ return FALSE;
+}
+
+/*
+ * wxVariantDataDateTime
+ */
+
+class wxVariantDataDateTime: public wxVariantData
+{
+ DECLARE_DYNAMIC_CLASS(wxVariantDataDateTime)
+
+public:
+ wxVariantDataDateTime() { }
+ wxVariantDataDateTime(const wxDateTime& value) { m_value = value; }
+#if wxUSE_ODBC
+ wxVariantDataDateTime(const TIME_STRUCT* valptr)
+ { m_value = wxDateTime(valptr->hour, valptr->minute, valptr->second); }
+ wxVariantDataDateTime(const DATE_STRUCT* valptr)
+ { m_value = wxDateTime(valptr->day, (wxDateTime::Month) (valptr->month - 1),valptr->year); }
+ wxVariantDataDateTime(const TIMESTAMP_STRUCT* valptr)
+ { m_value = wxDateTime(valptr->day, (wxDateTime::Month) (valptr->month - 1), valptr->year,
+ valptr->hour, valptr->minute, valptr->second, valptr->fraction ); }
+#endif //ODBC
+
+ inline wxDateTime GetValue() const { return m_value; }
+ inline void SetValue(const wxDateTime& value) { m_value = value; }
+
+ virtual void Copy(wxVariantData& data);
+ 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 { return wxT("datetime"); };
+ virtual wxVariantData* Clone() { return new wxVariantDataDateTime; }
+
+protected:
+ wxDateTime m_value;
+};
+
+
+IMPLEMENT_DYNAMIC_CLASS(wxVariantDataDateTime, wxVariantData)
+
+void wxVariantDataDateTime::Copy(wxVariantData& data)
+{
+ wxASSERT_MSG( (data.GetType() == wxT("datetime")), wxT("wxVariantDataDateTime::Copy: Can't copy to this type of data") );
+
+ wxVariantDataDateTime& otherData = (wxVariantDataDateTime&) data;
+
+ otherData.m_value = m_value;
+}
+
+
+bool wxVariantDataDateTime::Eq(wxVariantData& data) const
+{
+ wxASSERT_MSG( (data.GetType() == wxT("datetime")), wxT("wxVariantDataDateTime::Eq: argument mismatch") );
+
+ wxVariantDataDateTime& otherData = (wxVariantDataDateTime&) data;
+
+ return (otherData.m_value == m_value);
+}
+
+
+#if wxUSE_STD_IOSTREAM
+bool wxVariantDataDateTime::Write(wxSTD ostream& str) const
+{
+ // Not implemented
+ return FALSE;
+}
+#endif
+
+
+bool wxVariantDataDateTime::Write(wxString& str) const
+{
+ str = m_value.Format();
+ return TRUE;
+}
+
+
+#if wxUSE_STD_IOSTREAM
+bool wxVariantDataDateTime::Read(wxSTD istream& WXUNUSED(str))
+{
+ // Not implemented
+ return FALSE;
+}
+#endif
+
+
+bool wxVariantDataDateTime::Read(wxString& str)
+{
+ if(! m_value.ParseDateTime(str))
+ return FALSE;
+ return TRUE;
+}
+
+// ----------------------------------------------------------------------------
+// wxVariantDataArrayString
+// ----------------------------------------------------------------------------
+
+class wxVariantDataArrayString: public wxVariantData
+{
+public:
+ wxVariantDataArrayString() { }
+ wxVariantDataArrayString(const wxArrayString& value) { m_value = value; }
+
+ wxArrayString GetValue() const { return m_value; }
+ void SetValue(const wxArrayString& value) { m_value = value; }
+
+ virtual void Copy(wxVariantData& data);
+ 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 { return wxT("arrstring"); };
+ virtual wxVariantData* Clone() { return new wxVariantDataArrayString; }
+
+protected:
+ wxArrayString m_value;
+
+ DECLARE_DYNAMIC_CLASS(wxVariantDataArrayString)
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxVariantDataArrayString, wxVariantData)
+
+void wxVariantDataArrayString::Copy(wxVariantData& data)
+{
+ wxASSERT_MSG( data.GetType() == GetType(), wxT("wxVariantDataArrayString::Copy: Can't copy to this type of data") );
+
+ wxVariantDataArrayString& otherData = (wxVariantDataArrayString&) data;
+
+ otherData.m_value = m_value;
+}
+
+
+bool wxVariantDataArrayString::Eq(wxVariantData& data) const
+{
+ wxASSERT_MSG( data.GetType() == GetType(), wxT("wxVariantDataArrayString::Eq: argument mismatch") );
+
+ wxVariantDataArrayString& otherData = (wxVariantDataArrayString&) data;
+
+ return otherData.m_value == m_value;
+}
+
+
+#if wxUSE_STD_IOSTREAM
+bool wxVariantDataArrayString::Write(wxSTD ostream& str) const
+{
+ // Not implemented
+ return FALSE;
+}
+#endif
+
+
+bool wxVariantDataArrayString::Write(wxString& str) const
+{
+ size_t count = m_value.GetCount();
+ for ( size_t n = 0; n < count; n++ )
+ {
+ if ( n )
+ str += _T(';');
+
+ str += m_value[n];
+ }
+
+ return TRUE;
+}
+
+
+#if wxUSE_STD_IOSTREAM
+bool wxVariantDataArrayString::Read(wxSTD istream& WXUNUSED(str))
+{
+ // Not implemented
+ return FALSE;
+}
+#endif
+
+
+bool wxVariantDataArrayString::Read(wxString& str)
+{
+ wxStringTokenizer tk(str, _T(";"));
+ while ( tk.HasMoreTokens() )
+ {
+ m_value.Add(tk.GetNextToken());
+ }
+
+ return TRUE;
+}
+
+
+
+/*
+ * wxVariant
+ */
+
+IMPLEMENT_DYNAMIC_CLASS(wxVariant, wxObject)
+
+// Construction & destruction
+wxVariant::wxVariant()
+{
+ m_data = (wxVariantData*) NULL;
+}
+
+wxVariant::wxVariant(double val, const wxString& name)
+{
+ m_data = new wxVariantDataReal(val);
+ m_name = name;
+}
+
+wxVariant::wxVariant(long val, const wxString& name)
+{
+ m_data = new wxVariantDataLong(val);
+ m_name = name;
+}
+
+#ifdef HAVE_BOOL
+wxVariant::wxVariant(bool val, const wxString& name)
+{
+ m_data = new wxVariantDataBool(val);
+ m_name = name;
+}
+#endif
+
+wxVariant::wxVariant(char val, const wxString& name)
+{
+ m_data = new wxVariantDataChar(val);
+ m_name = name;
+}
+
+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;
+}
+
+wxVariant::wxVariant(const wxStringList& val, const wxString& name)
+{
+ m_data = new wxVariantDataStringList(val);
+ m_name = name;
+}
+
+wxVariant::wxVariant(const wxList& val, const wxString& name) // List of variants
+{
+ m_data = new wxVariantDataList(val);
+ m_name = name;
+}
+
+// For some reason, Watcom C++ can't link variant.cpp with time/date classes compiled
+#if wxUSE_TIMEDATE && !defined(__WATCOMC__)
+wxVariant::wxVariant(const wxTime& val, const wxString& name) // Time
+{
+ m_data = new wxVariantDataTime(val);
+ m_name = name;
+}
+
+wxVariant::wxVariant(const wxDate& val, const wxString& name) // Date
+{
+ m_data = new wxVariantDataDate(val);
+ m_name = name;
+}
+#endif
+
+wxVariant::wxVariant(void* val, const wxString& name) // Void ptr
+{
+ m_data = new wxVariantDataVoidPtr(val);
+ m_name = name;
+}
+
+wxVariant::wxVariant(const wxDateTime& val, const wxString& name) // Date
+{
+ m_data = new wxVariantDataDateTime(val);
+ m_name = name;
+}
+
+#if wxUSE_ODBC
+wxVariant::wxVariant(const TIME_STRUCT* valptr, const wxString& name) // Date
+{
+ m_data = new wxVariantDataDateTime(valptr);
+ m_name = name;
+}
+
+wxVariant::wxVariant(const TIMESTAMP_STRUCT* valptr, const wxString& name) // Date
+{
+ m_data = new wxVariantDataDateTime(valptr);
+ m_name = name;
+}
+
+wxVariant::wxVariant(const DATE_STRUCT* valptr, const wxString& name) // Date
+{
+ m_data = new wxVariantDataDateTime(valptr);
+ m_name = name;
+}
+#endif // wxUSE_ODBC
+
+wxVariant::wxVariant(const wxArrayString& val, const wxString& name) // Strings
+{
+ m_data = new wxVariantDataArrayString(val);
+ m_name = name;
+}
+
+wxVariant::wxVariant(const wxVariant& variant)
+ : wxObject()
+{
+ if (!variant.IsNull())
+ {
+ m_data = (wxVariantData*) variant.GetData()->GetClassInfo()->CreateObject();
+ variant.m_data->Copy(*m_data);
+ }
+ else
+ m_data = (wxVariantData*) NULL;
+ m_name = variant.m_name;
+}
+
+wxVariant::wxVariant(wxVariantData* data, const wxString& name) // User-defined data
+{
+ m_data = data;
+ m_name = name;
+}
+
+wxVariant::~wxVariant()
+{
+ delete m_data;
+}
+
+
+// Make NULL (i.e. delete the data)
+void wxVariant::MakeNull()
+{
+ delete m_data;
+ m_data = NULL;
+}
+
+// Generic operators
+// Assignment
+void wxVariant::operator= (const wxVariant& variant)
+{
+ if (variant.IsNull())
+ {
+ MakeNull();
+ return;
+ }
+
+ if (IsNull() || (GetType() != variant.GetType()))
+ {
+ if (m_data)
+ delete m_data;
+ m_data = (wxVariantData*) variant.GetData()->GetClassInfo()->CreateObject();
+ }
+
+ variant.GetData()->Copy(* GetData());
+
+ m_name = variant.m_name;
+}
+
+// Assignment using data, e.g.
+// myVariant = new wxStringVariantData("hello")
+void wxVariant::operator= (wxVariantData* variantData)
+{
+ MakeNull();
+ m_data = variantData;
+}
+
+bool wxVariant::operator== (const wxVariant& variant) const
+{
+ if (IsNull() || variant.IsNull())
+ return (IsNull() == variant.IsNull());
+
+ return (GetData()->Eq(* variant.GetData()));
+}
+
+bool wxVariant::operator!= (const wxVariant& variant) const
+{
+ return (!(*this == variant));