]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxStd{In,Out}putStream classes (closes #10637)
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 2 May 2009 18:29:33 +0000 (18:29 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 2 May 2009 18:29:33 +0000 (18:29 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60483 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

29 files changed:
Makefile.in
build/bakefiles/files.bkl
build/msw/makefile.bcc
build/msw/makefile.gcc
build/msw/makefile.vc
build/msw/makefile.wat
build/msw/wx_base.dsp
build/msw/wx_vc7_base.vcproj
build/msw/wx_vc8_base.vcproj
build/msw/wx_vc9_base.vcproj
docs/changes.txt
docs/doxygen/overviews/stream.h
include/wx/stdstream.h [new file with mode: 0644]
interface/wx/stdstream.h [new file with mode: 0644]
src/common/stdstream.cpp [new file with mode: 0644]
tests/Makefile.in
tests/makefile.bcc
tests/makefile.gcc
tests/makefile.vc
tests/makefile.wat
tests/streams/stdstream.cpp [new file with mode: 0644]
tests/test.bkl
tests/test_test.dsp
tests/test_vc7_test.vcproj
tests/test_vc8_test.vcproj
tests/test_vc9_test.vcproj
wxGTK.spec
wxMotif.spec
wxX11.spec

index 0bde7114c755a7290f4c0737bc00b2e9f6a2b362..a34a22eb13aafb5e6d4993e42e32542f4c69706c 100644 (file)
@@ -405,6 +405,7 @@ ALL_BASE_HEADERS =  \
        wx/stack.h \
        wx/stackwalk.h \
        wx/stdpaths.h \
+       wx/stdstream.h \
        wx/stockitem.h \
        wx/stopwatch.h \
        wx/strconv.h \
@@ -564,6 +565,7 @@ ALL_PORTS_BASE_HEADERS =  \
        wx/stack.h \
        wx/stackwalk.h \
        wx/stdpaths.h \
+       wx/stdstream.h \
        wx/stockitem.h \
        wx/stopwatch.h \
        wx/strconv.h \
@@ -714,6 +716,7 @@ ALL_BASE_SOURCES =  \
        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 \
@@ -901,6 +904,7 @@ MONODLL_OBJECTS =  \
        monodll_regex.o \
        monodll_stdpbase.o \
        monodll_sstream.o \
+       monodll_stdstream.o \
        monodll_stopwatch.o \
        monodll_strconv.o \
        monodll_stream.o \
@@ -1025,6 +1029,7 @@ MONOLIB_OBJECTS =  \
        monolib_regex.o \
        monolib_stdpbase.o \
        monolib_sstream.o \
+       monolib_stdstream.o \
        monolib_stopwatch.o \
        monolib_strconv.o \
        monolib_stream.o \
@@ -1146,6 +1151,7 @@ BASEDLL_OBJECTS =  \
        basedll_regex.o \
        basedll_stdpbase.o \
        basedll_sstream.o \
+       basedll_stdstream.o \
        basedll_stopwatch.o \
        basedll_strconv.o \
        basedll_stream.o \
@@ -1249,6 +1255,7 @@ BASELIB_OBJECTS =  \
        baselib_regex.o \
        baselib_stdpbase.o \
        baselib_sstream.o \
+       baselib_stdstream.o \
        baselib_stopwatch.o \
        baselib_strconv.o \
        baselib_stream.o \
@@ -14162,6 +14169,9 @@ monodll_stdpbase.o: $(srcdir)/src/common/stdpbase.cpp $(MONODLL_ODEP)
 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
 
@@ -18848,6 +18858,9 @@ monolib_stdpbase.o: $(srcdir)/src/common/stdpbase.cpp $(MONOLIB_ODEP)
 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
 
@@ -23534,6 +23547,9 @@ basedll_stdpbase.o: $(srcdir)/src/common/stdpbase.cpp $(BASEDLL_ODEP)
 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
 
@@ -23996,6 +24012,9 @@ baselib_stdpbase.o: $(srcdir)/src/common/stdpbase.cpp $(BASELIB_ODEP)
 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
 
index 8c6dc9f1ac66784122cbe822f82226dbde5eaacc..9a1674c68e351791c72c4771b1f408921001606d 100644 (file)
@@ -354,6 +354,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
     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
@@ -485,6 +486,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
     wx/stack.h
     wx/stackwalk.h
     wx/stdpaths.h
+    wx/stdstream.h
     wx/stockitem.h
     wx/stopwatch.h
     wx/strconv.h
index 52df76ef41e0a8e2b90dcd7ab79b4f3ed28a7d95..b636fe6d73baf29cc0094a2372e175936e610eae 100644 (file)
@@ -358,6 +358,7 @@ MONODLL_OBJECTS =  \
        $(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 \
@@ -497,6 +498,7 @@ MONOLIB_OBJECTS =  \
        $(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 \
@@ -633,6 +635,7 @@ BASEDLL_OBJECTS =  \
        $(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 \
@@ -754,6 +757,7 @@ BASELIB_OBJECTS =  \
        $(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 \
@@ -5558,6 +5562,9 @@ $(OBJS)\monodll_stdpbase.obj: ..\..\src\common\stdpbase.cpp
 $(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
 
@@ -7784,6 +7791,9 @@ $(OBJS)\monolib_stdpbase.obj: ..\..\src\common\stdpbase.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
 
@@ -10010,6 +10020,9 @@ $(OBJS)\basedll_stdpbase.obj: ..\..\src\common\stdpbase.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
 
@@ -10322,6 +10335,9 @@ $(OBJS)\baselib_stdpbase.obj: ..\..\src\common\stdpbase.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
 
index 7c1614b7a4501e137665b3d18271924b9b00d68b..ea28280b1f5c0121445970a698d192bf94f5d4b5 100644 (file)
@@ -344,6 +344,7 @@ MONODLL_OBJECTS =  \
        $(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 \
@@ -484,6 +485,7 @@ MONOLIB_OBJECTS =  \
        $(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 \
@@ -622,6 +624,7 @@ BASEDLL_OBJECTS =  \
        $(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 \
@@ -743,6 +746,7 @@ BASELIB_OBJECTS =  \
        $(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 \
@@ -5710,6 +5714,9 @@ $(OBJS)\monodll_stdpbase.o: ../../src/common/stdpbase.cpp
 $(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) $<
 
@@ -8048,6 +8055,9 @@ $(OBJS)\monolib_stdpbase.o: ../../src/common/stdpbase.cpp
 $(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) $<
 
@@ -10386,6 +10396,9 @@ $(OBJS)\basedll_stdpbase.o: ../../src/common/stdpbase.cpp
 $(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) $<
 
@@ -10698,6 +10711,9 @@ $(OBJS)\baselib_stdpbase.o: ../../src/common/stdpbase.cpp
 $(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) $<
 
index 5e01a28d1d2ce37642f15a99f5ee8730ee900791..63e4ab4bb6fb9df6979d9e65ac0e41beddbe749a 100644 (file)
@@ -359,6 +359,7 @@ MONODLL_OBJECTS =  \
        $(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 \
@@ -503,6 +504,7 @@ MONOLIB_OBJECTS =  \
        $(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 \
@@ -645,6 +647,7 @@ BASEDLL_OBJECTS =  \
        $(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 \
@@ -771,6 +774,7 @@ BASELIB_OBJECTS =  \
        $(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 \
@@ -5904,6 +5908,9 @@ $(OBJS)\monodll_stdpbase.obj: ..\..\src\common\stdpbase.cpp
 $(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
 
@@ -8130,6 +8137,9 @@ $(OBJS)\monolib_stdpbase.obj: ..\..\src\common\stdpbase.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
 
@@ -10356,6 +10366,9 @@ $(OBJS)\basedll_stdpbase.obj: ..\..\src\common\stdpbase.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
 
@@ -10668,6 +10681,9 @@ $(OBJS)\baselib_stdpbase.obj: ..\..\src\common\stdpbase.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
 
index 7c0e82269664175f5fbbb2a5ae55ff8c59299ee4..5f14bc87a6091beabde55f7d92026fe50ca9a245 100644 (file)
@@ -3464,6 +3464,7 @@ MONODLL_OBJECTS =  &
        $(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 &
@@ -3603,6 +3604,7 @@ MONOLIB_OBJECTS =  &
        $(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 &
@@ -3740,6 +3742,7 @@ BASEDLL_OBJECTS =  &
        $(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 &
@@ -3861,6 +3864,7 @@ BASELIB_OBJECTS =  &
        $(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 &
@@ -5959,6 +5963,9 @@ $(OBJS)\monodll_stdpbase.obj :  .AUTODEPEND ..\..\src\common\stdpbase.cpp
 $(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) $<
 
@@ -8297,6 +8304,9 @@ $(OBJS)\monolib_stdpbase.obj :  .AUTODEPEND ..\..\src\common\stdpbase.cpp
 $(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) $<
 
@@ -10635,6 +10645,9 @@ $(OBJS)\basedll_stdpbase.obj :  .AUTODEPEND ..\..\src\common\stdpbase.cpp
 $(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) $<
 
@@ -10947,6 +10960,9 @@ $(OBJS)\baselib_stdpbase.obj :  .AUTODEPEND ..\..\src\common\stdpbase.cpp
 $(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) $<
 
index d33ad49d4ba89b20df2b8f66f5986fb52e98b016..b04a71d17b4852b4965b14ba9da11aefe53d39d1 100644 (file)
@@ -467,6 +467,10 @@ SOURCE=..\..\src\common\stdpbase.cpp
 # 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
@@ -1419,6 +1423,10 @@ SOURCE=..\..\include\wx\stdpaths.h
 # 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
index 31d131773ff01ad875f1ad596746ab5daf752ea6..4ce33f300aa5219d90e45e4388bde609cd82dc78 100644 (file)
                        <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
index cfa90c7b1eeb3aca8ff7895d5fecdd89cc2b6345..6c4fcab102b6bab5319b508a74bedee4495c6df5 100644 (file)
                                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
index 78e2180a19405b217a3ecae69485a0ed5aa0bcd3..c57b50ce1ae9758d12c2aaac87f52f64f2c588fb 100644 (file)
                                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
index afe352382e0bb4e044d0db1837bdaf4299360119..bf4619c7647d8a0f96785b3175eac4b368c14062 100644 (file)
@@ -328,6 +328,7 @@ Major new features in this release
 
 All:
 
+- Added wxStd{Input,Output}Stream classes (Jonathan Liu).
 - Include port number in host header in wxHTTP (Marcin 'Malcom' Malich).
 
 All (GUI):
index 132b142eed99a9a8fd1116ae81b2beee612976de..a11b2668637f19d7800e47f9fd57f10210831e02 100644 (file)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        stream.h
-// Purpose:     topic overview
+// Purpose:     stream classes overview
 // Author:      wxWidgets team
 // RCS-ID:      $Id$
 // Licence:     wxWindows license
@@ -33,16 +33,25 @@ Classes:
 
 @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:
 
diff --git a/include/wx/stdstream.h b/include/wx/stdstream.h
new file mode 100644 (file)
index 0000000..993c1ea
--- /dev/null
@@ -0,0 +1,111 @@
+/////////////////////////////////////////////////////////////////////////////
+// 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_
diff --git a/interface/wx/stdstream.h b/interface/wx/stdstream.h
new file mode 100644 (file)
index 0000000..2fe3a5e
--- /dev/null
@@ -0,0 +1,190 @@
+/////////////////////////////////////////////////////////////////////////////
+// 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() { }
+};
diff --git a/src/common/stdstream.cpp b/src/common/stdstream.cpp
new file mode 100644 (file)
index 0000000..af8475c
--- /dev/null
@@ -0,0 +1,272 @@
+/////////////////////////////////////////////////////////////////////////////
+// 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
index a437506f8493e6e23254c43358e03624e8a0b47a..0e094c5d725e44461e1bd12ea4ae67eacc22685e 100644 (file)
@@ -1,6 +1,6 @@
 # =========================================================================
 #     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!
 # =========================================================================
 
@@ -14,6 +14,7 @@ INSTALL = @INSTALL@
 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@
@@ -100,6 +101,7 @@ TEST_OBJECTS =  \
        test_memstream.o \
        test_socketstream.o \
        test_sstream.o \
+       test_stdstream.o \
        test_tempfile.o \
        test_textstreamtest.o \
        test_zlibstream.o \
@@ -174,7 +176,7 @@ PRINTFBENCH_ODEP = $(_____pch_testprec_printfbench_testprec_h_gch___depname)
 @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
@@ -207,7 +209,7 @@ PRINTFBENCH_ODEP = $(_____pch_testprec_printfbench_testprec_h_gch___depname)
 @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
@@ -239,7 +241,8 @@ COND_MONOLITHIC_0___WXLIB_CORE_p = \
 @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
@@ -503,6 +506,9 @@ test_socketstream.o: $(srcdir)/streams/socketstream.cpp $(TEST_ODEP)
 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
 
index d779b0aa08ab3f5d427717cc9173525de967d5df..bc475bbac9b20fd09a8d1dddb70152a727316582 100644 (file)
@@ -85,6 +85,7 @@ TEST_OBJECTS =  \
        $(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 \
@@ -544,6 +545,9 @@ $(OBJS)\test_socketstream.obj: .\streams\socketstream.cpp
 $(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
 
index 97e84a4a836e83f207d08e438b749d5a7044c9a9..daf461823aea3a8f125a9a394b115af738da466e 100644 (file)
@@ -77,6 +77,7 @@ TEST_OBJECTS =  \
        $(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 \
@@ -524,6 +525,9 @@ $(OBJS)\test_socketstream.o: ./streams/socketstream.cpp
 $(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) $<
 
index 089f43c01667d0f3bb054d3b4d035ad34b20db44..22f95e45d6b5eabed9a8a428a02d9f07f7c7fe20 100644 (file)
@@ -78,6 +78,7 @@ TEST_OBJECTS =  \
        $(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 \
@@ -629,6 +630,9 @@ $(OBJS)\test_socketstream.obj: .\streams\socketstream.cpp
 $(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
 
index 4aa291b374b219fbd46c0b338bde510c336c9fe3..dee72ca402c461e1d1d328e7fd93f275cad2cbd8 100644 (file)
@@ -316,6 +316,7 @@ TEST_OBJECTS =  &
        $(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 &
@@ -585,6 +586,9 @@ $(OBJS)\test_socketstream.obj :  .AUTODEPEND .\streams\socketstream.cpp
 $(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) $<
 
diff --git a/tests/streams/stdstream.cpp b/tests/streams/stdstream.cpp
new file mode 100644 (file)
index 0000000..a5212e5
--- /dev/null
@@ -0,0 +1,446 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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
index ee4e4a49305feb24a0d653c5078ba245c6ba5233..2b7d2ca5ac726d55c40cedc2eb0ea141248ee05d 100644 (file)
@@ -76,6 +76,7 @@
             streams/memstream.cpp
             streams/socketstream.cpp
             streams/sstream.cpp
+            streams/stdstream.cpp
             streams/tempfile.cpp
             streams/textstreamtest.cpp
             streams/zlibstream.cpp
index 32d96d8be930f554fbc8f96a2376b9db2cd0cbd7..0773823af017d31fb4917d251f9c5666d583229b 100644 (file)
@@ -397,6 +397,10 @@ SOURCE=.\streams\sstream.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
index 0263ed5825ff8dd33e81fc49efa1d8f84b544ba8..28064a645f4c8692366b9d35c89eedd55124d24c 100644 (file)
                        <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
index d382fb5d093b6e83cfed014537f52975a6f97023..e8d10ff879812b8fd645ade1d2ed444c99555a78 100644 (file)
                                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
index 03eea489925928451dda5d6126edaebe3622eb55..b729ad6fdd6e97a627477d23100240ec98ee54e5 100644 (file)
                                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
index d6e259093ffcd08e864aeda37d5d06f9d10c5ede..bd158a300f9953a6f6586c876bace822f958ab5c 100644 (file)
@@ -301,6 +301,7 @@ wx/sstream.h
 wx/stack.h
 wx/stackwalk.h
 wx/stdpaths.h
+wx/stdstream.h
 wx/stockitem.h
 wx/stopwatch.h
 wx/strconv.h
index 4f29e8dc2c0e9f730b7dfbbbecb7920773370e0d..37e8a79180d4b182a0a9f3e7bc9dcb90b4a3315b 100644 (file)
@@ -206,6 +206,7 @@ wx/sstream.h
 wx/stack.h
 wx/stackwalk.h
 wx/stdpaths.h
+wx/stdstream.h
 wx/stockitem.h
 wx/stopwatch.h
 wx/strconv.h
index 2a4504e07ef60bb0b44c5030118c686d4372ce1e..46657bfc64594121181ee1dfec7f60b931387df8 100644 (file)
@@ -230,6 +230,7 @@ wx/sstream.h
 wx/stack.h
 wx/stackwalk.h
 wx/stdpaths.h
+wx/stdstream.h
 wx/stockitem.h
 wx/stopwatch.h
 wx/strconv.h