X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3883022093c42e3fb7b248ea2cb4bbd1e056a75b..5701b057fb4b5bf672da2fb19230d179f7f3e251:/src/common/variant.cpp diff --git a/src/common/variant.cpp b/src/common/variant.cpp index df4651d9f6..5b7126fd5e 100644 --- a/src/common/variant.cpp +++ b/src/common/variant.cpp @@ -26,7 +26,11 @@ # include #endif +#if wxUSE_STREAMS #include "wx/stream.h" +#include "wx/txtstrm.h" +#endif + #include "wx/string.h" #include "wx/variant.h" @@ -371,13 +375,16 @@ bool wxVariantDataLong::Read(istream& str) #if wxUSE_STREAMS bool wxVariantDataLong::Write(wxOutputStream& str) const { - str << m_value; + wxTextOutputStream s(str); + + s.Write32(m_value); return TRUE; } bool wxVariantDataLong::Read(wxInputStream& str) { - str >> m_value; + wxTextInputStream s(str); + m_value = s.Read32(); return TRUE; } #endif // wxUSE_STREAMS @@ -469,13 +476,15 @@ bool wxVariantDataReal::Read(istream& str) #if wxUSE_STREAMS bool wxVariantDataReal::Write(wxOutputStream& str) const { - str << m_value; + wxTextOutputStream s(str); + s.WriteDouble((double)m_value); return TRUE; } bool wxVariantDataReal::Read(wxInputStream& str) { - str >> (float&)m_value; + wxTextInputStream s(str); + m_value = (float)s.ReadDouble(); return TRUE; } #endif // wxUSE_STREAMS @@ -569,13 +578,17 @@ bool wxVariantDataBool::Read(istream& WXUNUSED(str)) #if wxUSE_STREAMS bool wxVariantDataBool::Write(wxOutputStream& str) const { - str << (char)m_value; + wxTextOutputStream s(str); + + s.Write8(m_value); return TRUE; } bool wxVariantDataBool::Read(wxInputStream& str) { - str >> (char&)m_value; + wxTextInputStream s(str); + + m_value = s.Read8() != 0; return TRUE; } #endif // wxUSE_STREAMS @@ -667,13 +680,17 @@ bool wxVariantDataChar::Read(istream& WXUNUSED(str)) #if wxUSE_STREAMS bool wxVariantDataChar::Write(wxOutputStream& str) const { - str << m_value; + wxTextOutputStream s(str); + + s.Write8(m_value); return TRUE; } bool wxVariantDataChar::Read(wxInputStream& str) { - str >> m_value; + wxTextInputStream s(str); + + m_value = s.Read8(); return TRUE; } #endif // wxUSE_STREAMS @@ -771,13 +788,16 @@ bool wxVariantDataString::Read(istream& str) bool wxVariantDataString::Write(wxOutputStream& str) const { // why doesn't wxOutputStream::operator<< take "const wxString&" - str << (const char*) m_value.mb_str(); + wxTextOutputStream s(str); + s.WriteString(m_value); return TRUE; } bool wxVariantDataString::Read(wxInputStream& str) { - str >> m_value; + wxTextInputStream s(str); + + m_value = s.ReadString(); return TRUE; } #endif // wxUSE_STREAMS