X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/71520754fc7c981b2fdfd711a7091548347a51b0..ce7208d49d5ce2ca1dc0b3b83f14f1d04f29c4bf:/src/common/variant.cpp?ds=sidebyside

diff --git a/src/common/variant.cpp b/src/common/variant.cpp
index 63584d8d39..870938c773 100644
--- a/src/common/variant.cpp
+++ b/src/common/variant.cpp
@@ -290,7 +290,7 @@ bool wxVariantDataLong::Read(wxString& str)
     return true;
 }
 
-// wxVariant 
+// wxVariant
 
 wxVariant::wxVariant(long val, const wxString& name)
 {
@@ -695,7 +695,7 @@ bool wxVariantDataChar::Write(wxString& str) const
 bool wxVariantDataChar::Read(wxSTD istream& WXUNUSED(str))
 {
     wxFAIL_MSG(wxT("Unimplemented"));
-    
+
     return false;
 }
 #endif
@@ -705,7 +705,8 @@ bool wxVariantDataChar::Write(wxOutputStream& str) const
 {
     wxTextOutputStream s(str);
 
-    s.Write8(m_value);
+    s << m_value;
+
     return true;
 }
 
@@ -733,7 +734,7 @@ wxVariant::wxVariant(wxChar val, const wxString& name)
 
 bool wxVariant::operator== (wxChar value) const
 {
-    char thisValue;
+    wxChar thisValue;
     if (!Convert(&thisValue))
         return false;
     else
@@ -761,7 +762,7 @@ void wxVariant::operator= (wxChar value)
 
 wxChar wxVariant::GetChar() const
 {
-    char value;
+    wxChar value;
     if (Convert(& value))
         return value;
     else
@@ -854,7 +855,7 @@ bool wxVariantDataString::Read(wxString& str)
 IMPLEMENT_DYNAMIC_CLASS(wxVariantDataString, wxVariantData)
 
 // wxVariant ****
- 
+
 wxVariant::wxVariant(const wxString& val, const wxString& name)
 {
     m_data = new wxVariantDataString(val);
@@ -1700,72 +1701,6 @@ void wxVariant::ClearList()
     }
 }
 
-// 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
 
 // ----------------------------------------------------------------------------
@@ -1906,7 +1841,7 @@ void wxVariant::operator= (const wxStringList& value)
     }
 }
 
-// wxVariant 
+// wxVariant
 
 wxStringList& wxVariant::GetStringList() const
 {
@@ -1917,6 +1852,72 @@ 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
 // ----------------------------------------------------------------------------
@@ -1987,7 +1988,7 @@ bool wxVariant::Convert(double* value) const
     return true;
 }
 
-bool wxVariant::Convert(char* value) const
+bool wxVariant::Convert(wxChar* value) const
 {
     wxString type(GetType());
     if (type == wxT("char"))
@@ -2026,7 +2027,4 @@ bool wxVariant::Convert(wxDateTime* value) const
 }
 #endif // wxUSE_DATETIME
 
-
-
-
 #endif // wxUSE_VARIANT