wx/stack.h \
wx/stackwalk.h \
wx/stdpaths.h \
+ wx/stdstream.h \
wx/stockitem.h \
wx/stopwatch.h \
wx/strconv.h \
wx/stack.h \
wx/stackwalk.h \
wx/stdpaths.h \
+ wx/stdstream.h \
wx/stockitem.h \
wx/stopwatch.h \
wx/strconv.h \
src/common/regex.cpp \
src/common/stdpbase.cpp \
src/common/sstream.cpp \
+ src/common/stdstream.cpp \
src/common/stopwatch.cpp \
src/common/strconv.cpp \
src/common/stream.cpp \
monodll_regex.o \
monodll_stdpbase.o \
monodll_sstream.o \
+ monodll_stdstream.o \
monodll_stopwatch.o \
monodll_strconv.o \
monodll_stream.o \
monolib_regex.o \
monolib_stdpbase.o \
monolib_sstream.o \
+ monolib_stdstream.o \
monolib_stopwatch.o \
monolib_strconv.o \
monolib_stream.o \
basedll_regex.o \
basedll_stdpbase.o \
basedll_sstream.o \
+ basedll_stdstream.o \
basedll_stopwatch.o \
basedll_strconv.o \
basedll_stream.o \
baselib_regex.o \
baselib_stdpbase.o \
baselib_sstream.o \
+ baselib_stdstream.o \
baselib_stopwatch.o \
baselib_strconv.o \
baselib_stream.o \
monodll_sstream.o: $(srcdir)/src/common/sstream.cpp $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/sstream.cpp
+monodll_stdstream.o: $(srcdir)/src/common/stdstream.cpp $(MONODLL_ODEP)
+ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/stdstream.cpp
+
monodll_stopwatch.o: $(srcdir)/src/common/stopwatch.cpp $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/stopwatch.cpp
monolib_sstream.o: $(srcdir)/src/common/sstream.cpp $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/sstream.cpp
+monolib_stdstream.o: $(srcdir)/src/common/stdstream.cpp $(MONOLIB_ODEP)
+ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/stdstream.cpp
+
monolib_stopwatch.o: $(srcdir)/src/common/stopwatch.cpp $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/stopwatch.cpp
basedll_sstream.o: $(srcdir)/src/common/sstream.cpp $(BASEDLL_ODEP)
$(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/common/sstream.cpp
+basedll_stdstream.o: $(srcdir)/src/common/stdstream.cpp $(BASEDLL_ODEP)
+ $(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/common/stdstream.cpp
+
basedll_stopwatch.o: $(srcdir)/src/common/stopwatch.cpp $(BASEDLL_ODEP)
$(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/common/stopwatch.cpp
baselib_sstream.o: $(srcdir)/src/common/sstream.cpp $(BASELIB_ODEP)
$(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/common/sstream.cpp
+baselib_stdstream.o: $(srcdir)/src/common/stdstream.cpp $(BASELIB_ODEP)
+ $(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/common/stdstream.cpp
+
baselib_stopwatch.o: $(srcdir)/src/common/stopwatch.cpp $(BASELIB_ODEP)
$(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/common/stopwatch.cpp
src/common/regex.cpp
src/common/stdpbase.cpp
src/common/sstream.cpp
+ src/common/stdstream.cpp
src/common/stopwatch.cpp
src/common/strconv.cpp
src/common/stream.cpp
wx/stack.h
wx/stackwalk.h
wx/stdpaths.h
+ wx/stdstream.h
wx/stockitem.h
wx/stopwatch.h
wx/strconv.h
$(OBJS)\monodll_regex.obj \
$(OBJS)\monodll_stdpbase.obj \
$(OBJS)\monodll_sstream.obj \
+ $(OBJS)\monodll_stdstream.obj \
$(OBJS)\monodll_stopwatch.obj \
$(OBJS)\monodll_strconv.obj \
$(OBJS)\monodll_stream.obj \
$(OBJS)\monolib_regex.obj \
$(OBJS)\monolib_stdpbase.obj \
$(OBJS)\monolib_sstream.obj \
+ $(OBJS)\monolib_stdstream.obj \
$(OBJS)\monolib_stopwatch.obj \
$(OBJS)\monolib_strconv.obj \
$(OBJS)\monolib_stream.obj \
$(OBJS)\basedll_regex.obj \
$(OBJS)\basedll_stdpbase.obj \
$(OBJS)\basedll_sstream.obj \
+ $(OBJS)\basedll_stdstream.obj \
$(OBJS)\basedll_stopwatch.obj \
$(OBJS)\basedll_strconv.obj \
$(OBJS)\basedll_stream.obj \
$(OBJS)\baselib_regex.obj \
$(OBJS)\baselib_stdpbase.obj \
$(OBJS)\baselib_sstream.obj \
+ $(OBJS)\baselib_stdstream.obj \
$(OBJS)\baselib_stopwatch.obj \
$(OBJS)\baselib_strconv.obj \
$(OBJS)\baselib_stream.obj \
$(OBJS)\monodll_sstream.obj: ..\..\src\common\sstream.cpp
$(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\common\sstream.cpp
+$(OBJS)\monodll_stdstream.obj: ..\..\src\common\stdstream.cpp
+ $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\common\stdstream.cpp
+
$(OBJS)\monodll_stopwatch.obj: ..\..\src\common\stopwatch.cpp
$(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\common\stopwatch.cpp
$(OBJS)\monolib_sstream.obj: ..\..\src\common\sstream.cpp
$(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\sstream.cpp
+$(OBJS)\monolib_stdstream.obj: ..\..\src\common\stdstream.cpp
+ $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\stdstream.cpp
+
$(OBJS)\monolib_stopwatch.obj: ..\..\src\common\stopwatch.cpp
$(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\stopwatch.cpp
$(OBJS)\basedll_sstream.obj: ..\..\src\common\sstream.cpp
$(CXX) -q -c -P -o$@ $(BASEDLL_CXXFLAGS) ..\..\src\common\sstream.cpp
+$(OBJS)\basedll_stdstream.obj: ..\..\src\common\stdstream.cpp
+ $(CXX) -q -c -P -o$@ $(BASEDLL_CXXFLAGS) ..\..\src\common\stdstream.cpp
+
$(OBJS)\basedll_stopwatch.obj: ..\..\src\common\stopwatch.cpp
$(CXX) -q -c -P -o$@ $(BASEDLL_CXXFLAGS) ..\..\src\common\stopwatch.cpp
$(OBJS)\baselib_sstream.obj: ..\..\src\common\sstream.cpp
$(CXX) -q -c -P -o$@ $(BASELIB_CXXFLAGS) ..\..\src\common\sstream.cpp
+$(OBJS)\baselib_stdstream.obj: ..\..\src\common\stdstream.cpp
+ $(CXX) -q -c -P -o$@ $(BASELIB_CXXFLAGS) ..\..\src\common\stdstream.cpp
+
$(OBJS)\baselib_stopwatch.obj: ..\..\src\common\stopwatch.cpp
$(CXX) -q -c -P -o$@ $(BASELIB_CXXFLAGS) ..\..\src\common\stopwatch.cpp
$(OBJS)\monodll_regex.o \
$(OBJS)\monodll_stdpbase.o \
$(OBJS)\monodll_sstream.o \
+ $(OBJS)\monodll_stdstream.o \
$(OBJS)\monodll_stopwatch.o \
$(OBJS)\monodll_strconv.o \
$(OBJS)\monodll_stream.o \
$(OBJS)\monolib_regex.o \
$(OBJS)\monolib_stdpbase.o \
$(OBJS)\monolib_sstream.o \
+ $(OBJS)\monolib_stdstream.o \
$(OBJS)\monolib_stopwatch.o \
$(OBJS)\monolib_strconv.o \
$(OBJS)\monolib_stream.o \
$(OBJS)\basedll_regex.o \
$(OBJS)\basedll_stdpbase.o \
$(OBJS)\basedll_sstream.o \
+ $(OBJS)\basedll_stdstream.o \
$(OBJS)\basedll_stopwatch.o \
$(OBJS)\basedll_strconv.o \
$(OBJS)\basedll_stream.o \
$(OBJS)\baselib_regex.o \
$(OBJS)\baselib_stdpbase.o \
$(OBJS)\baselib_sstream.o \
+ $(OBJS)\baselib_stdstream.o \
$(OBJS)\baselib_stopwatch.o \
$(OBJS)\baselib_strconv.o \
$(OBJS)\baselib_stream.o \
$(OBJS)\monodll_sstream.o: ../../src/common/sstream.cpp
$(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\monodll_stdstream.o: ../../src/common/stdstream.cpp
+ $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\monodll_stopwatch.o: ../../src/common/stopwatch.cpp
$(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\monolib_sstream.o: ../../src/common/sstream.cpp
$(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\monolib_stdstream.o: ../../src/common/stdstream.cpp
+ $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\monolib_stopwatch.o: ../../src/common/stopwatch.cpp
$(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\basedll_sstream.o: ../../src/common/sstream.cpp
$(CXX) -c -o $@ $(BASEDLL_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\basedll_stdstream.o: ../../src/common/stdstream.cpp
+ $(CXX) -c -o $@ $(BASEDLL_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\basedll_stopwatch.o: ../../src/common/stopwatch.cpp
$(CXX) -c -o $@ $(BASEDLL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\baselib_sstream.o: ../../src/common/sstream.cpp
$(CXX) -c -o $@ $(BASELIB_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\baselib_stdstream.o: ../../src/common/stdstream.cpp
+ $(CXX) -c -o $@ $(BASELIB_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\baselib_stopwatch.o: ../../src/common/stopwatch.cpp
$(CXX) -c -o $@ $(BASELIB_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\monodll_regex.obj \
$(OBJS)\monodll_stdpbase.obj \
$(OBJS)\monodll_sstream.obj \
+ $(OBJS)\monodll_stdstream.obj \
$(OBJS)\monodll_stopwatch.obj \
$(OBJS)\monodll_strconv.obj \
$(OBJS)\monodll_stream.obj \
$(OBJS)\monolib_regex.obj \
$(OBJS)\monolib_stdpbase.obj \
$(OBJS)\monolib_sstream.obj \
+ $(OBJS)\monolib_stdstream.obj \
$(OBJS)\monolib_stopwatch.obj \
$(OBJS)\monolib_strconv.obj \
$(OBJS)\monolib_stream.obj \
$(OBJS)\basedll_regex.obj \
$(OBJS)\basedll_stdpbase.obj \
$(OBJS)\basedll_sstream.obj \
+ $(OBJS)\basedll_stdstream.obj \
$(OBJS)\basedll_stopwatch.obj \
$(OBJS)\basedll_strconv.obj \
$(OBJS)\basedll_stream.obj \
$(OBJS)\baselib_regex.obj \
$(OBJS)\baselib_stdpbase.obj \
$(OBJS)\baselib_sstream.obj \
+ $(OBJS)\baselib_stdstream.obj \
$(OBJS)\baselib_stopwatch.obj \
$(OBJS)\baselib_strconv.obj \
$(OBJS)\baselib_stream.obj \
$(OBJS)\monodll_sstream.obj: ..\..\src\common\sstream.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\sstream.cpp
+$(OBJS)\monodll_stdstream.obj: ..\..\src\common\stdstream.cpp
+ $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\stdstream.cpp
+
$(OBJS)\monodll_stopwatch.obj: ..\..\src\common\stopwatch.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\stopwatch.cpp
$(OBJS)\monolib_sstream.obj: ..\..\src\common\sstream.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\sstream.cpp
+$(OBJS)\monolib_stdstream.obj: ..\..\src\common\stdstream.cpp
+ $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\stdstream.cpp
+
$(OBJS)\monolib_stopwatch.obj: ..\..\src\common\stopwatch.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\stopwatch.cpp
$(OBJS)\basedll_sstream.obj: ..\..\src\common\sstream.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BASEDLL_CXXFLAGS) ..\..\src\common\sstream.cpp
+$(OBJS)\basedll_stdstream.obj: ..\..\src\common\stdstream.cpp
+ $(CXX) /c /nologo /TP /Fo$@ $(BASEDLL_CXXFLAGS) ..\..\src\common\stdstream.cpp
+
$(OBJS)\basedll_stopwatch.obj: ..\..\src\common\stopwatch.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BASEDLL_CXXFLAGS) ..\..\src\common\stopwatch.cpp
$(OBJS)\baselib_sstream.obj: ..\..\src\common\sstream.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BASELIB_CXXFLAGS) ..\..\src\common\sstream.cpp
+$(OBJS)\baselib_stdstream.obj: ..\..\src\common\stdstream.cpp
+ $(CXX) /c /nologo /TP /Fo$@ $(BASELIB_CXXFLAGS) ..\..\src\common\stdstream.cpp
+
$(OBJS)\baselib_stopwatch.obj: ..\..\src\common\stopwatch.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BASELIB_CXXFLAGS) ..\..\src\common\stopwatch.cpp
$(OBJS)\monodll_regex.obj &
$(OBJS)\monodll_stdpbase.obj &
$(OBJS)\monodll_sstream.obj &
+ $(OBJS)\monodll_stdstream.obj &
$(OBJS)\monodll_stopwatch.obj &
$(OBJS)\monodll_strconv.obj &
$(OBJS)\monodll_stream.obj &
$(OBJS)\monolib_regex.obj &
$(OBJS)\monolib_stdpbase.obj &
$(OBJS)\monolib_sstream.obj &
+ $(OBJS)\monolib_stdstream.obj &
$(OBJS)\monolib_stopwatch.obj &
$(OBJS)\monolib_strconv.obj &
$(OBJS)\monolib_stream.obj &
$(OBJS)\basedll_regex.obj &
$(OBJS)\basedll_stdpbase.obj &
$(OBJS)\basedll_sstream.obj &
+ $(OBJS)\basedll_stdstream.obj &
$(OBJS)\basedll_stopwatch.obj &
$(OBJS)\basedll_strconv.obj &
$(OBJS)\basedll_stream.obj &
$(OBJS)\baselib_regex.obj &
$(OBJS)\baselib_stdpbase.obj &
$(OBJS)\baselib_sstream.obj &
+ $(OBJS)\baselib_stdstream.obj &
$(OBJS)\baselib_stopwatch.obj &
$(OBJS)\baselib_strconv.obj &
$(OBJS)\baselib_stream.obj &
$(OBJS)\monodll_sstream.obj : .AUTODEPEND ..\..\src\common\sstream.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $<
+$(OBJS)\monodll_stdstream.obj : .AUTODEPEND ..\..\src\common\stdstream.cpp
+ $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $<
+
$(OBJS)\monodll_stopwatch.obj : .AUTODEPEND ..\..\src\common\stopwatch.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $<
$(OBJS)\monolib_sstream.obj : .AUTODEPEND ..\..\src\common\sstream.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $<
+$(OBJS)\monolib_stdstream.obj : .AUTODEPEND ..\..\src\common\stdstream.cpp
+ $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $<
+
$(OBJS)\monolib_stopwatch.obj : .AUTODEPEND ..\..\src\common\stopwatch.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $<
$(OBJS)\basedll_sstream.obj : .AUTODEPEND ..\..\src\common\sstream.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(BASEDLL_CXXFLAGS) $<
+$(OBJS)\basedll_stdstream.obj : .AUTODEPEND ..\..\src\common\stdstream.cpp
+ $(CXX) -bt=nt -zq -fo=$^@ $(BASEDLL_CXXFLAGS) $<
+
$(OBJS)\basedll_stopwatch.obj : .AUTODEPEND ..\..\src\common\stopwatch.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(BASEDLL_CXXFLAGS) $<
$(OBJS)\baselib_sstream.obj : .AUTODEPEND ..\..\src\common\sstream.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(BASELIB_CXXFLAGS) $<
+$(OBJS)\baselib_stdstream.obj : .AUTODEPEND ..\..\src\common\stdstream.cpp
+ $(CXX) -bt=nt -zq -fo=$^@ $(BASELIB_CXXFLAGS) $<
+
$(OBJS)\baselib_stopwatch.obj : .AUTODEPEND ..\..\src\common\stopwatch.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(BASELIB_CXXFLAGS) $<
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\src\common\stdstream.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\src\common\stopwatch.cpp\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\include\wx\stdstream.h\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\include\wx\stockitem.h\r
# End Source File\r
# Begin Source File\r
<File\r
RelativePath="..\..\src\common\stdpbase.cpp">\r
</File>\r
+ <File\r
+ RelativePath="..\..\src\common\stdstream.cpp">\r
+ </File>\r
<File\r
RelativePath="..\..\src\common\stopwatch.cpp">\r
</File>\r
<File\r
RelativePath="..\..\include\wx\stdpaths.h">\r
</File>\r
+ <File\r
+ RelativePath="..\..\include\wx\stdstream.h">\r
+ </File>\r
<File\r
RelativePath="..\..\include\wx\stockitem.h">\r
</File>\r
RelativePath="..\..\src\common\stdpbase.cpp"\r
>\r
</File>\r
+ <File\r
+ RelativePath="..\..\src\common\stdstream.cpp"\r
+ >\r
+ </File>\r
<File\r
RelativePath="..\..\src\common\stopwatch.cpp"\r
>\r
RelativePath="..\..\include\wx\stdpaths.h"\r
>\r
</File>\r
+ <File\r
+ RelativePath="..\..\include\wx\stdstream.h"\r
+ >\r
+ </File>\r
<File\r
RelativePath="..\..\include\wx\stockitem.h"\r
>\r
RelativePath="..\..\src\common\stdpbase.cpp"\r
>\r
</File>\r
+ <File\r
+ RelativePath="..\..\src\common\stdstream.cpp"\r
+ >\r
+ </File>\r
<File\r
RelativePath="..\..\src\common\stopwatch.cpp"\r
>\r
RelativePath="..\..\include\wx\stdpaths.h"\r
>\r
</File>\r
+ <File\r
+ RelativePath="..\..\include\wx\stdstream.h"\r
+ >\r
+ </File>\r
<File\r
RelativePath="..\..\include\wx\stockitem.h"\r
>\r
All:
+- Added wxStd{Input,Output}Stream classes (Jonathan Liu).
- Include port number in host header in wxHTTP (Marcin 'Malcom' Malich).
All (GUI):
/////////////////////////////////////////////////////////////////////////////
// Name: stream.h
-// Purpose: topic overview
+// Purpose: stream classes overview
// Author: wxWidgets team
// RCS-ID: $Id$
// Licence: wxWindows license
@section overview_stream_intro Introduction
-wxWidgets provides its own set of stream classes in order to be
-independent of the standard C++ stream class and their different
-implementations.
+@subsection overview_stream_intro_std wxWidgets and Standard Streams
-Besides, using @c std::iostream on Linux makes impossible to write programs that are
-binary compatible across different Linux distributions.
+wxWidgets provides its own set of stream classes in order to support platforms
+not providing standard C++ streams implementation and also to make it possible
+to provide binary versions of wxWidgets application not depending on any
+particular standard library version. The wxWidgets stream classes also provide
+some functionality not available in the standard library such as support for
+several compression formats and possibility to work with sockets or text
+controls (for output only in the latter case).
-Therefore, wxStreams have been added to wxWidgets so that an applications can
-reliably compile and run on all supported platforms without dependence on a
-particular release of libg++.
+Nevertheless wxWidgets programs can also use standard stream classes and are
+encouraged to do so if the above considerations don't apply. Moreover,
+wxStdInputStream and wxStdOutputStream classes are provided to provide a degree
+of interoperability between the two and make it possible to use any wxWidgets
+stream as a standard stream (the converse possibility to use a standard stream
+as a wxWidgets stream is planned for a future release).
+
+
+@subsection overview_stream_intro_overview Stream Classes
wxStream classes are divided in two main groups:
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: wx/stdstream.h
+// Purpose: Header of std::istream and std::ostream derived wrappers for
+// wxInputStream and wxOutputStream
+// Author: Jonathan Liu <net147@gmail.com>
+// Created: 2009-05-02
+// RCS-ID: $Id$
+// Copyright: (c) 2009 Jonathan Liu
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_STDSTREAM_H_
+#define _WX_STDSTREAM_H_
+
+#include "wx/defs.h" // wxUSE_STD_IOSTREAM
+
+#if wxUSE_STD_IOSTREAM
+
+#include <iosfwd>
+#include <wx/defs.h>
+#include <wx/stream.h>
+
+// ==========================================================================
+// wxStdInputStreamBuffer
+// ==========================================================================
+
+class WXDLLIMPEXP_BASE wxStdInputStreamBuffer : public std::streambuf
+{
+public:
+ wxStdInputStreamBuffer(wxInputStream& stream);
+ virtual ~wxStdInputStreamBuffer() { }
+
+protected:
+ virtual std::streambuf *setbuf(char *s, std::streamsize n);
+ virtual std::streampos seekoff(std::streamoff off,
+ std::ios_base::seekdir way,
+ std::ios_base::openmode which =
+ std::ios_base::in |
+ std::ios_base::out);
+ virtual std::streampos seekpos(std::streampos sp,
+ std::ios_base::openmode which =
+ std::ios_base::in |
+ std::ios_base::out);
+ virtual std::streamsize showmanyc();
+ virtual std::streamsize xsgetn(char *s, std::streamsize n);
+ virtual int underflow();
+ virtual int uflow();
+ virtual int pbackfail(int c = EOF);
+
+ wxInputStream& m_stream;
+ int m_lastChar;
+};
+
+// ==========================================================================
+// wxStdInputStream
+// ==========================================================================
+
+class WXDLLIMPEXP_BASE wxStdInputStream : public std::istream
+{
+public:
+ wxStdInputStream(wxInputStream& stream);
+ virtual ~wxStdInputStream() { }
+
+protected:
+ wxStdInputStreamBuffer m_streamBuffer;
+};
+
+// ==========================================================================
+// wxStdOutputStreamBuffer
+// ==========================================================================
+
+class WXDLLIMPEXP_BASE wxStdOutputStreamBuffer : public std::streambuf
+{
+public:
+ wxStdOutputStreamBuffer(wxOutputStream& stream);
+ virtual ~wxStdOutputStreamBuffer() { }
+
+protected:
+ virtual std::streambuf *setbuf(char *s, std::streamsize n);
+ virtual std::streampos seekoff(std::streamoff off,
+ std::ios_base::seekdir way,
+ std::ios_base::openmode which =
+ std::ios_base::in |
+ std::ios_base::out);
+ virtual std::streampos seekpos(std::streampos sp,
+ std::ios_base::openmode which =
+ std::ios_base::in |
+ std::ios_base::out);
+ virtual std::streamsize xsputn(const char *s, std::streamsize n);
+ virtual int overflow(int c);
+
+ wxOutputStream& m_stream;
+};
+
+// ==========================================================================
+// wxStdOutputStream
+// ==========================================================================
+
+class WXDLLIMPEXP_BASE wxStdOutputStream : public std::ostream
+{
+public:
+ wxStdOutputStream(wxOutputStream& stream);
+ virtual ~wxStdOutputStream() { }
+
+protected:
+ wxStdOutputStreamBuffer m_streamBuffer;
+};
+
+#endif // wxUSE_STD_IOSTREAM
+
+#endif // _WX_STDSTREAM_H_
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: stdstream.h
+// Purpose: interface of wxStdInputStream, wxStdInputStreamBuffer,
+// wxStdOutputStream, wxStdOutputStreamBuffer
+// Author: Jonathan Liu <net147@gmail.com>
+// RCS-ID: $Id$
+// Copyright: (c) 2009 Jonathan Liu
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ @class wxStdInputStreamBuffer
+
+ wxStdInputStreamBuffer is a std::streambuf derived stream buffer which
+ reads from a wxInputStream.
+
+ Example:
+ @code
+ wxFFileInputStream file("input.txt.gz");
+ wxZlibInputStream gzipInput(file, wxZLIB_GZIP);
+ wxStdInputStreamBuffer gzipStreamBuffer(gzipInput);
+
+ // redirect std::cin to read from compressed file
+ std::streambuf* streamBufferOld = std::cin.rdbuf(&gzipStreamBuffer);
+
+ // prompt for integer
+ int number;
+ std::cout << "Enter an integer: " << std::flush;
+ std::cin >> number;
+ std::cout << std::endl;
+ std::cout << "You entered the integer " << number << "." << std::endl;
+
+ // restore std::cin
+ std::cin.rdbuf(streamBufferOld);
+ @endcode
+
+ @library{wxbase}
+ @category{streams}
+
+ @see wxInputStream, wxStdInputStream
+*/
+class wxStdInputStreamBuffer : public std::streambuf
+{
+public:
+ /**
+ Creates a std::steambuf derived stream buffer which reads from a
+ wxInputStream.
+
+ @param stream
+ Stream to read from.
+ */
+ wxStdInputStreamBuffer(wxInputStream& stream);
+
+ /**
+ Destructor.
+ */
+ virtual ~wxStdInputStreamBuffer() { }
+};
+
+/**
+ @class wxStdInputStream
+
+ wxStdInputStream is a std::istream derived stream buffer which reads from
+ a wxInputStream.
+
+ Example:
+ @code
+ wxFFileInputStream file("words.txt");
+ wxStdInputStream in(file);
+ std::vector<std::string> words;
+
+ // read words from stdin
+ std::copy(std::istream_iterator<std::string>(in),
+ std::istream_iterator<std::string>(),
+ std::back_inserter(words));
+
+ // sort and remove duplicates
+ std::sort(words.begin(), words.end());
+ words.resize(std::unique(words.begin(), words.end()) - words.begin());
+
+ // print words
+ std::copy(words.begin(), words.end(),
+ std::ostream_iterator<std::string>(std::cout, "\n"));
+ @endcode
+
+ @library{wxbase}
+ @category{streams}
+
+ @see wxInputStream, wxStdInputStreamBuffer
+*/
+class wxStdInputStream : public std::istream
+{
+public:
+ /**
+ Creates a std::istream derived stream which reads from a
+ wxInputStream.
+
+ @param stream
+ Stream to read from.
+ */
+ wxStdInputStream(wxInputStream& stream);
+
+ /**
+ Destructor.
+ */
+ virtual ~wxStdInputStream() { }
+};
+
+/**
+ @class wxStdOutputStreamBuffer
+
+ wxStdOutputStreamBuffer is a std::streambuf derived stream buffer which
+ writes to a wxOutputStream.
+
+ Example:
+ @code
+ wxFFileOutputStream file("cout.txt.gz");
+ wxZlibOutputStream gzipOutput(file, -1, wxZLIB_GZIP);
+ wxStdOutputStreamBuffer gzipStreamBuffer(gzipOutput);
+
+ // redirect std::cout to cout.txt.gz using GZIP compression
+ std::streambuf* streamBufferOld = std::cout.rdbuf(&gzipStreamBuffer);
+
+ // write to std::cout
+ std::cout << "Hello world!" << std::endl;
+
+ // restore std::cout
+ std::cout.rdbuf(streamBufferOld);
+ @endcode
+
+ @library{wxbase}
+ @category{streams}
+
+ @see wxOutputStream, wxStdOutputStream
+*/
+class wxStdOutputStreamBuffer : public std::streambuf
+{
+public:
+ /**
+ Creates a std::steambuf derived stream buffer which writes to a
+ wxOutputStream.
+
+ @param stream
+ Stream to write to.
+ */
+ wxStdOutputStreamBuffer(wxOutputStream& stream);
+
+ /**
+ Destructor.
+ */
+ virtual ~wxStdOutputStreamBuffer() { }
+};
+
+/**
+ @class wxStdOutputStream
+
+ wxStdOutputStream is a std::ostream derived stream which writes to a
+ wxOutputStream.
+
+ Example:
+ @code
+ wxFFileOutputStream file("out.txt.gz");
+ wxZlibOutputStream gzipOutput(file, -1, wxZLIB_GZIP);
+ wxStdOutputStream out(gzipOutput);
+
+ out << "Hello world!" << std::endl;
+ @endcode
+
+ @library{wxbase}
+ @category{streams}
+
+ @see wxOutputStream, wxStdOutputStreamBuffer
+*/
+class wxStdOutputStream : public std::ostream
+{
+public:
+ /**
+ Creates a std::ostream derived stream which writes to a
+ wxOutputStream.
+
+ @param stream
+ Stream to write to.
+ */
+ wxStdOutputStream(wxOutputStream& stream);
+
+ /**
+ Destructor.
+ */
+ virtual ~wxStdOutputStream() { }
+};
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: wx/stdstream.h
+// Purpose: Implementation of std::istream and std::ostream derived
+// wrappers for wxInputStream and wxOutputStream
+// Author: Jonathan Liu <net147@gmail.com>
+// Created: 2009-05-02
+// RCS-ID: $Id$
+// Copyright: (c) 2009 Jonathan Liu
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+// ==========================================================================
+// Declarations
+// ==========================================================================
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#if wxUSE_STD_IOSTREAM
+
+#ifndef WX_PRECOMP
+#endif
+
+#include "wx/stdstream.h"
+
+#include <ios>
+#include <istream>
+#include <ostream>
+#include <streambuf>
+
+// ==========================================================================
+// Helpers
+// ==========================================================================
+
+namespace
+{
+
+inline bool
+IosSeekDirToWxSeekMode(std::ios_base::seekdir way,
+ wxSeekMode& seekMode)
+{
+ switch ( way )
+ {
+ case std::ios_base::beg:
+ seekMode = wxFromStart;
+ break;
+ case std::ios_base::cur:
+ seekMode = wxFromCurrent;
+ break;
+ case std::ios_base::end:
+ seekMode = wxFromEnd;
+ break;
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+} // anonymous namespace
+
+// ==========================================================================
+// wxStdInputStreamBuffer
+// ==========================================================================
+
+wxStdInputStreamBuffer::wxStdInputStreamBuffer(wxInputStream& stream) :
+ m_stream(stream), m_lastChar(EOF)
+{
+}
+
+std::streambuf *
+wxStdInputStreamBuffer::setbuf(char *WXUNUSED(s),
+ std::streamsize WXUNUSED(n))
+{
+ return NULL;
+}
+
+std::streampos
+wxStdInputStreamBuffer::seekoff(std::streamoff off,
+ std::ios_base::seekdir way,
+ std::ios_base::openmode which)
+{
+ wxSeekMode seekMode;
+
+ if ( !IosSeekDirToWxSeekMode(way, seekMode) )
+ return -1;
+ if ( !(which & std::ios_base::in) )
+ return -1;
+
+ off_t newPos = m_stream.SeekI((off_t) off, seekMode);
+
+ if ( newPos != wxInvalidOffset )
+ return (std::streampos) newPos;
+ else
+ return -1;
+}
+
+std::streampos
+wxStdInputStreamBuffer::seekpos(std::streampos sp,
+ std::ios_base::openmode which)
+{
+ if ( !(which & std::ios_base::in) )
+ return -1;
+
+ off_t newPos = m_stream.SeekI((off_t) sp);
+
+ if ( newPos != wxInvalidOffset )
+ return (std::streampos) newPos;
+ else
+ return -1;
+}
+
+std::streamsize
+wxStdInputStreamBuffer::showmanyc()
+{
+ if ( m_stream.CanRead() && (off_t) m_stream.GetSize() > m_stream.TellI() )
+ return m_stream.GetSize() - m_stream.TellI();
+ else
+ return 0;
+}
+
+std::streamsize
+wxStdInputStreamBuffer::xsgetn(char *s, std::streamsize n)
+{
+ m_stream.Read((void *) s, (size_t) n);
+
+ std::streamsize read = m_stream.LastRead();
+
+ if ( read > 0 )
+ m_lastChar = (unsigned char) s[read - 1];
+
+ return read;
+}
+
+int
+wxStdInputStreamBuffer::underflow()
+{
+ int ch = m_stream.GetC();
+
+ if ( m_stream.LastRead() == 1 )
+ {
+ m_stream.Ungetch((char) ch);
+ return ch;
+ }
+ else
+ {
+ return EOF;
+ }
+}
+
+int
+wxStdInputStreamBuffer::uflow()
+{
+ int ch = m_stream.GetC();
+
+ if ( m_stream.LastRead() == 1 )
+ {
+ m_lastChar = ch;
+ return ch;
+ }
+ else
+ {
+ return EOF;
+ }
+}
+
+int
+wxStdInputStreamBuffer::pbackfail(int c)
+{
+ if ( c == EOF )
+ {
+ if ( m_lastChar == EOF )
+ return EOF;
+
+ c = m_lastChar;
+ m_lastChar = EOF;
+ }
+
+ return m_stream.Ungetch((char) c) ? c : EOF;
+}
+
+// ==========================================================================
+// wxStdInputStream
+// ==========================================================================
+
+wxStdInputStream::wxStdInputStream(wxInputStream& stream) :
+ std::istream(NULL), m_streamBuffer(stream)
+{
+ std::ios::init(&m_streamBuffer);
+}
+
+// ==========================================================================
+// wxStdOutputStreamBuffer
+// ==========================================================================
+
+wxStdOutputStreamBuffer::wxStdOutputStreamBuffer(wxOutputStream& stream) :
+ m_stream(stream)
+{
+}
+
+std::streambuf *
+wxStdOutputStreamBuffer::setbuf(char *WXUNUSED(s),
+ std::streamsize WXUNUSED(n))
+{
+ return NULL;
+}
+
+std::streampos
+wxStdOutputStreamBuffer::seekoff(std::streamoff off,
+ std::ios_base::seekdir way,
+ std::ios_base::openmode which)
+{
+ wxSeekMode seekMode;
+
+ if ( !IosSeekDirToWxSeekMode(way, seekMode) )
+ return -1;
+ if ( !(which & std::ios_base::out) )
+ return -1;
+
+ off_t newPos = m_stream.SeekO((off_t) off, seekMode);
+
+ if ( newPos != wxInvalidOffset )
+ return (std::streampos) newPos;
+ else
+ return -1;
+}
+
+std::streampos
+wxStdOutputStreamBuffer::seekpos(std::streampos sp,
+ std::ios_base::openmode which)
+{
+ if ( !(which & std::ios_base::out) )
+ return -1;
+
+ off_t newPos = m_stream.SeekO((off_t) sp);
+
+ if ( newPos != wxInvalidOffset )
+ return (std::streampos) newPos;
+ else
+ return -1;
+}
+
+std::streamsize
+wxStdOutputStreamBuffer::xsputn(const char *s,
+ std::streamsize n)
+{
+ m_stream.Write((const void *) s, (size_t) n);
+ return (std::streamsize) m_stream.LastWrite();
+}
+
+int
+wxStdOutputStreamBuffer::overflow(int c)
+{
+ m_stream.PutC(c);
+ return m_stream.IsOk() ? c : EOF;
+}
+
+// ==========================================================================
+// wxStdOutputStream
+// ==========================================================================
+
+wxStdOutputStream::wxStdOutputStream(wxOutputStream& stream) :
+ std::ostream(NULL), m_streamBuffer(stream)
+{
+ std::ios::init(&m_streamBuffer);
+}
+
+#endif // wxUSE_STD_IOSTREAM
# =========================================================================
# This makefile was generated by
-# Bakefile 0.2.5 (http://www.bakefile.org)
+# Bakefile 0.2.6 (http://www.bakefile.org)
# Do not modify, all changes will be overwritten!
# =========================================================================
EXEEXT = @EXEEXT@
WINDRES = @WINDRES@
SETFILE = @SETFILE@
+ICC_PCH_USE_SWITCH = @ICC_PCH_USE_SWITCH@
BK_DEPS = @BK_DEPS@
BK_MAKE_PCH = @BK_MAKE_PCH@
srcdir = @srcdir@
test_memstream.o \
test_socketstream.o \
test_sstream.o \
+ test_stdstream.o \
test_tempfile.o \
test_textstreamtest.o \
test_zlibstream.o \
@COND_PLATFORM_MAC_1@__test___mac_setfilecmd = \
@COND_PLATFORM_MAC_1@ $(SETFILE) -t APPL test$(EXEEXT)
@COND_GCC_PCH_1@__test_PCH_INC = -I./.pch/testprec_test
-@COND_ICC_PCH_1@__test_PCH_INC = -use_pch \
+@COND_ICC_PCH_1@__test_PCH_INC = $(ICC_PCH_USE_SWITCH) \
@COND_ICC_PCH_1@ ./.pch/testprec_test/testprec.h.gch
@COND_USE_PCH_1@_____pch_testprec_test_testprec_h_gch___depname \
@COND_USE_PCH_1@ = ./.pch/testprec_test/testprec.h.gch
@COND_TOOLKIT_COCOA@____test_gui_BUNDLE_TGT_REF_DEP = \
@COND_TOOLKIT_COCOA@ $(__test_gui_app_Contents_PkgInfo___depname)
@COND_GCC_PCH_1@__test_gui_PCH_INC = -I./.pch/testprec_test_gui
-@COND_ICC_PCH_1@__test_gui_PCH_INC = -use_pch \
+@COND_ICC_PCH_1@__test_gui_PCH_INC = $(ICC_PCH_USE_SWITCH) \
@COND_ICC_PCH_1@ ./.pch/testprec_test_gui/testprec.h.gch
@COND_USE_PCH_1@_____pch_testprec_test_gui_testprec_h_gch___depname \
@COND_USE_PCH_1@ = ./.pch/testprec_test_gui/testprec.h.gch
@COND_PLATFORM_MAC_1@__printfbench___mac_setfilecmd = \
@COND_PLATFORM_MAC_1@ $(SETFILE) -t APPL printfbench$(EXEEXT)
@COND_GCC_PCH_1@__printfbench_PCH_INC = -I./.pch/testprec_printfbench
-@COND_ICC_PCH_1@__printfbench_PCH_INC = -use_pch \
+@COND_ICC_PCH_1@__printfbench_PCH_INC = \
+@COND_ICC_PCH_1@ $(ICC_PCH_USE_SWITCH) \
@COND_ICC_PCH_1@ ./.pch/testprec_printfbench/testprec.h.gch
@COND_USE_PCH_1@_____pch_testprec_printfbench_testprec_h_gch___depname \
@COND_USE_PCH_1@ = ./.pch/testprec_printfbench/testprec.h.gch
test_sstream.o: $(srcdir)/streams/sstream.cpp $(TEST_ODEP)
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/streams/sstream.cpp
+test_stdstream.o: $(srcdir)/streams/stdstream.cpp $(TEST_ODEP)
+ $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/streams/stdstream.cpp
+
test_tempfile.o: $(srcdir)/streams/tempfile.cpp $(TEST_ODEP)
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/streams/tempfile.cpp
$(OBJS)\test_memstream.obj \
$(OBJS)\test_socketstream.obj \
$(OBJS)\test_sstream.obj \
+ $(OBJS)\test_stdstream.obj \
$(OBJS)\test_tempfile.obj \
$(OBJS)\test_textstreamtest.obj \
$(OBJS)\test_zlibstream.obj \
$(OBJS)\test_sstream.obj: .\streams\sstream.cpp
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\streams\sstream.cpp
+$(OBJS)\test_stdstream.obj: .\streams\stdstream.cpp
+ $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\streams\stdstream.cpp
+
$(OBJS)\test_tempfile.obj: .\streams\tempfile.cpp
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\streams\tempfile.cpp
$(OBJS)\test_memstream.o \
$(OBJS)\test_socketstream.o \
$(OBJS)\test_sstream.o \
+ $(OBJS)\test_stdstream.o \
$(OBJS)\test_tempfile.o \
$(OBJS)\test_textstreamtest.o \
$(OBJS)\test_zlibstream.o \
$(OBJS)\test_sstream.o: ./streams/sstream.cpp
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\test_stdstream.o: ./streams/stdstream.cpp
+ $(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\test_tempfile.o: ./streams/tempfile.cpp
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\test_memstream.obj \
$(OBJS)\test_socketstream.obj \
$(OBJS)\test_sstream.obj \
+ $(OBJS)\test_stdstream.obj \
$(OBJS)\test_tempfile.obj \
$(OBJS)\test_textstreamtest.obj \
$(OBJS)\test_zlibstream.obj \
$(OBJS)\test_sstream.obj: .\streams\sstream.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\streams\sstream.cpp
+$(OBJS)\test_stdstream.obj: .\streams\stdstream.cpp
+ $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\streams\stdstream.cpp
+
$(OBJS)\test_tempfile.obj: .\streams\tempfile.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\streams\tempfile.cpp
$(OBJS)\test_memstream.obj &
$(OBJS)\test_socketstream.obj &
$(OBJS)\test_sstream.obj &
+ $(OBJS)\test_stdstream.obj &
$(OBJS)\test_tempfile.obj &
$(OBJS)\test_textstreamtest.obj &
$(OBJS)\test_zlibstream.obj &
$(OBJS)\test_sstream.obj : .AUTODEPEND .\streams\sstream.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
+$(OBJS)\test_stdstream.obj : .AUTODEPEND .\streams\stdstream.cpp
+ $(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
+
$(OBJS)\test_tempfile.obj : .AUTODEPEND .\streams\tempfile.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: tests/streams/stdstream.cpp
+// Purpose: Test wxStdInputStreamBuffer/wxStdOutputStreamBuffer
+// Author: Jonathan Liu <net147@gmail.com>
+// RCS-ID: $Id$
+// Copyright: (c) 2009 Jonathan Liu
+// Licence: wxWidgets licence
+///////////////////////////////////////////////////////////////////////////////
+
+// For compilers that support precompilation, includes "wx/wx.h".
+// and "wx/cppunit.h"
+#include "testprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#if wxUSE_STD_IOSTREAM
+
+#include "wx/stdstream.h"
+
+#include <string.h>
+#include "wx/mstream.h"
+
+// when std::streamoff is simply long we don't need this as we already allow
+// comparisons between int and long but we do need it otherwise -- and we don't
+// have any way to detect it so for now just assume that all 64 bit builds use
+// long as streamoff and if this is wrong we'll add a check to configure later
+#if SIZEOF_SIZE_T != 8
+ WX_CPPUNIT_ALLOW_EQUALS_TO_INT(std::streamoff)
+#endif
+
+// ==========================================================================
+// Definitions
+// ==========================================================================
+
+const int TEST_SIZE = 384;
+
+// ==========================================================================
+// Test class
+// ==========================================================================
+
+class StdStreamTestCase : public CppUnit::TestCase
+{
+public:
+ StdStreamTestCase();
+
+private:
+ CPPUNIT_TEST_SUITE( StdStreamTestCase );
+ // Input buffer management and positioning
+ CPPUNIT_TEST( InputBuffer_pubsetbuf );
+ CPPUNIT_TEST( InputBuffer_pubseekoff );
+ CPPUNIT_TEST( InputBuffer_pubseekpos );
+ CPPUNIT_TEST( InputBuffer_pubsync );
+
+ // Input functions
+ CPPUNIT_TEST( InputBuffer_in_avail );
+ CPPUNIT_TEST( InputBuffer_snextc );
+ CPPUNIT_TEST( InputBuffer_sbumpc );
+ CPPUNIT_TEST( InputBuffer_sgetc );
+ CPPUNIT_TEST( InputBuffer_sgetn );
+ CPPUNIT_TEST( InputBuffer_sputbackc );
+ CPPUNIT_TEST( InputBuffer_sungetc );
+
+ // Output buffer management and positioning
+ CPPUNIT_TEST( OutputBuffer_pubsetbuf );
+ CPPUNIT_TEST( OutputBuffer_pubseekoff );
+ CPPUNIT_TEST( OutputBuffer_pubseekpos );
+ CPPUNIT_TEST( OutputBuffer_pubsync );
+
+ // Output functions
+ CPPUNIT_TEST( OutputBuffer_sputc );
+ CPPUNIT_TEST( OutputBuffer_sputn );
+ CPPUNIT_TEST_SUITE_END();
+
+ // Input buffer management and positioning
+ void InputBuffer_pubsetbuf();
+ void InputBuffer_pubseekoff();
+ void InputBuffer_pubseekpos();
+ void InputBuffer_pubsync();
+
+ // Input functions
+ void InputBuffer_in_avail();
+ void InputBuffer_snextc();
+ void InputBuffer_sbumpc();
+ void InputBuffer_sgetc();
+ void InputBuffer_sgetn();
+ void InputBuffer_sputbackc();
+ void InputBuffer_sungetc();
+
+ // Output buffer management and positioning
+ void OutputBuffer_pubsetbuf();
+ void OutputBuffer_pubseekoff();
+ void OutputBuffer_pubseekpos();
+ void OutputBuffer_pubsync();
+
+ // Output functions
+ void OutputBuffer_sputc();
+ void OutputBuffer_sputn();
+
+ char m_testData[TEST_SIZE];
+
+ DECLARE_NO_COPY_CLASS(StdStreamTestCase)
+};
+
+// register in the unnamed registry so that these tests are run by default
+CPPUNIT_TEST_SUITE_REGISTRATION( StdStreamTestCase );
+
+// also include in it's own registry so that these tests can be run alone
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( StdStreamTestCase,
+ "StdStreamTestCase" );
+
+// ==========================================================================
+// Implementation
+// ==========================================================================
+
+StdStreamTestCase::StdStreamTestCase()
+{
+ for (int i = 0; i < TEST_SIZE; ++i)
+ m_testData[i] = (i & 0xFF);
+}
+
+// --------------------------------------------------------------------------
+// Input buffer management and positioning
+// --------------------------------------------------------------------------
+
+void StdStreamTestCase::InputBuffer_pubsetbuf()
+{
+ wxMemoryInputStream stream(m_testData, TEST_SIZE);
+ wxStdInputStreamBuffer buffer(stream);
+ char testBuffer[TEST_SIZE];
+
+ CPPUNIT_ASSERT(buffer.pubsetbuf(testBuffer, TEST_SIZE) == NULL);
+}
+
+void StdStreamTestCase::InputBuffer_pubseekoff()
+{
+ const char *testData = "0123456789";
+ wxMemoryInputStream stream(testData, 10);
+ wxStdInputStreamBuffer buffer(stream);
+
+ CPPUNIT_ASSERT_EQUAL(2,
+ buffer.pubseekoff(2, std::ios_base::beg,
+ std::ios_base::in));
+ CPPUNIT_ASSERT_EQUAL(-1,
+ buffer.pubseekoff(2, std::ios_base::beg,
+ std::ios_base::out));
+
+ CPPUNIT_ASSERT_EQUAL(4,
+ buffer.pubseekoff(2, std::ios_base::cur));
+ CPPUNIT_ASSERT_EQUAL(-1,
+ buffer.pubseekoff(2, std::ios_base::cur,
+ std::ios_base::out));
+
+ CPPUNIT_ASSERT_EQUAL(8,
+ buffer.pubseekoff(-2, std::ios_base::end));
+ CPPUNIT_ASSERT_EQUAL(-1,
+ buffer.pubseekoff(-2, std::ios_base::end,
+ std::ios_base::out));
+
+ CPPUNIT_ASSERT_EQUAL(-1,
+ buffer.pubseekoff(3, std::ios_base::cur));
+ CPPUNIT_ASSERT_EQUAL(-1,
+ buffer.pubseekoff(3, std::ios_base::cur,
+ std::ios_base::out));
+}
+
+void StdStreamTestCase::InputBuffer_pubseekpos()
+{
+ const char *testData = "0123456789";
+ wxMemoryInputStream stream(testData, 10);
+ wxStdInputStreamBuffer buffer(stream);
+
+ for (int i = 9; i >= 0; --i)
+ {
+ if (i % 2 == 0)
+ CPPUNIT_ASSERT_EQUAL(i, buffer.pubseekpos(i));
+ else
+ CPPUNIT_ASSERT_EQUAL(i, buffer.pubseekpos(i, std::ios_base::in));
+
+ CPPUNIT_ASSERT_EQUAL('0' + i, buffer.sgetc());
+ }
+}
+
+void StdStreamTestCase::InputBuffer_pubsync()
+{
+ wxMemoryInputStream stream(m_testData, TEST_SIZE);
+ wxStdInputStreamBuffer buffer(stream);
+
+ CPPUNIT_ASSERT(buffer.pubsync() == 0);
+}
+
+// --------------------------------------------------------------------------
+// Input functions
+// --------------------------------------------------------------------------
+
+void StdStreamTestCase::InputBuffer_in_avail()
+{
+ wxMemoryInputStream stream(m_testData, TEST_SIZE);
+ wxStdInputStreamBuffer buffer(stream);
+
+ CPPUNIT_ASSERT(buffer.sgetc() != EOF);
+ CPPUNIT_ASSERT_EQUAL(TEST_SIZE, buffer.in_avail());
+
+ char data[TEST_SIZE / 2];
+
+ buffer.sgetn(data, TEST_SIZE / 2);
+ CPPUNIT_ASSERT_EQUAL(TEST_SIZE - TEST_SIZE / 2, buffer.in_avail());
+}
+
+void StdStreamTestCase::InputBuffer_snextc()
+{
+ wxMemoryInputStream stream(m_testData, TEST_SIZE);
+ wxStdInputStreamBuffer buffer(stream);
+
+ CPPUNIT_ASSERT(buffer.sgetc() != EOF);
+ CPPUNIT_ASSERT_EQUAL(TEST_SIZE, buffer.in_avail());
+
+ char data[TEST_SIZE];
+
+ data[0] = buffer.sgetc();
+
+ for (int i = 1; i < TEST_SIZE; ++i)
+ data[i] = buffer.snextc();
+
+ CPPUNIT_ASSERT(memcmp(data, m_testData, TEST_SIZE) == 0);
+ CPPUNIT_ASSERT_EQUAL((int)(unsigned char) (m_testData[TEST_SIZE - 1]),
+ buffer.sbumpc());
+ CPPUNIT_ASSERT(buffer.sgetc() == EOF);
+}
+
+void StdStreamTestCase::InputBuffer_sbumpc()
+{
+ wxMemoryInputStream stream(m_testData, TEST_SIZE);
+ wxStdInputStreamBuffer buffer(stream);
+
+ CPPUNIT_ASSERT(buffer.sgetc() != EOF);
+ CPPUNIT_ASSERT_EQUAL(TEST_SIZE, buffer.in_avail());
+
+ char data[TEST_SIZE];
+
+ for (int i = 0; i < TEST_SIZE; ++i)
+ data[i] = buffer.sbumpc();
+
+ CPPUNIT_ASSERT(memcmp(data, m_testData, TEST_SIZE) == 0);
+ CPPUNIT_ASSERT(buffer.sgetc() == EOF);
+}
+
+void StdStreamTestCase::InputBuffer_sgetc()
+{
+ wxMemoryInputStream stream(m_testData, TEST_SIZE);
+ wxStdInputStreamBuffer buffer(stream);
+
+ CPPUNIT_ASSERT(buffer.sgetc() != EOF);
+ CPPUNIT_ASSERT_EQUAL(TEST_SIZE, buffer.in_avail());
+
+ char data[TEST_SIZE];
+
+ for (int i = 0; i < TEST_SIZE; ++i) {
+ data[i] = buffer.sgetc();
+ buffer.sbumpc();
+ }
+
+ CPPUNIT_ASSERT(memcmp(data, m_testData, TEST_SIZE) == 0);
+ CPPUNIT_ASSERT(buffer.sgetc() == EOF);
+}
+
+void StdStreamTestCase::InputBuffer_sgetn()
+{
+ wxMemoryInputStream stream(m_testData, TEST_SIZE);
+ wxStdInputStreamBuffer buffer(stream);
+
+ CPPUNIT_ASSERT(buffer.sgetc() != EOF);
+ CPPUNIT_ASSERT_EQUAL(TEST_SIZE, buffer.in_avail());
+
+ char data[TEST_SIZE * 2];
+ std::streamsize read = buffer.sgetn(data, TEST_SIZE * 2);
+
+ CPPUNIT_ASSERT_EQUAL(TEST_SIZE, read);
+ CPPUNIT_ASSERT(memcmp(data, m_testData, TEST_SIZE) == 0);
+ CPPUNIT_ASSERT(buffer.sgetc() == EOF);
+}
+
+void StdStreamTestCase::InputBuffer_sputbackc()
+{
+ wxMemoryInputStream stream(m_testData, TEST_SIZE);
+ wxStdInputStreamBuffer buffer(stream);
+
+ CPPUNIT_ASSERT(buffer.sgetc() != EOF);
+ CPPUNIT_ASSERT_EQUAL(TEST_SIZE, buffer.in_avail());
+
+ char data[TEST_SIZE];
+ std::streamsize read = buffer.sgetn(data, TEST_SIZE);
+
+ CPPUNIT_ASSERT_EQUAL(TEST_SIZE, read);
+ CPPUNIT_ASSERT(memcmp(data, m_testData, TEST_SIZE) == 0);
+ CPPUNIT_ASSERT(buffer.sgetc() == EOF);
+
+ char putBackChar = m_testData[TEST_SIZE - 1] + 147;
+
+ CPPUNIT_ASSERT_EQUAL((int) putBackChar, buffer.sputbackc(putBackChar));
+ CPPUNIT_ASSERT_EQUAL((int) putBackChar, buffer.sgetc());
+ CPPUNIT_ASSERT_EQUAL((int) putBackChar, buffer.sbumpc());
+ CPPUNIT_ASSERT(buffer.sgetc() == EOF);
+}
+
+void StdStreamTestCase::InputBuffer_sungetc()
+{
+ wxMemoryInputStream stream(m_testData, TEST_SIZE);
+ wxStdInputStreamBuffer buffer(stream);
+
+ CPPUNIT_ASSERT(buffer.sgetc() != EOF);
+ CPPUNIT_ASSERT_EQUAL(TEST_SIZE, buffer.in_avail());
+
+ char data[TEST_SIZE];
+ std::streamsize read = buffer.sgetn(data, TEST_SIZE);
+
+ CPPUNIT_ASSERT_EQUAL(TEST_SIZE, read);
+ CPPUNIT_ASSERT(memcmp(data, m_testData, TEST_SIZE) == 0);
+ CPPUNIT_ASSERT(buffer.sgetc() == EOF);
+
+ CPPUNIT_ASSERT_EQUAL((int) m_testData[TEST_SIZE - 1], buffer.sungetc());
+ CPPUNIT_ASSERT_EQUAL((int) m_testData[TEST_SIZE - 1], buffer.sgetc());
+ CPPUNIT_ASSERT_EQUAL((int) m_testData[TEST_SIZE - 1], buffer.sbumpc());
+ CPPUNIT_ASSERT(buffer.sgetc() == EOF);
+}
+
+// --------------------------------------------------------------------------
+// Output buffer management and positioning
+// --------------------------------------------------------------------------
+
+void StdStreamTestCase::OutputBuffer_pubsetbuf()
+{
+ wxMemoryOutputStream stream;
+ wxStdOutputStreamBuffer buffer(stream);
+ char testBuffer[TEST_SIZE];
+
+ CPPUNIT_ASSERT(buffer.pubsetbuf(testBuffer, TEST_SIZE) == NULL);
+}
+
+void StdStreamTestCase::OutputBuffer_pubseekoff()
+{
+ char testData[] = "0123456789";
+ wxMemoryOutputStream stream(testData, 10);
+ wxStdOutputStreamBuffer buffer(stream);
+
+ CPPUNIT_ASSERT_EQUAL(2,
+ buffer.pubseekoff(2, std::ios_base::beg,
+ std::ios_base::out));
+ CPPUNIT_ASSERT_EQUAL(-1,
+ buffer.pubseekoff(2, std::ios_base::beg,
+ std::ios_base::in));
+
+ CPPUNIT_ASSERT_EQUAL(4,
+ buffer.pubseekoff(2, std::ios_base::cur));
+ CPPUNIT_ASSERT_EQUAL(-1,
+ buffer.pubseekoff(2, std::ios_base::cur,
+ std::ios_base::in));
+
+ CPPUNIT_ASSERT_EQUAL(8,
+ buffer.pubseekoff(-2, std::ios_base::end));
+ CPPUNIT_ASSERT_EQUAL(-1,
+ buffer.pubseekoff(-2, std::ios_base::end,
+ std::ios_base::in));
+
+ CPPUNIT_ASSERT_EQUAL(-1,
+ buffer.pubseekoff(3, std::ios_base::cur));
+ CPPUNIT_ASSERT_EQUAL(-1,
+ buffer.pubseekoff(3, std::ios_base::cur,
+ std::ios_base::in));
+}
+
+void StdStreamTestCase::OutputBuffer_pubseekpos()
+{
+ char testData[] = "0123456789";
+ wxMemoryOutputStream stream(testData, 10);
+ wxStdOutputStreamBuffer buffer(stream);
+
+ for (int i = 9; i >= 0; --i)
+ {
+ if (i % 2 == 0)
+ {
+ CPPUNIT_ASSERT_EQUAL(i, buffer.pubseekpos(i));
+ }
+ else
+ {
+ CPPUNIT_ASSERT_EQUAL(i,
+ buffer.pubseekpos(i, std::ios_base::out));
+ }
+
+ CPPUNIT_ASSERT_EQUAL('0' + (9 - i), buffer.sputc('0' + (9 - i)));
+ }
+
+ CPPUNIT_ASSERT(memcmp(testData, "9876543210", 10) == 0);
+
+ CPPUNIT_ASSERT_EQUAL(-1, buffer.pubseekpos(5, std::ios_base::in));
+}
+
+void StdStreamTestCase::OutputBuffer_pubsync()
+{
+ wxMemoryOutputStream stream;
+ wxStdOutputStreamBuffer buffer(stream);
+
+ CPPUNIT_ASSERT(buffer.pubsync() == 0);
+}
+
+// --------------------------------------------------------------------------
+// Output functions
+// --------------------------------------------------------------------------
+
+void StdStreamTestCase::OutputBuffer_sputc()
+{
+ wxMemoryOutputStream stream;
+ wxStdOutputStreamBuffer buffer(stream);
+
+ for (int i = 0; i < TEST_SIZE; ++i)
+ buffer.sputc(m_testData[i]);
+
+ CPPUNIT_ASSERT_EQUAL(TEST_SIZE, stream.GetSize());
+
+ char result[TEST_SIZE];
+
+ stream.CopyTo(result, TEST_SIZE);
+ CPPUNIT_ASSERT(memcmp(result, m_testData, TEST_SIZE) == 0);
+}
+
+void StdStreamTestCase::OutputBuffer_sputn()
+{
+ wxMemoryOutputStream stream;
+ wxStdOutputStreamBuffer buffer(stream);
+
+ buffer.sputn(m_testData, TEST_SIZE);
+ CPPUNIT_ASSERT_EQUAL(TEST_SIZE, stream.GetSize());
+
+ char result[TEST_SIZE];
+
+ stream.CopyTo(result, TEST_SIZE);
+ CPPUNIT_ASSERT(memcmp(result, m_testData, TEST_SIZE) == 0);
+}
+
+#endif // wxUSE_STD_IOSTREAM
streams/memstream.cpp
streams/socketstream.cpp
streams/sstream.cpp
+ streams/stdstream.cpp
streams/tempfile.cpp
streams/textstreamtest.cpp
streams/zlibstream.cpp
# End Source File\r
# Begin Source File\r
\r
+SOURCE=.\streams\stdstream.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=.\strings\stdstrings.cpp\r
# End Source File\r
# Begin Source File\r
<File\r
RelativePath=".\streams\sstream.cpp">\r
</File>\r
+ <File\r
+ RelativePath=".\streams\stdstream.cpp">\r
+ </File>\r
<File\r
RelativePath=".\strings\stdstrings.cpp">\r
</File>\r
RelativePath=".\streams\sstream.cpp"\r
>\r
</File>\r
+ <File\r
+ RelativePath=".\streams\stdstream.cpp"\r
+ >\r
+ </File>\r
<File\r
RelativePath=".\strings\stdstrings.cpp"\r
>\r
RelativePath=".\streams\sstream.cpp"\r
>\r
</File>\r
+ <File\r
+ RelativePath=".\streams\stdstream.cpp"\r
+ >\r
+ </File>\r
<File\r
RelativePath=".\strings\stdstrings.cpp"\r
>\r
wx/stack.h
wx/stackwalk.h
wx/stdpaths.h
+wx/stdstream.h
wx/stockitem.h
wx/stopwatch.h
wx/strconv.h
wx/stack.h
wx/stackwalk.h
wx/stdpaths.h
+wx/stdstream.h
wx/stockitem.h
wx/stopwatch.h
wx/strconv.h
wx/stack.h
wx/stackwalk.h
wx/stdpaths.h
+wx/stdstream.h
wx/stockitem.h
wx/stopwatch.h
wx/strconv.h