return true;
}
-// wxVariant
+// wxVariant
wxVariant::wxVariant(long val, const wxString& name)
{
DECLARE_DYNAMIC_CLASS(wxVariantDataChar)
public:
wxVariantDataChar() { m_value = 0; }
- wxVariantDataChar(char value) { m_value = value; }
+ wxVariantDataChar(wxChar value) { m_value = value; }
- inline char GetValue() const { return m_value; }
- inline void SetValue(char value) { m_value = value; }
+ inline wxChar GetValue() const { return m_value; }
+ inline void SetValue(wxChar value) { m_value = value; }
virtual bool Eq(wxVariantData& data) const;
#if wxUSE_STD_IOSTREAM
virtual wxString GetType() const { return wxT("char"); };
protected:
- char m_value;
+ wxChar m_value;
};
IMPLEMENT_DYNAMIC_CLASS(wxVariantDataChar, wxVariantData)
bool wxVariantDataChar::Read(wxSTD istream& WXUNUSED(str))
{
wxFAIL_MSG(wxT("Unimplemented"));
-// str >> m_value;
+
return false;
}
#endif
{
wxTextOutputStream s(str);
- s.Write8(m_value);
+ s << m_value;
+
return true;
}
{
wxTextInputStream s(str);
- m_value = s.Read8();
+ s >> m_value;
+
return true;
}
#endif // wxUSE_STREAMS
bool wxVariantDataChar::Read(wxString& str)
{
- m_value = str.ToAscii()[size_t(0)];
+ m_value = str[size_t(0)];
return true;
}
-wxVariant::wxVariant(char val, const wxString& name)
+wxVariant::wxVariant(wxChar val, const wxString& name)
{
m_data = new wxVariantDataChar(val);
m_name = name;
}
-bool wxVariant::operator== (char value) const
+bool wxVariant::operator== (wxChar value) const
{
- char thisValue;
+ wxChar thisValue;
if (!Convert(&thisValue))
return false;
else
return (value == thisValue);
}
-bool wxVariant::operator!= (char value) const
+bool wxVariant::operator!= (wxChar value) const
{
return (!((*this) == value));
}
-void wxVariant::operator= (char value)
+void wxVariant::operator= (wxChar value)
{
if (GetType() == wxT("char") &&
m_data->GetRefCount() == 1)
}
}
-char wxVariant::GetChar() const
+wxChar wxVariant::GetChar() const
{
- char value;
+ wxChar value;
if (Convert(& value))
return value;
else
IMPLEMENT_DYNAMIC_CLASS(wxVariantDataString, wxVariantData)
// wxVariant ****
-
+
wxVariant::wxVariant(const wxString& val, const wxString& name)
{
m_data = new wxVariantDataString(val);
}
}
-// 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"))
- {
- wxVariantDataList* data = (wxVariantDataList*) m_data;
- wxASSERT_MSG( (idx < 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;
- wxASSERT_MSG( (idx < data->GetValue().GetCount()), wxT("Invalid index for array") );
-
- wxString str( (const wxChar*) (data->GetValue().Item(idx)->GetData()) );
- wxVariant variant( str );
- return variant;
- }
-#endif
- 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 < data->GetValue().GetCount()), wxT("Invalid index for array") );
-
- return * (wxVariant*) (data->GetValue().Item(idx)->GetData());
-}
-
-// Return the number of elements in a list
-size_t 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 WXWIN_COMPATIBILITY_2_4
// ----------------------------------------------------------------------------
}
}
-// wxVariant
+// wxVariant
wxStringList& wxVariant::GetStringList() const
{
#endif
+// 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"))
+ {
+ wxVariantDataList* data = (wxVariantDataList*) m_data;
+ wxASSERT_MSG( (idx < 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;
+ wxASSERT_MSG( (idx < data->GetValue().GetCount()), wxT("Invalid index for array") );
+
+ wxString str( (const wxChar*) (data->GetValue().Item(idx)->GetData()) );
+ wxVariant variant( str );
+ return variant;
+ }
+#endif
+ 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 < data->GetValue().GetCount()), wxT("Invalid index for array") );
+
+ return * (wxVariant*) (data->GetValue().Item(idx)->GetData());
+}
+
+// Return the number of elements in a list
+size_t 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;
+}
+
// ----------------------------------------------------------------------------
// Type conversion
// ----------------------------------------------------------------------------
return true;
}
-bool wxVariant::Convert(char* value) const
+bool wxVariant::Convert(wxChar* value) const
{
wxString type(GetType());
if (type == wxT("char"))
}
#endif // wxUSE_DATETIME
-
-
-
#endif // wxUSE_VARIANT