X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3ba055acae99caf68da4bb201f66fc1030d2dbb0..26128999a7e2bc05024e09ba2658d4a6ab87accd:/src/common/variant.cpp diff --git a/src/common/variant.cpp b/src/common/variant.cpp index 341329fc28..ad725d2e13 100644 --- a/src/common/variant.cpp +++ b/src/common/variant.cpp @@ -6,7 +6,7 @@ // Created: 10/09/98 // RCS-ID: $Id$ // Copyright: (c) -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -17,16 +17,13 @@ #include "wx/wxprec.h" #ifdef __BORLANDC__ -#pragma hdrstop + #pragma hdrstop #endif #if wxUSE_IOSTREAMH # include #else # include -# ifdef _MSC_VER - using namespace std; -# endif #endif #include "wx/stream.h" @@ -293,12 +290,17 @@ public: virtual void Copy(wxVariantData& data); virtual bool Eq(wxVariantData& data) const; - virtual bool Write(ostream& str) const; + + virtual bool Read(wxString& str); virtual bool Write(wxString& str) const; - virtual bool Write(wxOutputStream &str) const; virtual bool Read(istream& str); + virtual bool Write(ostream& str) const; + +#if wxUSE_STREAMS virtual bool Read(wxInputStream& str); - virtual bool Read(wxString& str); + virtual bool Write(wxOutputStream &str) const; +#endif // wxUSE_STREAMS + virtual wxString GetType() const { return "long"; }; protected: @@ -333,12 +335,6 @@ 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); @@ -351,11 +347,19 @@ bool wxVariantDataLong::Read(istream& str) return TRUE; } +#if wxUSE_STREAMS +bool wxVariantDataLong::Write(wxOutputStream& str) const +{ + str << m_value; + return TRUE; +} + bool wxVariantDataLong::Read(wxInputStream& str) { str >> m_value; return TRUE; } +#endif // wxUSE_STREAMS bool wxVariantDataLong::Read(wxString& str) { @@ -379,12 +383,14 @@ public: virtual void Copy(wxVariantData& data); virtual bool Eq(wxVariantData& data) const; + virtual bool Read(wxString& str); virtual bool Write(ostream& str) const; virtual bool Write(wxString& str) const; - virtual bool Write(wxOutputStream &str) const; virtual bool Read(istream& str); +#if wxUSE_STREAMS virtual bool Read(wxInputStream& str); - virtual bool Read(wxString& str); + virtual bool Write(wxOutputStream &str) const; +#endif // wxUSE_STREAMS virtual wxString GetType() const { return "double"; }; protected: @@ -419,12 +425,6 @@ 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); @@ -437,11 +437,19 @@ bool wxVariantDataReal::Read(istream& str) return TRUE; } +#if wxUSE_STREAMS +bool wxVariantDataReal::Write(wxOutputStream& str) const +{ + str << m_value; + return TRUE; +} + bool wxVariantDataReal::Read(wxInputStream& str) { str >> (float&)m_value; return TRUE; } +#endif // wxUSE_STREAMS bool wxVariantDataReal::Read(wxString& str) { @@ -466,11 +474,13 @@ 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(wxString& str); virtual bool Read(istream& str); +#if wxUSE_STREAMS virtual bool Read(wxInputStream& str); - virtual bool Read(wxString& str); + virtual bool Write(wxOutputStream& str) const; +#endif // wxUSE_STREAMS virtual wxString GetType() const { return "bool"; }; protected: @@ -505,12 +515,6 @@ 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); @@ -524,11 +528,19 @@ bool wxVariantDataBool::Read(istream& WXUNUSED(str)) return FALSE; } +#if wxUSE_STREAMS +bool wxVariantDataBool::Write(wxOutputStream& str) const +{ + str << (char)m_value; + return TRUE; +} + bool wxVariantDataBool::Read(wxInputStream& str) { str >> (char&)m_value; return TRUE; } +#endif // wxUSE_STREAMS bool wxVariantDataBool::Read(wxString& str) { @@ -552,12 +564,14 @@ public: virtual void Copy(wxVariantData& data); virtual bool Eq(wxVariantData& data) const; + virtual bool Read(istream& str); virtual bool Write(ostream& str) const; - virtual bool Write(wxOutputStream& str) const; + virtual bool Read(wxString& str); virtual bool Write(wxString& str) const; - virtual bool Read(istream& str); +#if wxUSE_STREAMS virtual bool Read(wxInputStream& str); - virtual bool Read(wxString& str); + virtual bool Write(wxOutputStream& str) const; +#endif // wxUSE_STREAMS virtual wxString GetType() const { return "char"; }; protected: @@ -592,12 +606,6 @@ 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); @@ -611,11 +619,19 @@ bool wxVariantDataChar::Read(istream& WXUNUSED(str)) return FALSE; } +#if wxUSE_STREAMS +bool wxVariantDataChar::Write(wxOutputStream& str) const +{ + str << m_value; + return TRUE; +} + bool wxVariantDataChar::Read(wxInputStream& str) { str >> m_value; return TRUE; } +#endif // wxUSE_STREAMS bool wxVariantDataChar::Read(wxString& str) { @@ -649,11 +665,13 @@ 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 Read(wxString& str); virtual bool Write(wxString& str) const; virtual bool Read(istream& str); +#if wxUSE_STREAMS virtual bool Read(wxInputStream& str); - virtual bool Read(wxString& str); + virtual bool Write(wxOutputStream& str) const; +#endif // wxUSE_STREAMS virtual wxString GetType() const { return "string"; }; protected: @@ -684,12 +702,6 @@ 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; @@ -702,11 +714,19 @@ bool wxVariantDataString::Read(istream& str) return TRUE; } +#if wxUSE_STREAMS +bool wxVariantDataString::Write(wxOutputStream& str) const +{ + str << (const char*) m_value; + return TRUE; +} + bool wxVariantDataString::Read(wxInputStream& str) { str >> m_value; return TRUE; } +#endif // wxUSE_STREAMS bool wxVariantDataString::Read(wxString& str) {