From 83141d3a74bc3ce6b97632dec8b28b7569c480a2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 12 Sep 2000 15:15:44 +0000 Subject: [PATCH] 1. removed 'B' flag from treebase.cpp and regenerated the makefiles 2. fixed wxMemoryInputStream::Eof() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8340 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- distrib/msw/tmake/filelist.txt | 2 +- include/wx/cursor.h | 1 + include/wx/mstream.h | 61 ++++++++++++++++++---------------- samples/console/console.cpp | 34 ++++++++++++++++++- src/common/mstream.cpp | 25 ++++++++++---- src/files.lst | 6 +--- src/gtk/files.lst | 2 +- src/gtk1/files.lst | 2 +- src/motif/files.lst | 6 +++- src/msw/makefile.b32 | 2 +- src/msw/makefile.bcc | 2 +- src/msw/makefile.dos | 2 +- src/msw/makefile.g95 | 2 +- src/msw/makefile.sc | 2 +- src/msw/makefile.vc | 2 +- src/msw/makefile.wat | 2 +- 16 files changed, 100 insertions(+), 53 deletions(-) diff --git a/distrib/msw/tmake/filelist.txt b/distrib/msw/tmake/filelist.txt index 488c004db6..c23655e71e 100644 --- a/distrib/msw/tmake/filelist.txt +++ b/distrib/msw/tmake/filelist.txt @@ -195,7 +195,7 @@ textcmn.cpp C textfile.cpp C B timercmn.cpp C B tokenzr.cpp C B -treebase.cpp C B +treebase.cpp C txtstrm.cpp C B unzip.c C B url.cpp C S,B diff --git a/include/wx/cursor.h b/include/wx/cursor.h index 10bc6a0cc3..e4cf1106df 100644 --- a/include/wx/cursor.h +++ b/include/wx/cursor.h @@ -18,6 +18,7 @@ #endif #include "wx/utils.h" + /* This is a small class which can be used by all ports to temporarily suspend the busy cursor. Useful in modal dialogs. diff --git a/include/wx/mstream.h b/include/wx/mstream.h index 85e0b30e35..bdb4a65997 100644 --- a/include/wx/mstream.h +++ b/include/wx/mstream.h @@ -8,6 +8,7 @@ // Copyright: (c) Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// + #ifndef _WX_WXMMSTREAM_H__ #define _WX_WXMMSTREAM_H__ @@ -15,45 +16,47 @@ #if wxUSE_STREAMS -class WXDLLEXPORT wxMemoryInputStream: public wxInputStream { - private: - size_t m_length; - - public: - wxMemoryInputStream(const char *data, size_t length); - virtual ~wxMemoryInputStream(); - virtual size_t GetSize() const { return m_length; } +class WXDLLEXPORT wxMemoryInputStream : public wxInputStream +{ +public: + wxMemoryInputStream(const char *data, size_t length); + virtual ~wxMemoryInputStream(); + virtual size_t GetSize() const { return m_length; } + virtual bool Eof() const; + + char Peek(); - char Peek(); + wxStreamBuffer *InputStreamBuffer() const { return m_i_streambuf; } - wxStreamBuffer *InputStreamBuffer() const { return m_i_streambuf; } +protected: + wxStreamBuffer *m_i_streambuf; - protected: - wxStreamBuffer *m_i_streambuf; + size_t OnSysRead(void *buffer, size_t nbytes); + off_t OnSysSeek(off_t pos, wxSeekMode mode); + off_t OnSysTell() const; - protected: - size_t OnSysRead(void *buffer, size_t nbytes); - off_t OnSysSeek(off_t pos, wxSeekMode mode); - off_t OnSysTell() const; +private: + size_t m_length; }; -class WXDLLEXPORT wxMemoryOutputStream: public wxOutputStream { - public: - wxMemoryOutputStream(char *data = NULL, size_t length = 0); - virtual ~wxMemoryOutputStream(); - virtual size_t GetSize() const { return m_o_streambuf->GetLastAccess(); } +class WXDLLEXPORT wxMemoryOutputStream : public wxOutputStream +{ +public: + wxMemoryOutputStream(char *data = NULL, size_t length = 0); + virtual ~wxMemoryOutputStream(); + virtual size_t GetSize() const { return m_o_streambuf->GetLastAccess(); } - wxStreamBuffer *OutputStreamBuffer() const { return m_o_streambuf; } + wxStreamBuffer *OutputStreamBuffer() const { return m_o_streambuf; } - size_t CopyTo(char *buffer, size_t len) const; + size_t CopyTo(char *buffer, size_t len) const; - protected: - wxStreamBuffer *m_o_streambuf; +protected: + wxStreamBuffer *m_o_streambuf; - protected: - size_t OnSysWrite(const void *buffer, size_t nbytes); - off_t OnSysSeek(off_t pos, wxSeekMode mode); - off_t OnSysTell() const; +protected: + size_t OnSysWrite(const void *buffer, size_t nbytes); + off_t OnSysSeek(off_t pos, wxSeekMode mode); + off_t OnSysTell() const; }; #endif diff --git a/samples/console/console.cpp b/samples/console/console.cpp index a935db655f..e33f32e87c 100644 --- a/samples/console/console.cpp +++ b/samples/console/console.cpp @@ -41,7 +41,7 @@ //#define TEST_DIR //#define TEST_DLLLOADER //#define TEST_EXECUTE -#define TEST_FILE +//#define TEST_FILE //#define TEST_FILECONF //#define TEST_HASH //#define TEST_LIST @@ -50,6 +50,7 @@ //#define TEST_MIME //#define TEST_INFO_FUNCTIONS //#define TEST_SOCKETS +#define TEST_STREAMS //#define TEST_STRINGS //#define TEST_THREADS //#define TEST_TIMER @@ -1301,6 +1302,33 @@ static void TestProtocolFtpUpload() #endif // TEST_SOCKETS +// ---------------------------------------------------------------------------- +// streams +// ---------------------------------------------------------------------------- + +#ifdef TEST_STREAMS + +#include + +static void TestMemoryStream() +{ + puts("*** Testing wxMemoryInputStream ***"); + + wxChar buf[1024]; + wxStrncpy(buf, _T("Hello, stream!"), WXSIZEOF(buf)); + + wxMemoryInputStream memInpStream(buf, wxStrlen(buf)); + printf(_T("Memory stream size: %u\n"), memInpStream.GetSize()); + while ( !memInpStream.Eof() ) + { + putchar(memInpStream.GetC()); + } + + puts("\n*** wxMemoryInputStream test done ***"); +} + +#endif // TEST_STREAMS + // ---------------------------------------------------------------------------- // timers // ---------------------------------------------------------------------------- @@ -3594,6 +3622,10 @@ int main(int argc, char **argv) TestProtocolFtpUpload(); #endif // TEST_SOCKETS +#ifdef TEST_STREAMS + TestMemoryStream(); +#endif // TEST_STREAMS + #ifdef TEST_TIMER TestStopWatch(); #endif // TEST_TIMER diff --git a/src/common/mstream.cpp b/src/common/mstream.cpp index b0819a26ce..b0f1ab6a1a 100644 --- a/src/common/mstream.cpp +++ b/src/common/mstream.cpp @@ -51,14 +51,25 @@ char wxMemoryInputStream::Peek() return m_i_streambuf->GetBufferStart()[m_i_streambuf->GetIntPosition()]; } +bool wxMemoryInputStream::Eof() const +{ + return m_i_streambuf->GetBufferPos() == m_i_streambuf->GetBufferEnd(); +} + size_t wxMemoryInputStream::OnSysRead(void *buffer, size_t nbytes) -{ - size_t bufsize = m_i_streambuf->GetBufferEnd() - m_i_streambuf->GetBufferStart(); - size_t oldpos = m_i_streambuf->GetIntPosition(); - m_i_streambuf->Read(buffer, nbytes); - size_t newpos = m_i_streambuf->GetIntPosition(); - if (newpos == 0) return bufsize - oldpos; - else return newpos - oldpos; +{ + size_t pos = m_i_streambuf->GetIntPosition(); + if ( pos == m_length ) + { + m_lasterror = wxSTREAM_EOF; + + return 0; + } + + m_i_streambuf->Read(buffer, nbytes); + m_lasterror = wxSTREAM_NOERROR; + + return m_i_streambuf->GetIntPosition() - pos; } off_t wxMemoryInputStream::OnSysSeek(off_t pos, wxSeekMode mode) diff --git a/src/files.lst b/src/files.lst index 8a7b8b0fb2..c2d6bf2521 100644 --- a/src/files.lst +++ b/src/files.lst @@ -1,4 +1,4 @@ -# This file was automatically generated by tmake at 19:28, 2000/09/10 +# This file was automatically generated by tmake at 18:13, 2000/09/12 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BASE.T! ALL_SOURCES = \ common/init.cpp \ @@ -48,7 +48,6 @@ ALL_SOURCES = \ common/textfile.cpp \ common/timercmn.cpp \ common/tokenzr.cpp \ - common/treebase.cpp \ common/txtstrm.cpp \ common/unzip.c \ common/url.cpp \ @@ -191,7 +190,6 @@ BASE_OBJS = \ textfile.o \ timercmn.o \ tokenzr.o \ - treebase.o \ txtstrm.o \ unzip.o \ url.o \ @@ -250,7 +248,6 @@ BASE_DEPS = \ textfile.d \ timercmn.d \ tokenzr.d \ - treebase.d \ txtstrm.d \ unzip.d \ url.d \ @@ -316,7 +313,6 @@ BASE_DEPS = \ textfile.d \ timercmn.d \ tokenzr.d \ - treebase.d \ txtstrm.d \ unzip.d \ url.d \ diff --git a/src/gtk/files.lst b/src/gtk/files.lst index 56c215bf58..ac24d8ecbf 100644 --- a/src/gtk/files.lst +++ b/src/gtk/files.lst @@ -1,4 +1,4 @@ -# This file was automatically generated by tmake at 19:28, 2000/09/10 +# This file was automatically generated by tmake at 18:13, 2000/09/12 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE GTK.T! ALL_SOURCES = \ generic/busyinfo.cpp \ diff --git a/src/gtk1/files.lst b/src/gtk1/files.lst index 56c215bf58..ac24d8ecbf 100644 --- a/src/gtk1/files.lst +++ b/src/gtk1/files.lst @@ -1,4 +1,4 @@ -# This file was automatically generated by tmake at 19:28, 2000/09/10 +# This file was automatically generated by tmake at 18:13, 2000/09/12 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE GTK.T! ALL_SOURCES = \ generic/busyinfo.cpp \ diff --git a/src/motif/files.lst b/src/motif/files.lst index 23f375dabf..accc9725a2 100644 --- a/src/motif/files.lst +++ b/src/motif/files.lst @@ -1,4 +1,4 @@ -# This file was automatically generated by tmake at 11:57, 2000/09/08 +# This file was automatically generated by tmake at 18:13, 2000/09/12 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE MOTIF.T! ALL_SOURCES = \ generic/busyinfo.cpp \ @@ -42,6 +42,7 @@ ALL_SOURCES = \ generic/tbarsmpl.cpp \ generic/textdlgg.cpp \ generic/tipdlg.cpp \ + generic/tipwin.cpp \ generic/treectlg.cpp \ generic/treelay.cpp \ generic/wizard.cpp \ @@ -410,6 +411,7 @@ ALL_HEADERS = \ time.h \ timer.h \ tipdlg.h \ + tipwin.h \ tokenzr.h \ toolbar.h \ tooltip.h \ @@ -807,6 +809,7 @@ GENERICOBJS = \ tbarsmpl.o \ textdlgg.o \ tipdlg.o \ + tipwin.o \ treectlg.o \ treelay.o \ wizard.o @@ -853,6 +856,7 @@ GENERICDEPS = \ tbarsmpl.d \ textdlgg.d \ tipdlg.d \ + tipwin.d \ treectlg.d \ treelay.d \ wizard.d diff --git a/src/msw/makefile.b32 b/src/msw/makefile.b32 index 8e2465b4d0..3e2c329a81 100644 --- a/src/msw/makefile.b32 +++ b/src/msw/makefile.b32 @@ -1,6 +1,6 @@ -# This file was automatically generated by tmake at 19:28, 2000/09/10 +# This file was automatically generated by tmake at 18:13, 2000/09/12 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE B32.T! # diff --git a/src/msw/makefile.bcc b/src/msw/makefile.bcc index a364ab42a5..6638c396cc 100644 --- a/src/msw/makefile.bcc +++ b/src/msw/makefile.bcc @@ -1,6 +1,6 @@ -# This file was automatically generated by tmake at 19:28, 2000/09/10 +# This file was automatically generated by tmake at 18:13, 2000/09/12 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BCC.T! # diff --git a/src/msw/makefile.dos b/src/msw/makefile.dos index 916ace01b2..de7986e759 100644 --- a/src/msw/makefile.dos +++ b/src/msw/makefile.dos @@ -1,4 +1,4 @@ -# This file was automatically generated by tmake at 19:28, 2000/09/10 +# This file was automatically generated by tmake at 18:13, 2000/09/12 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE DOS.T! # diff --git a/src/msw/makefile.g95 b/src/msw/makefile.g95 index 0240840c68..416097f0bf 100644 --- a/src/msw/makefile.g95 +++ b/src/msw/makefile.g95 @@ -1,4 +1,4 @@ -# This file was automatically generated by tmake at 19:28, 2000/09/10 +# This file was automatically generated by tmake at 18:13, 2000/09/12 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE G95.T! # diff --git a/src/msw/makefile.sc b/src/msw/makefile.sc index 25562cbae3..90fd9ac53e 100644 --- a/src/msw/makefile.sc +++ b/src/msw/makefile.sc @@ -1,6 +1,6 @@ -# This file was automatically generated by tmake at 19:28, 2000/09/10 +# This file was automatically generated by tmake at 18:13, 2000/09/12 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE SC.T! # Symantec C++ makefile for the msw objects diff --git a/src/msw/makefile.vc b/src/msw/makefile.vc index f719d708d0..a6a1bc883b 100644 --- a/src/msw/makefile.vc +++ b/src/msw/makefile.vc @@ -1,4 +1,4 @@ -# This file was automatically generated by tmake at 19:28, 2000/09/10 +# This file was automatically generated by tmake at 18:13, 2000/09/12 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE VC.T! # File: makefile.vc diff --git a/src/msw/makefile.wat b/src/msw/makefile.wat index a6f93a7178..2227c9090e 100644 --- a/src/msw/makefile.wat +++ b/src/msw/makefile.wat @@ -1,6 +1,6 @@ #!/binb/wmake.exe -# This file was automatically generated by tmake at 19:28, 2000/09/10 +# This file was automatically generated by tmake at 18:13, 2000/09/12 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE WAT.T! # -- 2.45.2