- 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);
- }
-}
-
-#if wxUSE_ODBC
-void wxVariant::operator= (const DATE_STRUCT* value)
-{
- if (m_data)
- delete m_data;
- m_data = new wxVariantDataDateTime(value);
-}
-
-
-void wxVariant::operator= (const TIME_STRUCT* value)
-{
- if (m_data)
- delete m_data;
- m_data = new wxVariantDataDateTime(value);
-}
-
-
-void wxVariant::operator= (const TIMESTAMP_STRUCT* value)
-{
- if (m_data)
- delete m_data;
- m_data = new wxVariantDataDateTime(value);
-}
-
-#endif // wxUSE_ODBC
-
-bool wxVariant::operator==(const wxArrayString& WXUNUSED(value)) const
-{
- wxFAIL_MSG( _T("TODO") );
-
- return false;
-}
-
-bool wxVariant::operator!=(const wxArrayString& value) const
-{
- return !(*this == value);
-}
-
-void wxVariant::operator=(const wxArrayString& value)
-{
- if (GetType() == wxT("arrstring"))
- {
- ((wxVariantDataArrayString *)GetData())->SetValue(value);
- }
- else
- {
- delete m_data;
- m_data = new wxVariantDataArrayString(value);
- }
-}
-
-wxArrayString wxVariant::GetArrayString() const
-{
- if ( GetType() == wxT("arrstring") )
- return ((wxVariantDataArrayString *)GetData())->GetValue();
-
- return wxArrayString();
-}
-
-
-// Treat a list variant as an array
-wxVariant wxVariant::operator[] (size_t idx) const
-{
- wxASSERT_MSG( (GetType() == wxT("list") || GetType() == wxT("stringlist")), wxT("Invalid type for array operator") );
-
- if (GetType() == wxT("list"))
- {
- wxVariantDataList* data = (wxVariantDataList*) m_data;
- wxASSERT_MSG( (idx < (size_t) data->GetValue().GetCount()), wxT("Invalid index for array") );
- return * (wxVariant*) (data->GetValue().Item(idx)->GetData());
- }
- else if (GetType() == wxT("stringlist"))
- {
- wxVariantDataStringList* data = (wxVariantDataStringList*) m_data;
- wxASSERT_MSG( (idx < (size_t) data->GetValue().GetCount()), wxT("Invalid index for array") );
-
- wxVariant variant( wxString( (wxChar*) (data->GetValue().Item(idx)->GetData()) ));
- return variant;
- }
- return wxNullVariant;
-}
-
-wxVariant& wxVariant::operator[] (size_t idx)
-{
- // We can't return a reference to a variant for a string list, since the string
- // is actually stored as a char*, not a variant.
-
- wxASSERT_MSG( (GetType() == wxT("list")), wxT("Invalid type for array operator") );
-
- wxVariantDataList* data = (wxVariantDataList*) m_data;
- wxASSERT_MSG( (idx < (size_t) data->GetValue().GetCount()), wxT("Invalid index for array") );
-
- return * (wxVariant*) (data->GetValue().Item(idx)->GetData());
-}
-
-// Return the number of elements in a list
-int wxVariant::GetCount() const
-{
- wxASSERT_MSG( (GetType() == wxT("list") || GetType() == wxT("stringlist")), wxT("Invalid type for GetCount()") );
-
- if (GetType() == wxT("list"))
- {
- wxVariantDataList* data = (wxVariantDataList*) m_data;
- return data->GetValue().GetCount();
- }
- else if (GetType() == wxT("stringlist"))
- {
- wxVariantDataStringList* data = (wxVariantDataStringList*) m_data;
- return data->GetValue().GetCount();
- }
- return 0;
-}
-
-wxString wxVariant::MakeString() const
-{
- if (!IsNull())
- {
- wxString str;
- if (GetData()->Write(str))
- return str;
- }
- return wxString(wxT(""));
-}
-
-// Accessors
-
-void wxVariant::SetData(wxVariantData* data)
-{
- if (m_data) delete m_data;
- m_data = data;
-}
-
-
-// Returns a string representing the type of the variant,
-// e.g. "string", "bool", "stringlist", "list", "double", "long"
-wxString wxVariant::GetType() const
-{
- if (IsNull())
- return wxString(wxT("null"));
- else
- return m_data->GetType();
-}
-
-
-bool wxVariant::IsType(const wxString& type) const
-{
- return (GetType() == type);
-}
-
-
-// Value accessors
-double wxVariant::GetReal() const
-{
- double value;
- if (Convert(& value))
- return value;
- else
- {
- wxFAIL_MSG(wxT("Could not convert to a real number"));
- return 0.0;
- }
-}
-
-long wxVariant::GetInteger() const
-{
- long value;
- if (Convert(& value))
- return value;
- else
- {
- wxFAIL_MSG(wxT("Could not convert to an integer"));
- return 0;
- }
-}
-
-char wxVariant::GetChar() const
-{
- char value;
- if (Convert(& value))
- return value;
- else
- {
- wxFAIL_MSG(wxT("Could not convert to a char"));
- return 0;
- }
-}
-
-bool wxVariant::GetBool() const
-{
- bool value;
- if (Convert(& value))
- return value;
- else
- {
- wxFAIL_MSG(wxT("Could not convert to a bool"));
- return 0;
- }
-}
-
-wxString wxVariant::GetString() const
-{
- wxString value;
- if (!Convert(& value))
- {
- wxFAIL_MSG(wxT("Could not convert to a string"));
- }
-
- return value;