X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a0a302dcba6d7f6828f221f7341ee8a8cbcd8e96..cfad3750c3ecc821ffae8b9b3de852551270846d:/src/common/variant.cpp diff --git a/src/common/variant.cpp b/src/common/variant.cpp index 39ced009bf..2612f8db24 100644 --- a/src/common/variant.cpp +++ b/src/common/variant.cpp @@ -35,7 +35,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxVariantData, wxObject) -wxVariant wxNullVariant; +wxVariant WXDLLEXPORT wxNullVariant; /* * wxVariantDataList @@ -293,12 +293,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 +338,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 +350,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 +386,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 +428,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 +440,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 +477,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 +518,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 +531,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 +567,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 +609,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 +622,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) { @@ -627,9 +646,18 @@ bool wxVariantDataChar::Read(wxString& str) * wxVariantDataString */ +#if defined(__BORLANDC__) && defined(__WIN16__) +// Change name because of truncation +#define wxVariantDataString wxVariantStringData +#endif + class WXDLLEXPORT wxVariantDataString: public wxVariantData { +#if defined(__BORLANDC__) && defined(__WIN16__) +DECLARE_DYNAMIC_CLASS(wxVariantStringData) +#else DECLARE_DYNAMIC_CLASS(wxVariantDataString) +#endif public: wxVariantDataString() { } wxVariantDataString(const wxString& value) { m_value = value; } @@ -640,11 +668,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: @@ -675,12 +705,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; @@ -693,11 +717,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) { @@ -705,7 +737,11 @@ bool wxVariantDataString::Read(wxString& str) return TRUE; } +#if defined(__BORLANDC__) && defined(__WIN16__) +IMPLEMENT_DYNAMIC_CLASS(wxVariantStringData, wxVariantData) +#else IMPLEMENT_DYNAMIC_CLASS(wxVariantDataString, wxVariantData) +#endif /* * wxVariantDataTime @@ -771,13 +807,13 @@ bool wxVariantDataTime::Write(wxString& str) const return TRUE; } -bool wxVariantDataTime::Read(istream& str) +bool wxVariantDataTime::Read(istream& WXUNUSED(str)) { // Not implemented return FALSE; } -bool wxVariantDataTime::Read(wxString& str) +bool wxVariantDataTime::Read(wxString& WXUNUSED(str)) { // Not implemented return FALSE; @@ -844,13 +880,13 @@ bool wxVariantDataDate::Write(wxString& str) const return TRUE; } -bool wxVariantDataDate::Read(istream& str) +bool wxVariantDataDate::Read(istream& WXUNUSED(str)) { // Not implemented return FALSE; } -bool wxVariantDataDate::Read(wxString& str) +bool wxVariantDataDate::Read(wxString& WXUNUSED(str)) { // Not implemented return FALSE; @@ -921,13 +957,13 @@ bool wxVariantDataVoidPtr::Write(wxString& str) const return TRUE; } -bool wxVariantDataVoidPtr::Read(istream& str) +bool wxVariantDataVoidPtr::Read(istream& WXUNUSED(str)) { // Not implemented return FALSE; } -bool wxVariantDataVoidPtr::Read(wxString& str) +bool wxVariantDataVoidPtr::Read(wxString& WXUNUSED(str)) { // Not implemented return FALSE; @@ -944,7 +980,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxVariant, wxObject) wxVariant::wxVariant() { m_data = (wxVariantData*) NULL; - m_name = wxEmptyString; } wxVariant::wxVariant(double val, const wxString& name)