bool wxVariantDataList::Write(wxString& str) const
{
- str = wxT("");
+ str = wxEmptyString;
wxList::compatibility_iterator node = m_value.GetFirst();
while (node)
{
// TODO
return false;
}
+#if WXWIN_COMPATIBILITY_2_4
/*
* wxVariantDataStringList
return false;
}
+#endif //2.4 compat
+
/*
* wxVariantDataLong
*/
#if wxUSE_STD_IOSTREAM
-bool wxVariantDataDateTime::Write(wxSTD ostream& str) const
+bool wxVariantDataDateTime::Write(wxSTD ostream& WXUNUSED(str)) const
{
// Not implemented
return false;
#if wxUSE_STD_IOSTREAM
-bool wxVariantDataArrayString::Write(wxSTD ostream& str) const
+bool wxVariantDataArrayString::Write(wxSTD ostream& WXUNUSED(str)) const
{
// Not implemented
return false;
m_name = name;
}
+#if WXWIN_COMPATIBILITY_2_4
+
wxVariant::wxVariant(const wxStringList& val, const wxString& name)
{
m_data = new wxVariantDataStringList(val);
m_name = name;
}
+#endif
+
wxVariant::wxVariant(const wxList& val, const wxString& name) // List of variants
{
m_data = new wxVariantDataList(val);
}
}
+#if WXWIN_COMPATIBILITY_2_4
+
bool wxVariant::operator== (const wxStringList& value) const
{
wxASSERT_MSG( (GetType() == wxT("stringlist")), wxT("Invalid type for == operator") );
bool wxVariant::operator!= (const wxStringList& value) const
{
- return (!((*this) == value));
+ wxASSERT_MSG( (GetType() == wxT("stringlist")), wxT("Invalid type for == operator") );
+
+ wxVariantDataStringList other(value);
+ return !(m_data->Eq(other));
}
void wxVariant::operator= (const wxStringList& value)
}
}
+#endif
+
bool wxVariant::operator== (const wxList& value) const
{
wxASSERT_MSG( (GetType() == wxT("list")), wxT("Invalid type for == operator") );
// Treat a list variant as an array
wxVariant wxVariant::operator[] (size_t idx) const
{
+#if WXWIN_COMPATIBILITY_2_4
wxASSERT_MSG( (GetType() == wxT("list") || GetType() == wxT("stringlist")), wxT("Invalid type for array operator") );
+#else
+ wxASSERT_MSG( GetType() == wxT("list"), wxT("Invalid type for array operator") );
+#endif
if (GetType() == wxT("list"))
{
wxASSERT_MSG( (idx < (size_t) data->GetValue().GetCount()), wxT("Invalid index for array") );
return * (wxVariant*) (data->GetValue().Item(idx)->GetData());
}
+#if WXWIN_COMPATIBILITY_2_4
else if (GetType() == wxT("stringlist"))
{
wxVariantDataStringList* data = (wxVariantDataStringList*) m_data;
wxVariant variant( str );
return variant;
}
+#endif
return wxNullVariant;
}
// Return the number of elements in a list
int wxVariant::GetCount() const
{
+#if WXWIN_COMPATIBILITY_2_4
wxASSERT_MSG( (GetType() == wxT("list") || GetType() == wxT("stringlist")), wxT("Invalid type for GetCount()") );
+#else
+ wxASSERT_MSG( GetType() == wxT("list"), wxT("Invalid type for GetCount()") );
+#endif
if (GetType() == wxT("list"))
{
wxVariantDataList* data = (wxVariantDataList*) m_data;
return data->GetValue().GetCount();
}
+#if WXWIN_COMPATIBILITY_2_4
else if (GetType() == wxT("stringlist"))
{
wxVariantDataStringList* data = (wxVariantDataStringList*) m_data;
return data->GetValue().GetCount();
}
+#endif
return 0;
}
if (GetData()->Write(str))
return str;
}
- return wxString(wxT(""));
+ return wxEmptyString;
}
// Accessors
// Returns a string representing the type of the variant,
-// e.g. "string", "bool", "stringlist", "list", "double", "long"
+// e.g. "string", "bool", "list", "double", "long"
wxString wxVariant::GetType() const
{
if (IsNull())
return (wxList&) ((wxVariantDataList*) m_data)->GetValue();
}
+#if WXWIN_COMPATIBILITY_2_4
+
wxStringList& wxVariant::GetStringList() const
{
wxASSERT( (GetType() == wxT("stringlist")) );
return (wxStringList&) ((wxVariantDataStringList*) m_data)->GetValue();
}
+#endif
+
// Make empty list
void wxVariant::NullList()
{
}
else
{
- if (GetType() != wxT("list"))
+ if (!GetType().IsSameAs(wxT("list")))
{
delete m_data;
m_data = NULL;
}
// Fallback to string conversion
wxString val;
- return Convert(&val) && (value->ParseDateTime(val) || value->ParseDate());
+ return Convert(&val) &&
+ (value->ParseDateTime(val) || value->ParseDate(val));
}
#endif // wxUSE_DATETIME