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
This commit is contained in:
Vadim Zeitlin 2000-09-12 15:15:44 +00:00
parent 5100cabffa
commit 83141d3a74
16 changed files with 100 additions and 53 deletions

View File

@ -195,7 +195,7 @@ textcmn.cpp C
textfile.cpp C B textfile.cpp C B
timercmn.cpp C B timercmn.cpp C B
tokenzr.cpp C B tokenzr.cpp C B
treebase.cpp C B treebase.cpp C
txtstrm.cpp C B txtstrm.cpp C B
unzip.c C B unzip.c C B
url.cpp C S,B url.cpp C S,B

View File

@ -18,6 +18,7 @@
#endif #endif
#include "wx/utils.h" #include "wx/utils.h"
/* This is a small class which can be used by all ports /* This is a small class which can be used by all ports
to temporarily suspend the busy cursor. Useful in modal to temporarily suspend the busy cursor. Useful in modal
dialogs. dialogs.

View File

@ -8,6 +8,7 @@
// Copyright: (c) Guilhem Lavaux // Copyright: (c) Guilhem Lavaux
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_WXMMSTREAM_H__ #ifndef _WX_WXMMSTREAM_H__
#define _WX_WXMMSTREAM_H__ #define _WX_WXMMSTREAM_H__
@ -15,45 +16,47 @@
#if wxUSE_STREAMS #if wxUSE_STREAMS
class WXDLLEXPORT wxMemoryInputStream: public wxInputStream { class WXDLLEXPORT wxMemoryInputStream : public wxInputStream
private: {
size_t m_length; public:
wxMemoryInputStream(const char *data, size_t length);
public: virtual ~wxMemoryInputStream();
wxMemoryInputStream(const char *data, size_t length); virtual size_t GetSize() const { return m_length; }
virtual ~wxMemoryInputStream(); virtual bool Eof() const;
virtual size_t GetSize() const { return m_length; }
char Peek(); char Peek();
wxStreamBuffer *InputStreamBuffer() const { return m_i_streambuf; } wxStreamBuffer *InputStreamBuffer() const { return m_i_streambuf; }
protected: protected:
wxStreamBuffer *m_i_streambuf; wxStreamBuffer *m_i_streambuf;
protected: size_t OnSysRead(void *buffer, size_t nbytes);
size_t OnSysRead(void *buffer, size_t nbytes); off_t OnSysSeek(off_t pos, wxSeekMode mode);
off_t OnSysSeek(off_t pos, wxSeekMode mode); off_t OnSysTell() const;
off_t OnSysTell() const;
private:
size_t m_length;
}; };
class WXDLLEXPORT wxMemoryOutputStream: public wxOutputStream { class WXDLLEXPORT wxMemoryOutputStream : public wxOutputStream
public: {
wxMemoryOutputStream(char *data = NULL, size_t length = 0); public:
virtual ~wxMemoryOutputStream(); wxMemoryOutputStream(char *data = NULL, size_t length = 0);
virtual size_t GetSize() const { return m_o_streambuf->GetLastAccess(); } 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: protected:
wxStreamBuffer *m_o_streambuf; wxStreamBuffer *m_o_streambuf;
protected: protected:
size_t OnSysWrite(const void *buffer, size_t nbytes); size_t OnSysWrite(const void *buffer, size_t nbytes);
off_t OnSysSeek(off_t pos, wxSeekMode mode); off_t OnSysSeek(off_t pos, wxSeekMode mode);
off_t OnSysTell() const; off_t OnSysTell() const;
}; };
#endif #endif

View File

@ -41,7 +41,7 @@
//#define TEST_DIR //#define TEST_DIR
//#define TEST_DLLLOADER //#define TEST_DLLLOADER
//#define TEST_EXECUTE //#define TEST_EXECUTE
#define TEST_FILE //#define TEST_FILE
//#define TEST_FILECONF //#define TEST_FILECONF
//#define TEST_HASH //#define TEST_HASH
//#define TEST_LIST //#define TEST_LIST
@ -50,6 +50,7 @@
//#define TEST_MIME //#define TEST_MIME
//#define TEST_INFO_FUNCTIONS //#define TEST_INFO_FUNCTIONS
//#define TEST_SOCKETS //#define TEST_SOCKETS
#define TEST_STREAMS
//#define TEST_STRINGS //#define TEST_STRINGS
//#define TEST_THREADS //#define TEST_THREADS
//#define TEST_TIMER //#define TEST_TIMER
@ -1301,6 +1302,33 @@ static void TestProtocolFtpUpload()
#endif // TEST_SOCKETS #endif // TEST_SOCKETS
// ----------------------------------------------------------------------------
// streams
// ----------------------------------------------------------------------------
#ifdef TEST_STREAMS
#include <wx/mstream.h>
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 // timers
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -3594,6 +3622,10 @@ int main(int argc, char **argv)
TestProtocolFtpUpload(); TestProtocolFtpUpload();
#endif // TEST_SOCKETS #endif // TEST_SOCKETS
#ifdef TEST_STREAMS
TestMemoryStream();
#endif // TEST_STREAMS
#ifdef TEST_TIMER #ifdef TEST_TIMER
TestStopWatch(); TestStopWatch();
#endif // TEST_TIMER #endif // TEST_TIMER

View File

@ -51,14 +51,25 @@ char wxMemoryInputStream::Peek()
return m_i_streambuf->GetBufferStart()[m_i_streambuf->GetIntPosition()]; 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 wxMemoryInputStream::OnSysRead(void *buffer, size_t nbytes)
{ {
size_t bufsize = m_i_streambuf->GetBufferEnd() - m_i_streambuf->GetBufferStart(); size_t pos = m_i_streambuf->GetIntPosition();
size_t oldpos = m_i_streambuf->GetIntPosition(); if ( pos == m_length )
m_i_streambuf->Read(buffer, nbytes); {
size_t newpos = m_i_streambuf->GetIntPosition(); m_lasterror = wxSTREAM_EOF;
if (newpos == 0) return bufsize - oldpos;
else return newpos - oldpos; 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) off_t wxMemoryInputStream::OnSysSeek(off_t pos, wxSeekMode mode)

View File

@ -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! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BASE.T!
ALL_SOURCES = \ ALL_SOURCES = \
common/init.cpp \ common/init.cpp \
@ -48,7 +48,6 @@ ALL_SOURCES = \
common/textfile.cpp \ common/textfile.cpp \
common/timercmn.cpp \ common/timercmn.cpp \
common/tokenzr.cpp \ common/tokenzr.cpp \
common/treebase.cpp \
common/txtstrm.cpp \ common/txtstrm.cpp \
common/unzip.c \ common/unzip.c \
common/url.cpp \ common/url.cpp \
@ -191,7 +190,6 @@ BASE_OBJS = \
textfile.o \ textfile.o \
timercmn.o \ timercmn.o \
tokenzr.o \ tokenzr.o \
treebase.o \
txtstrm.o \ txtstrm.o \
unzip.o \ unzip.o \
url.o \ url.o \
@ -250,7 +248,6 @@ BASE_DEPS = \
textfile.d \ textfile.d \
timercmn.d \ timercmn.d \
tokenzr.d \ tokenzr.d \
treebase.d \
txtstrm.d \ txtstrm.d \
unzip.d \ unzip.d \
url.d \ url.d \
@ -316,7 +313,6 @@ BASE_DEPS = \
textfile.d \ textfile.d \
timercmn.d \ timercmn.d \
tokenzr.d \ tokenzr.d \
treebase.d \
txtstrm.d \ txtstrm.d \
unzip.d \ unzip.d \
url.d \ url.d \

View File

@ -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! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE GTK.T!
ALL_SOURCES = \ ALL_SOURCES = \
generic/busyinfo.cpp \ generic/busyinfo.cpp \

View File

@ -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! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE GTK.T!
ALL_SOURCES = \ ALL_SOURCES = \
generic/busyinfo.cpp \ generic/busyinfo.cpp \

View File

@ -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! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE MOTIF.T!
ALL_SOURCES = \ ALL_SOURCES = \
generic/busyinfo.cpp \ generic/busyinfo.cpp \
@ -42,6 +42,7 @@ ALL_SOURCES = \
generic/tbarsmpl.cpp \ generic/tbarsmpl.cpp \
generic/textdlgg.cpp \ generic/textdlgg.cpp \
generic/tipdlg.cpp \ generic/tipdlg.cpp \
generic/tipwin.cpp \
generic/treectlg.cpp \ generic/treectlg.cpp \
generic/treelay.cpp \ generic/treelay.cpp \
generic/wizard.cpp \ generic/wizard.cpp \
@ -410,6 +411,7 @@ ALL_HEADERS = \
time.h \ time.h \
timer.h \ timer.h \
tipdlg.h \ tipdlg.h \
tipwin.h \
tokenzr.h \ tokenzr.h \
toolbar.h \ toolbar.h \
tooltip.h \ tooltip.h \
@ -807,6 +809,7 @@ GENERICOBJS = \
tbarsmpl.o \ tbarsmpl.o \
textdlgg.o \ textdlgg.o \
tipdlg.o \ tipdlg.o \
tipwin.o \
treectlg.o \ treectlg.o \
treelay.o \ treelay.o \
wizard.o wizard.o
@ -853,6 +856,7 @@ GENERICDEPS = \
tbarsmpl.d \ tbarsmpl.d \
textdlgg.d \ textdlgg.d \
tipdlg.d \ tipdlg.d \
tipwin.d \
treectlg.d \ treectlg.d \
treelay.d \ treelay.d \
wizard.d wizard.d

View File

@ -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! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE B32.T!
# #

View File

@ -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! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BCC.T!
# #

View File

@ -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! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE DOS.T!
# #

View File

@ -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! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE G95.T!
# #

View File

@ -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! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE SC.T!
# Symantec C++ makefile for the msw objects # Symantec C++ makefile for the msw objects

View File

@ -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! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE VC.T!
# File: makefile.vc # File: makefile.vc

View File

@ -1,6 +1,6 @@
#!/binb/wmake.exe #!/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! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE WAT.T!
# #