From 3883022093c42e3fb7b248ea2cb4bbd1e056a75b Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sun, 27 Jun 1999 10:39:38 +0000 Subject: [PATCH] Work on streams of all sorts. More to come. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2908 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/date.h | 2 + include/wx/gtk/textctrl.h | 10 ++-- include/wx/gtk1/textctrl.h | 10 ++-- include/wx/ioswrap.h | 5 ++ include/wx/log.h | 12 ++--- include/wx/object.h | 12 ++--- include/wx/stream.h | 34 ++++++------- include/wx/string.h | 2 +- include/wx/utils.h | 2 - include/wx/variant.h | 4 ++ samples/typetest/typetest.cpp | 52 ++++++++++++++++++++ samples/typetest/typetest.h | 2 + src/common/date.cpp | 13 ++--- src/common/object.cpp | 2 +- src/common/stream.cpp | 93 ++++++++++++++++++++++++++++------- src/common/time.cpp | 2 +- src/common/utilscmn.cpp | 8 --- src/common/variant.cpp | 79 ++++++++++++++++++++++++++++- src/gtk/textctrl.cpp | 8 +-- src/gtk1/textctrl.cpp | 8 +-- 20 files changed, 262 insertions(+), 98 deletions(-) diff --git a/include/wx/date.h b/include/wx/date.h index 3063dd31af..dc7c7b613a 100644 --- a/include/wx/date.h +++ b/include/wx/date.h @@ -92,7 +92,9 @@ public: friend bool WXDLLEXPORT operator == (const wxDate &dt1, const wxDate &dt2); friend bool WXDLLEXPORT operator != (const wxDate &dt1, const wxDate &dt2); +#if wxUSE_STD_IOSTREAM friend ostream WXDLLEXPORT & operator << (ostream &os, const wxDate &dt); +#endif wxString FormatDate (int type=-1) const; void SetFormat (int format); diff --git a/include/wx/gtk/textctrl.h b/include/wx/gtk/textctrl.h index 95161e5246..a930d772d4 100644 --- a/include/wx/gtk/textctrl.h +++ b/include/wx/gtk/textctrl.h @@ -29,10 +29,6 @@ #include #endif -#else - -#define NO_TEXT_WINDOW_STREAM - #endif //----------------------------------------------------------------------------- @@ -51,7 +47,7 @@ extern const char *wxTextCtrlNameStr; // wxTextCtrl //----------------------------------------------------------------------------- -#ifndef NO_TEXT_WINDOW_STREAM +#if wxUSE_STD_IOSTREAM class wxTextCtrl: public wxControl, public streambuf #else class wxTextCtrl: public wxControl @@ -130,10 +126,11 @@ class wxTextCtrl: public wxControl void OnUpdateUndo(wxUpdateUIEvent& event); void OnUpdateRedo(wxUpdateUIEvent& event); -#ifndef NO_TEXT_WINDOW_STREAM +#if wxUSE_STD_IOSTREAM int overflow(int i); int sync(); int underflow(); +#endif wxTextCtrl& operator<<(const wxString& s); wxTextCtrl& operator<<(int i); @@ -141,7 +138,6 @@ class wxTextCtrl: public wxControl wxTextCtrl& operator<<(float f); wxTextCtrl& operator<<(double d); wxTextCtrl& operator<<(const char c); -#endif bool SetFont( const wxFont &font ); bool SetForegroundColour(const wxColour &colour); diff --git a/include/wx/gtk1/textctrl.h b/include/wx/gtk1/textctrl.h index 95161e5246..a930d772d4 100644 --- a/include/wx/gtk1/textctrl.h +++ b/include/wx/gtk1/textctrl.h @@ -29,10 +29,6 @@ #include #endif -#else - -#define NO_TEXT_WINDOW_STREAM - #endif //----------------------------------------------------------------------------- @@ -51,7 +47,7 @@ extern const char *wxTextCtrlNameStr; // wxTextCtrl //----------------------------------------------------------------------------- -#ifndef NO_TEXT_WINDOW_STREAM +#if wxUSE_STD_IOSTREAM class wxTextCtrl: public wxControl, public streambuf #else class wxTextCtrl: public wxControl @@ -130,10 +126,11 @@ class wxTextCtrl: public wxControl void OnUpdateUndo(wxUpdateUIEvent& event); void OnUpdateRedo(wxUpdateUIEvent& event); -#ifndef NO_TEXT_WINDOW_STREAM +#if wxUSE_STD_IOSTREAM int overflow(int i); int sync(); int underflow(); +#endif wxTextCtrl& operator<<(const wxString& s); wxTextCtrl& operator<<(int i); @@ -141,7 +138,6 @@ class wxTextCtrl: public wxControl wxTextCtrl& operator<<(float f); wxTextCtrl& operator<<(double d); wxTextCtrl& operator<<(const char c); -#endif bool SetFont( const wxFont &font ); bool SetForegroundColour(const wxColour &colour); diff --git a/include/wx/ioswrap.h b/include/wx/ioswrap.h index ce0b15357c..e77e74033d 100644 --- a/include/wx/ioswrap.h +++ b/include/wx/ioswrap.h @@ -9,6 +9,8 @@ // Licence: wxWindows license /////////////////////////////////////////////////////////////////////////////// +#if wxUSE_STD_IOSTREAM + #if wxUSE_IOSTREAMH // N.B. BC++ doesn't have istream.h, ostream.h # include @@ -18,3 +20,6 @@ using namespace std; # endif #endif + +#endif + // wxUSE_STD_IOSTREAM \ No newline at end of file diff --git a/include/wx/log.h b/include/wx/log.h index 2c9e5ccb33..72f8d774fb 100644 --- a/include/wx/log.h +++ b/include/wx/log.h @@ -16,6 +16,8 @@ #pragma interface "log.h" #endif +#include "wx/setup.h" + // ---------------------------------------------------------------------------- // forward declarations // ---------------------------------------------------------------------------- @@ -87,15 +89,7 @@ enum #define wxTraceOleCalls 0x0100 // OLE interface calls #endif -#if wxUSE_IOSTREAMH -// N.B. BC++ doesn't have istream.h, ostream.h -# include -#else -# include -# if defined(__VISUALC__) || defined(__MWERKS__) - using namespace std; -# endif -#endif +#include "wx/ioswrap.h" // ---------------------------------------------------------------------------- // derive from this class to redirect (or suppress, or ...) log messages diff --git a/include/wx/object.h b/include/wx/object.h index 3f7faec6b2..1835449082 100644 --- a/include/wx/object.h +++ b/include/wx/object.h @@ -40,14 +40,8 @@ class WXDLLEXPORT wxObjectOutputStream; class WXDLLEXPORT wxHashTable; class WXDLLEXPORT wxObject_Serialize; -#if wxUSE_IOSTREAMH - // N.B. BC++ doesn't have istream.h, ostream.h -# include -#else -# include -# if defined(__VISUALC__) || defined(__MWERKS__) - using namespace std; -# endif +#if wxUSE_STD_IOSTREAM && (defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT) + #include "wx/ioswrap.h" #endif /* @@ -225,7 +219,7 @@ class WXDLLEXPORT wxObject #endif // Debug & memory tracing -#if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT +#if wxUSE_STD_IOSTREAM && (defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT) virtual void Dump(ostream& str); #endif diff --git a/include/wx/stream.h b/include/wx/stream.h index 0872a9ba81..0b572026ed 100644 --- a/include/wx/stream.h +++ b/include/wx/stream.h @@ -169,19 +169,18 @@ class WXDLLEXPORT wxInputStream: public wxStreamBase { wxInputStream& operator>>(wxOutputStream& out) { return Read(out); } wxInputStream& operator>>(wxString& line); wxInputStream& operator>>(char& c); - wxInputStream& operator>>(short& i); - wxInputStream& operator>>(int& i); - wxInputStream& operator>>(long& i); + wxInputStream& operator>>(signed short& i); + wxInputStream& operator>>(signed int& i); + wxInputStream& operator>>(signed long& i); + wxInputStream& operator>>(unsigned char& c); + wxInputStream& operator>>(unsigned short& i); + wxInputStream& operator>>(unsigned int& i); + wxInputStream& operator>>(unsigned long& i); wxInputStream& operator>>(double& i); + wxInputStream& operator>>(float& f) { double d; operator>>((double&)d); f = (float)d; return *this; } #if wxUSE_SERIAL wxInputStream& operator>>(wxObject *& obj); #endif - - wxInputStream& operator>>(float& f) { double d; operator>>((double&)d); f = (float)d; return *this; } - wxInputStream& operator>>(unsigned char& c) { return operator>>((char&)c); } - wxInputStream& operator>>(unsigned short& i) { return operator>>((short&)i); } - wxInputStream& operator>>(unsigned int& i) { return operator>>((int&)i); } - wxInputStream& operator>>(unsigned long& i) { return operator>>((long&)i); } wxInputStream& operator>>( __wxInputManip func) { return func(*this); } protected: @@ -210,19 +209,18 @@ class WXDLLEXPORT wxOutputStream: public wxStreamBase { wxOutputStream& operator<<(const char *string); wxOutputStream& operator<<(wxString& string); wxOutputStream& operator<<(char c); - wxOutputStream& operator<<(short i); - wxOutputStream& operator<<(int i); - wxOutputStream& operator<<(long i); + wxOutputStream& operator<<(signed short i); + wxOutputStream& operator<<(signed int i); + wxOutputStream& operator<<(signed long i); + wxOutputStream& operator<<(unsigned char c); + wxOutputStream& operator<<(unsigned short i); + wxOutputStream& operator<<(unsigned int i); + wxOutputStream& operator<<(unsigned long i); wxOutputStream& operator<<(double f); + wxOutputStream& operator<<(float f) { return operator<<((double)f); } #if wxUSE_SERIAL wxOutputStream& operator<<(wxObject& obj); #endif - - wxOutputStream& operator<<(float f) { return operator<<((double)f); } - wxOutputStream& operator<<(unsigned char c) { return operator<<((char)c); } - wxOutputStream& operator<<(unsigned short i) { return operator<<((short)i); } - wxOutputStream& operator<<(unsigned int i) { return operator<<((int)i); } - wxOutputStream& operator<<(unsigned long i) { return operator<<((long)i); } wxOutputStream& operator<<( __wxOutputManip func) { return func(*this); } protected: diff --git a/include/wx/string.h b/include/wx/string.h index 471681315b..661c893f57 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -1076,7 +1076,7 @@ inline wxString WXDLLEXPORT operator+(const wxCharBuffer& buf, const wxString& s // Implementation only from here until the end of file // --------------------------------------------------------------------------- -#ifdef wxSTD_STRING_COMPATIBILITY +#if defined(wxSTD_STRING_COMPATIBILITY) && wxUSE_STD_IOSTREAM #include "wx/ioswrap.h" diff --git a/include/wx/utils.h b/include/wx/utils.h index 4a11fd3316..8ab3168cc9 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -26,8 +26,6 @@ #include "wx/window.h" #include "wx/filefn.h" -#include "wx/ioswrap.h" - #ifdef __X__ #include #include diff --git a/include/wx/variant.h b/include/wx/variant.h index de915f8f7d..ac685e092c 100644 --- a/include/wx/variant.h +++ b/include/wx/variant.h @@ -54,9 +54,13 @@ public: // Copy to data virtual void Copy(wxVariantData& data) = 0; virtual bool Eq(wxVariantData& data) const = 0; +#if wxUSE_STD_IOSTREAM virtual bool Write(ostream& str) const = 0; +#endif virtual bool Write(wxString& str) const = 0; +#if wxUSE_STD_IOSTREAM virtual bool Read(istream& str) = 0; +#endif virtual bool Read(wxString& str) = 0; // What type is it? Return a string name. virtual wxString GetType() const = 0; diff --git a/samples/typetest/typetest.cpp b/samples/typetest/typetest.cpp index fc30948769..1cd285b13b 100644 --- a/samples/typetest/typetest.cpp +++ b/samples/typetest/typetest.cpp @@ -34,6 +34,17 @@ #include "mondrian.xpm" #endif +#include "wx/ioswrap.h" + +#if wxUSE_IOSTREAMH + #include +#else + #include +#endif + +#include "wx/wfstream.h" + + // Create a new application object IMPLEMENT_APP (MyApp) @@ -47,6 +58,7 @@ BEGIN_EVENT_TABLE(MyApp, wxApp) #if wxUSE_UNICODE EVT_MENU(TYPES_UNICODE, MyApp::DoUnicodeDemo) #endif + EVT_MENU(TYPES_STREAM, MyApp::DoStreamDemo) END_EVENT_TABLE() bool MyApp::OnInit(void) @@ -70,6 +82,7 @@ bool MyApp::OnInit(void) #if wxUSE_UNICODE file_menu->Append(TYPES_UNICODE, "&Unicode test"); #endif + file_menu->Append(TYPES_STREAM, "&Stream test"); file_menu->AppendSeparator(); file_menu->Append(TYPES_QUIT, "E&xit"); wxMenuBar *menu_bar = new wxMenuBar; @@ -86,6 +99,45 @@ bool MyApp::OnInit(void) return TRUE; } +void MyApp::DoStreamDemo(wxCommandEvent& WXUNUSED(event)) +{ + wxTextCtrl& textCtrl = * GetTextCtrl(); + + textCtrl.Clear(); + textCtrl << "\nTest fstream vs. wxFileStream:\n\n"; + + ofstream std_file_output( "test_std.dat" ); + wxFileOutputStream file_output( "test_wx.dat" ); + + textCtrl.WriteText( "Writig to fstream:\n" ); + + wxString tmp; + signed int si = 0xFFFFFFFF; + tmp.Printf( "Signed int: %d\n", si ); + textCtrl.WriteText( tmp ); + file_output << si << "\n"; + std_file_output << si << "\n"; + + unsigned int ui = 0xFFFFFFFF; + tmp.Printf( "Unsigned int: %u\n", ui ); + textCtrl.WriteText( tmp ); + file_output << ui << "\n"; + std_file_output << ui << "\n"; + + double d = 2.01234567890123456789; + tmp.Printf( "Double: %f\n", d ); + textCtrl.WriteText( tmp ); + file_output << d << "\n"; + std_file_output << d << "\n"; + + wxString str( "Hello!" ); + tmp.Printf( "String: %s\n", str.c_str() ); + textCtrl.WriteText( tmp ); + file_output << str << "\n"; + std_file_output << str.c_str() << "\n"; + +} + #if wxUSE_UNICODE void MyApp::DoUnicodeDemo(wxCommandEvent& WXUNUSED(event)) { diff --git a/samples/typetest/typetest.h b/samples/typetest/typetest.h index 454fe984db..ae37f643fb 100644 --- a/samples/typetest/typetest.h +++ b/samples/typetest/typetest.h @@ -26,6 +26,7 @@ public: void DoTimeDemo(wxCommandEvent& event); void DoVariantDemo(wxCommandEvent& event); void DoByteOrderDemo(wxCommandEvent& event); + void DoStreamDemo(wxCommandEvent& event); #if wxUSE_UNICODE void DoUnicodeDemo(wxCommandEvent& event); #endif @@ -66,6 +67,7 @@ public: #define TYPES_VARIANT 105 #define TYPES_BYTEORDER 106 #define TYPES_UNICODE 107 +#define TYPES_STREAM 108 #endif // _WX_TYPETEST_H_ diff --git a/src/common/date.cpp b/src/common/date.cpp index 4d8a901c8c..809730cd69 100644 --- a/src/common/date.cpp +++ b/src/common/date.cpp @@ -29,17 +29,13 @@ #if wxUSE_TIMEDATE #include "wx/date.h" -#include +#include "wx/intl.h" #include #include #include -#if wxUSE_IOSTREAMH -#include -#else -#include -#endif +#include "wx/ioswrap.h" #include #include @@ -274,6 +270,9 @@ bool WXDLLEXPORT operator != (const wxDate &dt1, const wxDate &dt2) return ( dt1.julian != dt2.julian ); } + +#if wxUSE_STD_IOSTREAM + //////////////////////////////////////////////////////////////// // Ostream operations //////////////////////////////////////////////////////////////// @@ -283,6 +282,8 @@ ostream WXDLLEXPORT & operator << (ostream &os, const wxDate &dt) return os << dt.FormatDate().mb_str(); } +#endif + ////////////////////////////////////////////////////////////// // Conversion routines ////////////////////////////////////////////////////////////// diff --git a/src/common/object.cpp b/src/common/object.cpp index dbc9d46ef4..3e3a612d48 100644 --- a/src/common/object.cpp +++ b/src/common/object.cpp @@ -99,7 +99,7 @@ void wxObject::CopyObject(wxObject& object_dest) const wxASSERT(object_dest.GetClassInfo()->IsKindOf(GetClassInfo())); } -#if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT +#if wxUSE_STD_IOSTREAM && (defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT) void wxObject::Dump(ostream& str) { if (GetClassInfo() && GetClassInfo()->GetClassName()) diff --git a/src/common/stream.cpp b/src/common/stream.cpp index cc38a5022b..b054abb9f7 100644 --- a/src/common/stream.cpp +++ b/src/common/stream.cpp @@ -603,28 +603,29 @@ wxInputStream& wxInputStream::operator>>(char& c) return *this; } -wxInputStream& wxInputStream::operator>>(short& i) +wxInputStream& wxInputStream::operator>>(signed short& i) { - long l; + signed long l; *this >> l; - i = (short)l; + i = (signed short)l; return *this; } -wxInputStream& wxInputStream::operator>>(int& i) +wxInputStream& wxInputStream::operator>>(signed int& i) { - long l; + signed long l; *this >> l; - i = (short)l; + i = (signed int)l; return *this; } -wxInputStream& wxInputStream::operator>>(long& i) +wxInputStream& wxInputStream::operator>>(signed long& i) { /* I only implemented a simple integer parser */ - int c, sign; + char c; + int sign; while (isspace( c = GetC() ) ) /* Do nothing */ ; @@ -651,6 +652,46 @@ wxInputStream& wxInputStream::operator>>(long& i) return *this; } +wxInputStream& wxInputStream::operator>>(unsigned short& i) +{ + unsigned long l; + + *this >> l; + i = (unsigned short)l; + return *this; +} + +wxInputStream& wxInputStream::operator>>(unsigned int& i) +{ + unsigned long l; + + *this >> l; + i = (unsigned int)l; + return *this; +} + +wxInputStream& wxInputStream::operator>>(unsigned long& i) +{ + /* I only implemented a simple integer parser */ + char c; + + while (isspace( c = GetC() ) ) + /* Do nothing */ ; + + i = 0; + if (!isdigit(c)) { + InputStreamBuffer()->WriteBack(c); + return *this; + } + + while (isdigit(c)) { + i = i*10 + c; + c = GetC(); + } + + return *this; +} + wxInputStream& wxInputStream::operator>>(double& f) { /* I only implemented a simple float parser */ @@ -772,27 +813,41 @@ wxOutputStream& wxOutputStream::operator<<(char c) return Write(&c, 1); } -wxOutputStream& wxOutputStream::operator<<(short i) +wxOutputStream& wxOutputStream::operator<<(signed short i) { - wxString strint; + signed long l = (signed long)i; + return *this << l; +} - strint.Printf(_T("%i"), i); - return *this << strint; +wxOutputStream& wxOutputStream::operator<<(signed int i) +{ + signed long l = (signed long)i; + return *this << l; +} + +wxOutputStream& wxOutputStream::operator<<(signed long i) +{ + wxString strlong; + strlong.Printf(_T("%ld"), i); + return *this << strlong; } -wxOutputStream& wxOutputStream::operator<<(int i) +wxOutputStream& wxOutputStream::operator<<(unsigned short i) { - wxString strint; + unsigned long l = (unsigned long)i; + return *this << l; +} - strint.Printf(_T("%i"), i); - return *this << strint; +wxOutputStream& wxOutputStream::operator<<(unsigned int i) +{ + unsigned long l = (unsigned long)i; + return *this << l; } -wxOutputStream& wxOutputStream::operator<<(long i) +wxOutputStream& wxOutputStream::operator<<(unsigned long i) { wxString strlong; - - strlong.Printf(_T("%i"), i); + strlong.Printf(_T("%lu"), i); return *this << strlong; } diff --git a/src/common/time.cpp b/src/common/time.cpp index c221079ae4..e97789f43c 100644 --- a/src/common/time.cpp +++ b/src/common/time.cpp @@ -36,7 +36,7 @@ seconds since January 1, 1901, GMT. #include "wx/ioswrap.h" -#if wxUSE_IOSTREAMH +#if wxUSE_IOSTREAMH && wxUSE_STD_IOSTREAM #include #else #include diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 1dffad113c..4b6e87cbce 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -30,14 +30,6 @@ #include "wx/textdlg.h" #endif -#include "wx/ioswrap.h" - -#if wxUSE_IOSTREAMH - #include -#else - #include -#endif - #include #include #include diff --git a/src/common/variant.cpp b/src/common/variant.cpp index bea0193b8e..df4651d9f6 100644 --- a/src/common/variant.cpp +++ b/src/common/variant.cpp @@ -20,7 +20,7 @@ #pragma hdrstop #endif -#if wxUSE_IOSTREAMH +#if wxUSE_IOSTREAMH && wxUSE_STD_IOSTREAM # include #else # include @@ -51,9 +51,13 @@ public: virtual void Copy(wxVariantData& data); virtual bool Eq(wxVariantData& data) const; +#if wxUSE_STD_IOSTREAM virtual bool Write(ostream& str) const; +#endif virtual bool Write(wxString& str) const; +#if wxUSE_STD_IOSTREAM virtual bool Read(istream& str); +#endif virtual bool Read(wxString& str); virtual wxString GetType() const { return _T("list"); }; @@ -135,6 +139,7 @@ bool wxVariantDataList::Eq(wxVariantData& data) const return TRUE; } +#if wxUSE_STD_IOSTREAM bool wxVariantDataList::Write(ostream& str) const { wxString s; @@ -142,6 +147,7 @@ bool wxVariantDataList::Write(ostream& str) const str << (const char*) s.mb_str(); return TRUE; } +#endif bool wxVariantDataList::Write(wxString& str) const { @@ -160,12 +166,14 @@ bool wxVariantDataList::Write(wxString& str) const return TRUE; } +#if wxUSE_STD_IOSTREAM bool wxVariantDataList::Read(istream& WXUNUSED(str)) { wxFAIL_MSG(_T("Unimplemented")); // TODO return FALSE; } +#endif bool wxVariantDataList::Read(wxString& WXUNUSED(str)) { @@ -190,9 +198,13 @@ public: virtual void Copy(wxVariantData& data); virtual bool Eq(wxVariantData& data) const; +#if wxUSE_STD_IOSTREAM virtual bool Write(ostream& str) const; +#endif virtual bool Write(wxString& str) const; +#if wxUSE_STD_IOSTREAM virtual bool Read(istream& str); +#endif virtual bool Read(wxString& str); virtual wxString GetType() const { return _T("stringlist"); }; @@ -236,6 +248,7 @@ bool wxVariantDataStringList::Eq(wxVariantData& data) const return TRUE; } +#if wxUSE_STD_IOSTREAM bool wxVariantDataStringList::Write(ostream& str) const { wxString s; @@ -243,6 +256,7 @@ bool wxVariantDataStringList::Write(ostream& str) const str << (const char*) s.mb_str(); return TRUE; } +#endif bool wxVariantDataStringList::Write(wxString& str) const { @@ -260,12 +274,14 @@ bool wxVariantDataStringList::Write(wxString& str) const return TRUE; } +#if wxUSE_STD_IOSTREAM bool wxVariantDataStringList::Read(istream& WXUNUSED(str)) { wxFAIL_MSG(_T("Unimplemented")); // TODO return FALSE; } +#endif bool wxVariantDataStringList::Read(wxString& WXUNUSED(str)) { @@ -293,9 +309,10 @@ public: virtual bool Read(wxString& str); virtual bool Write(wxString& str) const; +#if wxUSE_STD_IOSTREAM virtual bool Read(istream& str); virtual bool Write(ostream& str) const; - +#endif #if wxUSE_STREAMS virtual bool Read(wxInputStream& str); virtual bool Write(wxOutputStream &str) const; @@ -327,6 +344,7 @@ bool wxVariantDataLong::Eq(wxVariantData& data) const return (otherData.m_value == m_value); } +#if wxUSE_STD_IOSTREAM bool wxVariantDataLong::Write(ostream& str) const { wxString s; @@ -334,6 +352,7 @@ bool wxVariantDataLong::Write(ostream& str) const str << (const char*) s.mb_str(); return TRUE; } +#endif bool wxVariantDataLong::Write(wxString& str) const { @@ -341,11 +360,13 @@ bool wxVariantDataLong::Write(wxString& str) const return TRUE; } +#if wxUSE_STD_IOSTREAM bool wxVariantDataLong::Read(istream& str) { str >> m_value; return TRUE; } +#endif #if wxUSE_STREAMS bool wxVariantDataLong::Write(wxOutputStream& str) const @@ -384,9 +405,13 @@ public: virtual void Copy(wxVariantData& data); virtual bool Eq(wxVariantData& data) const; virtual bool Read(wxString& str); +#if wxUSE_STD_IOSTREAM virtual bool Write(ostream& str) const; +#endif virtual bool Write(wxString& str) const; +#if wxUSE_STD_IOSTREAM virtual bool Read(istream& str); +#endif #if wxUSE_STREAMS virtual bool Read(wxInputStream& str); virtual bool Write(wxOutputStream &str) const; @@ -417,6 +442,7 @@ bool wxVariantDataReal::Eq(wxVariantData& data) const return (otherData.m_value == m_value); } +#if wxUSE_STD_IOSTREAM bool wxVariantDataReal::Write(ostream& str) const { wxString s; @@ -424,6 +450,7 @@ bool wxVariantDataReal::Write(ostream& str) const str << (const char*) s.mb_str(); return TRUE; } +#endif bool wxVariantDataReal::Write(wxString& str) const { @@ -431,11 +458,13 @@ bool wxVariantDataReal::Write(wxString& str) const return TRUE; } +#if wxUSE_STD_IOSTREAM bool wxVariantDataReal::Read(istream& str) { str >> m_value; return TRUE; } +#endif #if wxUSE_STREAMS bool wxVariantDataReal::Write(wxOutputStream& str) const @@ -474,10 +503,14 @@ public: virtual void Copy(wxVariantData& data); virtual bool Eq(wxVariantData& data) const; +#if wxUSE_STD_IOSTREAM virtual bool Write(ostream& str) const; +#endif virtual bool Write(wxString& str) const; virtual bool Read(wxString& str); +#if wxUSE_STD_IOSTREAM virtual bool Read(istream& str); +#endif #if wxUSE_STREAMS virtual bool Read(wxInputStream& str); virtual bool Write(wxOutputStream& str) const; @@ -508,6 +541,7 @@ bool wxVariantDataBool::Eq(wxVariantData& data) const return (otherData.m_value == m_value); } +#if wxUSE_STD_IOSTREAM bool wxVariantDataBool::Write(ostream& str) const { wxString s; @@ -515,6 +549,7 @@ bool wxVariantDataBool::Write(ostream& str) const str << (const char*) s.mb_str(); return TRUE; } +#endif bool wxVariantDataBool::Write(wxString& str) const { @@ -522,12 +557,14 @@ bool wxVariantDataBool::Write(wxString& str) const return TRUE; } +#if wxUSE_STD_IOSTREAM bool wxVariantDataBool::Read(istream& WXUNUSED(str)) { wxFAIL_MSG(_T("Unimplemented")); // str >> (long) m_value; return FALSE; } +#endif #if wxUSE_STREAMS bool wxVariantDataBool::Write(wxOutputStream& str) const @@ -566,8 +603,10 @@ public: virtual void Copy(wxVariantData& data); virtual bool Eq(wxVariantData& data) const; +#if wxUSE_STD_IOSTREAM virtual bool Read(istream& str); virtual bool Write(ostream& str) const; +#endif virtual bool Read(wxString& str); virtual bool Write(wxString& str) const; #if wxUSE_STREAMS @@ -600,6 +639,7 @@ bool wxVariantDataChar::Eq(wxVariantData& data) const return (otherData.m_value == m_value); } +#if wxUSE_STD_IOSTREAM bool wxVariantDataChar::Write(ostream& str) const { wxString s; @@ -607,6 +647,7 @@ bool wxVariantDataChar::Write(ostream& str) const str << (const char*) s.mb_str(); return TRUE; } +#endif bool wxVariantDataChar::Write(wxString& str) const { @@ -614,12 +655,14 @@ bool wxVariantDataChar::Write(wxString& str) const return TRUE; } +#if wxUSE_STD_IOSTREAM bool wxVariantDataChar::Read(istream& WXUNUSED(str)) { wxFAIL_MSG(_T("Unimplemented")); // str >> m_value; return FALSE; } +#endif #if wxUSE_STREAMS bool wxVariantDataChar::Write(wxOutputStream& str) const @@ -666,10 +709,14 @@ public: virtual void Copy(wxVariantData& data); virtual bool Eq(wxVariantData& data) const; +#if wxUSE_STD_IOSTREAM virtual bool Write(ostream& str) const; +#endif virtual bool Read(wxString& str); virtual bool Write(wxString& str) const; +#if wxUSE_STD_IOSTREAM virtual bool Read(istream& str); +#endif #if wxUSE_STREAMS virtual bool Read(wxInputStream& str); virtual bool Write(wxOutputStream& str) const; @@ -698,11 +745,13 @@ bool wxVariantDataString::Eq(wxVariantData& data) const return (otherData.m_value == m_value); } +#if wxUSE_STD_IOSTREAM bool wxVariantDataString::Write(ostream& str) const { str << (const char*) m_value.mb_str(); return TRUE; } +#endif bool wxVariantDataString::Write(wxString& str) const { @@ -710,11 +759,13 @@ bool wxVariantDataString::Write(wxString& str) const return TRUE; } +#if wxUSE_STD_IOSTREAM bool wxVariantDataString::Read(istream& str) { str >> m_value; return TRUE; } +#endif #if wxUSE_STREAMS bool wxVariantDataString::Write(wxOutputStream& str) const @@ -761,9 +812,13 @@ public: virtual void Copy(wxVariantData& data); virtual bool Eq(wxVariantData& data) const; +#if wxUSE_STD_IOSTREAM virtual bool Write(ostream& str) const; +#endif virtual bool Write(wxString& str) const; +#if wxUSE_STD_IOSTREAM virtual bool Read(istream& str); +#endif virtual bool Read(wxString& str); virtual wxString GetType() const { return _T("time"); }; virtual wxVariantData* Clone() { return new wxVariantDataTime; } @@ -792,6 +847,7 @@ bool wxVariantDataTime::Eq(wxVariantData& data) const return (otherData.m_value == m_value); } +#if wxUSE_STD_IOSTREAM bool wxVariantDataTime::Write(ostream& str) const { wxString s; @@ -799,6 +855,7 @@ bool wxVariantDataTime::Write(ostream& str) const str << (const char*) s.mb_str(); return TRUE; } +#endif bool wxVariantDataTime::Write(wxString& str) const { @@ -807,11 +864,13 @@ bool wxVariantDataTime::Write(wxString& str) const return TRUE; } +#if wxUSE_STD_IOSTREAM bool wxVariantDataTime::Read(istream& WXUNUSED(str)) { // Not implemented return FALSE; } +#endif bool wxVariantDataTime::Read(wxString& WXUNUSED(str)) { @@ -835,9 +894,13 @@ public: virtual void Copy(wxVariantData& data); virtual bool Eq(wxVariantData& data) const; +#if wxUSE_STD_IOSTREAM virtual bool Write(ostream& str) const; +#endif virtual bool Write(wxString& str) const; +#if wxUSE_STD_IOSTREAM virtual bool Read(istream& str); +#endif virtual bool Read(wxString& str); virtual wxString GetType() const { return _T("date"); }; virtual wxVariantData* Clone() { return new wxVariantDataDate; } @@ -866,6 +929,7 @@ bool wxVariantDataDate::Eq(wxVariantData& data) const return (otherData.m_value == m_value); } +#if wxUSE_STD_IOSTREAM bool wxVariantDataDate::Write(ostream& str) const { wxString s; @@ -873,6 +937,7 @@ bool wxVariantDataDate::Write(ostream& str) const str << (const char*) s.mb_str(); return TRUE; } +#endif bool wxVariantDataDate::Write(wxString& str) const { @@ -880,11 +945,13 @@ bool wxVariantDataDate::Write(wxString& str) const return TRUE; } +#if wxUSE_STD_IOSTREAM bool wxVariantDataDate::Read(istream& WXUNUSED(str)) { // Not implemented return FALSE; } +#endif bool wxVariantDataDate::Read(wxString& WXUNUSED(str)) { @@ -910,9 +977,13 @@ public: virtual void Copy(wxVariantData& data); virtual bool Eq(wxVariantData& data) const; +#if wxUSE_STD_IOSTREAM virtual bool Write(ostream& str) const; +#endif virtual bool Write(wxString& str) const; +#if wxUSE_STD_IOSTREAM virtual bool Read(istream& str); +#endif virtual bool Read(wxString& str); virtual wxString GetType() const { return _T("void*"); }; virtual wxVariantData* Clone() { return new wxVariantDataVoidPtr; } @@ -941,6 +1012,7 @@ bool wxVariantDataVoidPtr::Eq(wxVariantData& data) const return (otherData.m_value == m_value); } +#if wxUSE_STD_IOSTREAM bool wxVariantDataVoidPtr::Write(ostream& str) const { wxString s; @@ -948,6 +1020,7 @@ bool wxVariantDataVoidPtr::Write(ostream& str) const str << (const char*) s.mb_str(); return TRUE; } +#endif bool wxVariantDataVoidPtr::Write(wxString& str) const { @@ -955,11 +1028,13 @@ bool wxVariantDataVoidPtr::Write(wxString& str) const return TRUE; } +#if wxUSE_STD_IOSTREAM bool wxVariantDataVoidPtr::Read(istream& WXUNUSED(str)) { // Not implemented return FALSE; } +#endif bool wxVariantDataVoidPtr::Read(wxString& WXUNUSED(str)) { diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index c83a8aeb71..7e283a82d9 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -94,7 +94,7 @@ BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo) END_EVENT_TABLE() -#ifndef NO_TEXT_WINDOW_STREAM +#if wxUSE_STD_IOSTREAM wxTextCtrl::wxTextCtrl() : streambuf() { if (allocate()) setp(base(),ebuf()); @@ -108,7 +108,7 @@ wxTextCtrl::wxTextCtrl() } #endif -#ifndef NO_TEXT_WINDOW_STREAM +#if wxUSE_STD_IOSTREAM wxTextCtrl::wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value, const wxPoint &pos, const wxSize &size, int style, const wxValidator& validator, const wxString &name ) : streambuf() @@ -913,7 +913,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event ) key_event.Skip(); } -#ifndef NO_TEXT_WINDOW_STREAM +#if wxUSE_STD_IOSTREAM int wxTextCtrl::overflow( int WXUNUSED(c) ) { int len = pptr() - pbase(); @@ -942,6 +942,7 @@ int wxTextCtrl::underflow() { return EOF; } +#endif wxTextCtrl& wxTextCtrl::operator<<(const wxString& s) { @@ -990,7 +991,6 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c) AppendText(buf); return *this; } -#endif GtkWidget* wxTextCtrl::GetConnectWidget() { diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index c83a8aeb71..7e283a82d9 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -94,7 +94,7 @@ BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo) END_EVENT_TABLE() -#ifndef NO_TEXT_WINDOW_STREAM +#if wxUSE_STD_IOSTREAM wxTextCtrl::wxTextCtrl() : streambuf() { if (allocate()) setp(base(),ebuf()); @@ -108,7 +108,7 @@ wxTextCtrl::wxTextCtrl() } #endif -#ifndef NO_TEXT_WINDOW_STREAM +#if wxUSE_STD_IOSTREAM wxTextCtrl::wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value, const wxPoint &pos, const wxSize &size, int style, const wxValidator& validator, const wxString &name ) : streambuf() @@ -913,7 +913,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event ) key_event.Skip(); } -#ifndef NO_TEXT_WINDOW_STREAM +#if wxUSE_STD_IOSTREAM int wxTextCtrl::overflow( int WXUNUSED(c) ) { int len = pptr() - pbase(); @@ -942,6 +942,7 @@ int wxTextCtrl::underflow() { return EOF; } +#endif wxTextCtrl& wxTextCtrl::operator<<(const wxString& s) { @@ -990,7 +991,6 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c) AppendText(buf); return *this; } -#endif GtkWidget* wxTextCtrl::GetConnectWidget() { -- 2.45.2