-
- 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)
-{
- 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();
- }
-// GetData()->Copy(* variant.GetData());
- variant.GetData()->Copy(* GetData());
-}
-
-// 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));
-}
-
-
-// Specific operators
-bool wxVariant::operator== (double value) const
-{
- double thisValue;
- if (!Convert(&thisValue))
- return FALSE;
- else
- return (value == thisValue);
-}
-
-bool wxVariant::operator!= (double value) const
-{
- return (!((*this) == value));
-}
-
-void wxVariant::operator= (double value)
-{
- if (GetType() == wxT("double"))
- {
- ((wxVariantDataReal*)GetData())->SetValue(value);
- }
- else
- {
- if (m_data)
- delete m_data;
- m_data = new wxVariantDataReal(value);
- }
-}
-
-bool wxVariant::operator== (long value) const
-{
- long thisValue;
- if (!Convert(&thisValue))
- return FALSE;
- else
- return (value == thisValue);
-}
-
-bool wxVariant::operator!= (long value) const
-{
- return (!((*this) == value));
-}
-
-void wxVariant::operator= (long value)
-{
- if (GetType() == wxT("long"))
- {
- ((wxVariantDataLong*)GetData())->SetValue(value);
- }
- else
- {
- if (m_data)
- delete m_data;
- m_data = new wxVariantDataLong(value);
- }
-}
-
-bool wxVariant::operator== (char value) const
-{
- char thisValue;
- if (!Convert(&thisValue))
- return FALSE;
- else
- return (value == thisValue);
-}
-
-bool wxVariant::operator!= (char value) const
-{
- return (!((*this) == value));
-}
-
-void wxVariant::operator= (char value)
-{
- if (GetType() == wxT("char"))
- {
- ((wxVariantDataChar*)GetData())->SetValue(value);
- }
- else
- {
- if (m_data)
- delete m_data;
- m_data = new wxVariantDataChar(value);
- }
-}
-
-#ifdef HAVE_BOOL
-bool wxVariant::operator== (bool value) const
-{
- bool thisValue;
- if (!Convert(&thisValue))
- return FALSE;
- else
- return (value == thisValue);
-}
-
-bool wxVariant::operator!= (bool value) const
-{
- return (!((*this) == value));
-}
-
-void wxVariant::operator= (bool value)
-{
- if (GetType() == wxT("bool"))
- {
- ((wxVariantDataBool*)GetData())->SetValue(value);
- }
- else
- {
- if (m_data)
- delete m_data;
- m_data = new wxVariantDataBool(value);
- }
-}
-#endif // HAVE_BOOL
-
-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"))
- {
- ((wxVariantDataString*)GetData())->SetValue(value);
- }
- else
- {
- if (m_data)
- delete m_data;
- m_data = new wxVariantDataString(value);
- }
-}
-
-void wxVariant::operator= (const wxChar* value)
-{
- if (GetType() == wxT("string"))
- {
- ((wxVariantDataString*)GetData())->SetValue(wxString(value));
- }
- else
- {
- if (m_data)
- delete m_data;
- m_data = new wxVariantDataString(wxString(value));
- }
-}
-
-bool wxVariant::operator== (const wxStringList& value) const
-{
- wxASSERT_MSG( (GetType() == wxT("stringlist")), wxT("Invalid type for == operator") );
-
- wxVariantDataStringList other(value);
- return (m_data->Eq(other));
-}
-
-bool wxVariant::operator!= (const wxStringList& value) const
-{
- return (!((*this) == value));
-}
-
-void wxVariant::operator= (const wxStringList& value)
-{
- if (GetType() == wxT("stringlist"))
- {
- ((wxVariantDataStringList*)GetData())->SetValue(value);
- }
- else
- {
- if (m_data)
- delete m_data;
- m_data = new wxVariantDataStringList(value);
- }
-}
-
-bool wxVariant::operator== (const wxList& value) const
-{
- wxASSERT_MSG( (GetType() == wxT("list")), wxT("Invalid type for == operator") );
-
- wxVariantDataList other(value);
- return (m_data->Eq(other));
-}
-
-bool wxVariant::operator!= (const wxList& value) const
-{
- return (!((*this) == value));
-}
-
-void wxVariant::operator= (const wxList& value)
-{
- if (GetType() == wxT("list"))
- {
- ((wxVariantDataList*)GetData())->SetValue(value);
- }
- else
- {
- if (m_data)
- delete m_data;
- m_data = new wxVariantDataList(value);
- }
-}
-
-// For some reason, Watcom C++ can't link variant.cpp with time/date classes compiled
-#if wxUSE_TIMEDATE && !defined(__WATCOMC__)
-bool wxVariant::operator== (const wxTime& value) const
-{
- wxTime thisValue;
- if (!Convert(&thisValue))
- return FALSE;
-
- return value == thisValue;
-}
-
-bool wxVariant::operator!= (const wxTime& value) const
-{
- return (!((*this) == value));
-}
-
-void wxVariant::operator= (const wxTime& value)
-{
- if (GetType() == wxT("time"))
- {
- ((wxVariantDataTime*)GetData())->SetValue(value);
- }
- else
- {
- if (m_data)
- delete m_data;
- m_data = new wxVariantDataTime(value);
- }
-}
-
-bool wxVariant::operator== (const wxDate& value) const
-{
- wxDate thisValue;
- if (!Convert(&thisValue))
- return FALSE;
-
- return (value == thisValue);
-}
-
-bool wxVariant::operator!= (const wxDate& value) const
-{
- return (!((*this) == value));
-}
-
-void wxVariant::operator= (const wxDate& value)
-{
- if (GetType() == wxT("date"))
- {
- ((wxVariantDataTime*)GetData())->SetValue(value);
- }
- else
- {
- if (m_data)
- delete m_data;
- m_data = new wxVariantDataDate(value);
- }
-}
-#endif
-
-bool wxVariant::operator== (void* value) const
-{
- return (value == ((wxVariantDataVoidPtr*)GetData())->GetValue());
-}
-
-bool wxVariant::operator!= (void* value) const
-{
- return (!((*this) == (void*) value));
-}
-
-void wxVariant::operator= (void* value)
-{
- if (GetType() == wxT("void*"))
- {
- ((wxVariantDataVoidPtr*)GetData())->SetValue(value);
- }
- else
- {
- if (m_data)
- delete m_data;
- m_data = new wxVariantDataVoidPtr(value);
- }
-}
-
-bool wxVariant::operator== (const wxDateTime& value) const
-{
- wxDateTime thisValue;
- if (!Convert(&thisValue))
- return FALSE;
-
- return value.IsEqualTo(thisValue);
-}
-
-bool wxVariant::operator!= (const wxDateTime& value) const
-{
- return (!((*this) == value));
-}
-
-void wxVariant::operator= (const wxDateTime& value)
-{
- if (GetType() == wxT("datetime"))
- {
- ((wxVariantDataDateTime*)GetData())->SetValue(value);
- }
- else
- {
- if (m_data)
- delete m_data;
- m_data = new wxVariantDataDateTime(value);
- }