X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fbc535ff084f61ec376f339c515d96d74065c18b..520e470fdd0daef09c77938db642e4583933c90d:/src/common/variant.cpp diff --git a/src/common/variant.cpp b/src/common/variant.cpp index b514bf1cd9..02fa477273 100644 --- a/src/common/variant.cpp +++ b/src/common/variant.cpp @@ -21,14 +21,15 @@ #endif #if wxUSE_IOSTREAMH -#include +# include #else -#include -# ifdef _MSC_VER - using namespace std; -# endif +# include +# ifdef _MSC_VER + using namespace std; +# endif #endif +#include "wx/stream.h" #include "wx/string.h" #include "wx/variant.h" @@ -294,7 +295,9 @@ public: virtual bool Eq(wxVariantData& data) const; virtual bool Write(ostream& str) const; virtual bool Write(wxString& str) const; + virtual bool Write(wxOutputStream &str) const; virtual bool Read(istream& str); + virtual bool Read(wxInputStream& str); virtual bool Read(wxString& str); virtual wxString GetType() const { return "long"; }; @@ -330,6 +333,12 @@ bool wxVariantDataLong::Write(ostream& str) const return TRUE; } +bool wxVariantDataLong::Write(wxOutputStream& str) const +{ + str << m_value; + return TRUE; +} + bool wxVariantDataLong::Write(wxString& str) const { str.Printf("%ld", m_value); @@ -342,6 +351,12 @@ bool wxVariantDataLong::Read(istream& str) return TRUE; } +bool wxVariantDataLong::Read(wxInputStream& str) +{ + str >> m_value; + return TRUE; +} + bool wxVariantDataLong::Read(wxString& str) { m_value = atol((const char*) str); @@ -366,7 +381,9 @@ public: virtual bool Eq(wxVariantData& data) const; virtual bool Write(ostream& str) const; virtual bool Write(wxString& str) const; + virtual bool Write(wxOutputStream &str) const; virtual bool Read(istream& str); + virtual bool Read(wxInputStream& str); virtual bool Read(wxString& str); virtual wxString GetType() const { return "double"; }; @@ -402,6 +419,12 @@ bool wxVariantDataReal::Write(ostream& str) const return TRUE; } +bool wxVariantDataReal::Write(wxOutputStream& str) const +{ + str << m_value; + return TRUE; +} + bool wxVariantDataReal::Write(wxString& str) const { str.Printf("%.4f", m_value); @@ -414,6 +437,12 @@ bool wxVariantDataReal::Read(istream& str) return TRUE; } +bool wxVariantDataReal::Read(wxInputStream& str) +{ + str >> (float&)m_value; + return TRUE; +} + bool wxVariantDataReal::Read(wxString& str) { m_value = atof((const char*) str); @@ -437,8 +466,10 @@ public: virtual void Copy(wxVariantData& data); virtual bool Eq(wxVariantData& data) const; virtual bool Write(ostream& str) const; + virtual bool Write(wxOutputStream& str) const; virtual bool Write(wxString& str) const; virtual bool Read(istream& str); + virtual bool Read(wxInputStream& str); virtual bool Read(wxString& str); virtual wxString GetType() const { return "bool"; }; @@ -474,6 +505,12 @@ bool wxVariantDataBool::Write(ostream& str) const return TRUE; } +bool wxVariantDataBool::Write(wxOutputStream& str) const +{ + str << (char)m_value; + return TRUE; +} + bool wxVariantDataBool::Write(wxString& str) const { str.Printf("%d", (int) m_value); @@ -487,6 +524,12 @@ bool wxVariantDataBool::Read(istream& WXUNUSED(str)) return FALSE; } +bool wxVariantDataBool::Read(wxInputStream& str) +{ + str >> (char&)m_value; + return TRUE; +} + bool wxVariantDataBool::Read(wxString& str) { m_value = (atol((const char*) str) != 0); @@ -510,8 +553,10 @@ public: virtual void Copy(wxVariantData& data); virtual bool Eq(wxVariantData& data) const; virtual bool Write(ostream& str) const; + virtual bool Write(wxOutputStream& str) const; virtual bool Write(wxString& str) const; virtual bool Read(istream& str); + virtual bool Read(wxInputStream& str); virtual bool Read(wxString& str); virtual wxString GetType() const { return "char"; }; @@ -547,6 +592,12 @@ bool wxVariantDataChar::Write(ostream& str) const return TRUE; } +bool wxVariantDataChar::Write(wxOutputStream& str) const +{ + str << m_value; + return TRUE; +} + bool wxVariantDataChar::Write(wxString& str) const { str.Printf("%c", m_value); @@ -560,6 +611,12 @@ bool wxVariantDataChar::Read(istream& WXUNUSED(str)) return FALSE; } +bool wxVariantDataChar::Read(wxInputStream& str) +{ + str >> m_value; + return TRUE; +} + bool wxVariantDataChar::Read(wxString& str) { m_value = str[(size_t)0]; @@ -583,8 +640,10 @@ public: virtual void Copy(wxVariantData& data); virtual bool Eq(wxVariantData& data) const; virtual bool Write(ostream& str) const; + virtual bool Write(wxOutputStream& str) const; virtual bool Write(wxString& str) const; virtual bool Read(istream& str); + virtual bool Read(wxInputStream& str); virtual bool Read(wxString& str); virtual wxString GetType() const { return "string"; }; @@ -616,6 +675,12 @@ bool wxVariantDataString::Write(ostream& str) const return TRUE; } +bool wxVariantDataString::Write(wxOutputStream& str) const +{ + str << (const char*) m_value; + return TRUE; +} + bool wxVariantDataString::Write(wxString& str) const { str = m_value; @@ -628,6 +693,12 @@ bool wxVariantDataString::Read(istream& str) return TRUE; } +bool wxVariantDataString::Read(wxInputStream& str) +{ + str >> m_value; + return TRUE; +} + bool wxVariantDataString::Read(wxString& str) { m_value = str;