From 166c3ef0f9a77a66143968be2c1b58747994d32e Mon Sep 17 00:00:00 2001 From: Michael Wetherell Date: Wed, 25 Oct 2006 20:41:12 +0000 Subject: [PATCH] Add class factories for filter streams. Also filters now follow the convention that they own their parent if they are created with a pointer to the parent. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42412 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- Makefile.in | 34 ++++++++++++++++ build/bakefiles/files.bkl | 2 + build/msw/makefile.bcc | 32 +++++++++++++++ build/msw/makefile.gcc | 32 +++++++++++++++ build/msw/makefile.vc | 32 +++++++++++++++ build/msw/makefile.wat | 32 +++++++++++++++ build/msw/wx_base.dsp | 8 ++++ include/wx/stream.h | 58 +++++++++++++++++++++++++++ src/common/filtall.cpp | 36 +++++++++++++++++ src/common/filtfind.cpp | 43 ++++++++++++++++++++ src/common/stream.cpp | 84 +++++++++++++++++++++++++++++++++++++-- src/wxWindows.dsp | 8 ++++ 12 files changed, 397 insertions(+), 4 deletions(-) create mode 100644 src/common/filtall.cpp create mode 100644 src/common/filtfind.cpp diff --git a/Makefile.in b/Makefile.in index 68d22301c9..59da9588b0 100644 --- a/Makefile.in +++ b/Makefile.in @@ -541,6 +541,8 @@ ALL_BASE_SOURCES = \ src/common/filefn.cpp \ src/common/filename.cpp \ src/common/filesys.cpp \ + src/common/filtall.cpp \ + src/common/filtfind.cpp \ src/common/fmapbase.cpp \ src/common/fs_zip.cpp \ src/common/hash.cpp \ @@ -690,6 +692,8 @@ MONODLL_OBJECTS = \ monodll_filefn.o \ monodll_filename.o \ monodll_filesys.o \ + monodll_filtall.o \ + monodll_filtfind.o \ monodll_fmapbase.o \ monodll_fs_zip.o \ monodll_hash.o \ @@ -783,6 +787,8 @@ MONOLIB_OBJECTS = \ monolib_filefn.o \ monolib_filename.o \ monolib_filesys.o \ + monolib_filtall.o \ + monolib_filtfind.o \ monolib_fmapbase.o \ monolib_fs_zip.o \ monolib_hash.o \ @@ -878,6 +884,8 @@ BASEDLL_OBJECTS = \ basedll_filefn.o \ basedll_filename.o \ basedll_filesys.o \ + basedll_filtall.o \ + basedll_filtfind.o \ basedll_fmapbase.o \ basedll_fs_zip.o \ basedll_hash.o \ @@ -956,6 +964,8 @@ BASELIB_OBJECTS = \ baselib_filefn.o \ baselib_filename.o \ baselib_filesys.o \ + baselib_filtall.o \ + baselib_filtfind.o \ baselib_fmapbase.o \ baselib_fs_zip.o \ baselib_hash.o \ @@ -12163,6 +12173,12 @@ monodll_filename.o: $(srcdir)/src/common/filename.cpp $(MONODLL_ODEP) monodll_filesys.o: $(srcdir)/src/common/filesys.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/filesys.cpp +monodll_filtall.o: $(srcdir)/src/common/filtall.cpp $(MONODLL_ODEP) + $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/filtall.cpp + +monodll_filtfind.o: $(srcdir)/src/common/filtfind.cpp $(MONODLL_ODEP) + $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/filtfind.cpp + monodll_fmapbase.o: $(srcdir)/src/common/fmapbase.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/fmapbase.cpp @@ -16231,6 +16247,12 @@ monolib_filename.o: $(srcdir)/src/common/filename.cpp $(MONOLIB_ODEP) monolib_filesys.o: $(srcdir)/src/common/filesys.cpp $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/filesys.cpp +monolib_filtall.o: $(srcdir)/src/common/filtall.cpp $(MONOLIB_ODEP) + $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/filtall.cpp + +monolib_filtfind.o: $(srcdir)/src/common/filtfind.cpp $(MONOLIB_ODEP) + $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/filtfind.cpp + monolib_fmapbase.o: $(srcdir)/src/common/fmapbase.cpp $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/fmapbase.cpp @@ -20302,6 +20324,12 @@ basedll_filename.o: $(srcdir)/src/common/filename.cpp $(BASEDLL_ODEP) basedll_filesys.o: $(srcdir)/src/common/filesys.cpp $(BASEDLL_ODEP) $(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/common/filesys.cpp +basedll_filtall.o: $(srcdir)/src/common/filtall.cpp $(BASEDLL_ODEP) + $(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/common/filtall.cpp + +basedll_filtfind.o: $(srcdir)/src/common/filtfind.cpp $(BASEDLL_ODEP) + $(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/common/filtfind.cpp + basedll_fmapbase.o: $(srcdir)/src/common/fmapbase.cpp $(BASEDLL_ODEP) $(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/common/fmapbase.cpp @@ -20869,6 +20897,12 @@ baselib_filename.o: $(srcdir)/src/common/filename.cpp $(BASELIB_ODEP) baselib_filesys.o: $(srcdir)/src/common/filesys.cpp $(BASELIB_ODEP) $(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/common/filesys.cpp +baselib_filtall.o: $(srcdir)/src/common/filtall.cpp $(BASELIB_ODEP) + $(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/common/filtall.cpp + +baselib_filtfind.o: $(srcdir)/src/common/filtfind.cpp $(BASELIB_ODEP) + $(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/common/filtfind.cpp + baselib_fmapbase.o: $(srcdir)/src/common/fmapbase.cpp $(BASELIB_ODEP) $(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/common/fmapbase.cpp diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index dd6961cf2d..763cb4b06f 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -309,6 +309,8 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/common/filefn.cpp src/common/filename.cpp src/common/filesys.cpp + src/common/filtall.cpp + src/common/filtfind.cpp src/common/fmapbase.cpp src/common/fs_zip.cpp src/common/hash.cpp diff --git a/build/msw/makefile.bcc b/build/msw/makefile.bcc index 7b64b71a2a..cfd5cdb293 100644 --- a/build/msw/makefile.bcc +++ b/build/msw/makefile.bcc @@ -223,6 +223,8 @@ MONODLL_OBJECTS = \ $(OBJS)\monodll_filefn.obj \ $(OBJS)\monodll_filename.obj \ $(OBJS)\monodll_filesys.obj \ + $(OBJS)\monodll_filtall.obj \ + $(OBJS)\monodll_filtfind.obj \ $(OBJS)\monodll_fmapbase.obj \ $(OBJS)\monodll_fs_zip.obj \ $(OBJS)\monodll_hash.obj \ @@ -337,6 +339,8 @@ MONOLIB_OBJECTS = \ $(OBJS)\monolib_filefn.obj \ $(OBJS)\monolib_filename.obj \ $(OBJS)\monolib_filesys.obj \ + $(OBJS)\monolib_filtall.obj \ + $(OBJS)\monolib_filtfind.obj \ $(OBJS)\monolib_fmapbase.obj \ $(OBJS)\monolib_fs_zip.obj \ $(OBJS)\monolib_hash.obj \ @@ -452,6 +456,8 @@ BASEDLL_OBJECTS = \ $(OBJS)\basedll_filefn.obj \ $(OBJS)\basedll_filename.obj \ $(OBJS)\basedll_filesys.obj \ + $(OBJS)\basedll_filtall.obj \ + $(OBJS)\basedll_filtfind.obj \ $(OBJS)\basedll_fmapbase.obj \ $(OBJS)\basedll_fs_zip.obj \ $(OBJS)\basedll_hash.obj \ @@ -551,6 +557,8 @@ BASELIB_OBJECTS = \ $(OBJS)\baselib_filefn.obj \ $(OBJS)\baselib_filename.obj \ $(OBJS)\baselib_filesys.obj \ + $(OBJS)\baselib_filtall.obj \ + $(OBJS)\baselib_filtfind.obj \ $(OBJS)\baselib_fmapbase.obj \ $(OBJS)\baselib_fs_zip.obj \ $(OBJS)\baselib_hash.obj \ @@ -4524,6 +4532,12 @@ $(OBJS)\monodll_filename.obj: ..\..\src\common\filename.cpp $(OBJS)\monodll_filesys.obj: ..\..\src\common\filesys.cpp $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) $** +$(OBJS)\monodll_filtall.obj: ..\..\src\common\filtall.cpp + $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) $** + +$(OBJS)\monodll_filtfind.obj: ..\..\src\common\filtfind.cpp + $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) $** + $(OBJS)\monodll_fmapbase.obj: ..\..\src\common\fmapbase.cpp $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) $** @@ -6474,6 +6488,12 @@ $(OBJS)\monolib_filename.obj: ..\..\src\common\filename.cpp $(OBJS)\monolib_filesys.obj: ..\..\src\common\filesys.cpp $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) $** +$(OBJS)\monolib_filtall.obj: ..\..\src\common\filtall.cpp + $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) $** + +$(OBJS)\monolib_filtfind.obj: ..\..\src\common\filtfind.cpp + $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) $** + $(OBJS)\monolib_fmapbase.obj: ..\..\src\common\fmapbase.cpp $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) $** @@ -8427,6 +8447,12 @@ $(OBJS)\basedll_filename.obj: ..\..\src\common\filename.cpp $(OBJS)\basedll_filesys.obj: ..\..\src\common\filesys.cpp $(CXX) -q -c -P -o$@ $(BASEDLL_CXXFLAGS) $** +$(OBJS)\basedll_filtall.obj: ..\..\src\common\filtall.cpp + $(CXX) -q -c -P -o$@ $(BASEDLL_CXXFLAGS) $** + +$(OBJS)\basedll_filtfind.obj: ..\..\src\common\filtfind.cpp + $(CXX) -q -c -P -o$@ $(BASEDLL_CXXFLAGS) $** + $(OBJS)\basedll_fmapbase.obj: ..\..\src\common\fmapbase.cpp $(CXX) -q -c -P -o$@ $(BASEDLL_CXXFLAGS) $** @@ -8676,6 +8702,12 @@ $(OBJS)\baselib_filename.obj: ..\..\src\common\filename.cpp $(OBJS)\baselib_filesys.obj: ..\..\src\common\filesys.cpp $(CXX) -q -c -P -o$@ $(BASELIB_CXXFLAGS) $** +$(OBJS)\baselib_filtall.obj: ..\..\src\common\filtall.cpp + $(CXX) -q -c -P -o$@ $(BASELIB_CXXFLAGS) $** + +$(OBJS)\baselib_filtfind.obj: ..\..\src\common\filtfind.cpp + $(CXX) -q -c -P -o$@ $(BASELIB_CXXFLAGS) $** + $(OBJS)\baselib_fmapbase.obj: ..\..\src\common\fmapbase.cpp $(CXX) -q -c -P -o$@ $(BASELIB_CXXFLAGS) $** diff --git a/build/msw/makefile.gcc b/build/msw/makefile.gcc index 25182e46fc..2c33ab44ff 100644 --- a/build/msw/makefile.gcc +++ b/build/msw/makefile.gcc @@ -209,6 +209,8 @@ MONODLL_OBJECTS = \ $(OBJS)\monodll_filefn.o \ $(OBJS)\monodll_filename.o \ $(OBJS)\monodll_filesys.o \ + $(OBJS)\monodll_filtall.o \ + $(OBJS)\monodll_filtfind.o \ $(OBJS)\monodll_fmapbase.o \ $(OBJS)\monodll_fs_zip.o \ $(OBJS)\monodll_hash.o \ @@ -323,6 +325,8 @@ MONOLIB_OBJECTS = \ $(OBJS)\monolib_filefn.o \ $(OBJS)\monolib_filename.o \ $(OBJS)\monolib_filesys.o \ + $(OBJS)\monolib_filtall.o \ + $(OBJS)\monolib_filtfind.o \ $(OBJS)\monolib_fmapbase.o \ $(OBJS)\monolib_fs_zip.o \ $(OBJS)\monolib_hash.o \ @@ -439,6 +443,8 @@ BASEDLL_OBJECTS = \ $(OBJS)\basedll_filefn.o \ $(OBJS)\basedll_filename.o \ $(OBJS)\basedll_filesys.o \ + $(OBJS)\basedll_filtall.o \ + $(OBJS)\basedll_filtfind.o \ $(OBJS)\basedll_fmapbase.o \ $(OBJS)\basedll_fs_zip.o \ $(OBJS)\basedll_hash.o \ @@ -538,6 +544,8 @@ BASELIB_OBJECTS = \ $(OBJS)\baselib_filefn.o \ $(OBJS)\baselib_filename.o \ $(OBJS)\baselib_filesys.o \ + $(OBJS)\baselib_filtall.o \ + $(OBJS)\baselib_filtfind.o \ $(OBJS)\baselib_fmapbase.o \ $(OBJS)\baselib_fs_zip.o \ $(OBJS)\baselib_hash.o \ @@ -4641,6 +4649,12 @@ $(OBJS)\monodll_filename.o: ../../src/common/filename.cpp $(OBJS)\monodll_filesys.o: ../../src/common/filesys.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\monodll_filtall.o: ../../src/common/filtall.cpp + $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\monodll_filtfind.o: ../../src/common/filtfind.cpp + $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\monodll_fmapbase.o: ../../src/common/fmapbase.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< @@ -6691,6 +6705,12 @@ $(OBJS)\monolib_filename.o: ../../src/common/filename.cpp $(OBJS)\monolib_filesys.o: ../../src/common/filesys.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\monolib_filtall.o: ../../src/common/filtall.cpp + $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\monolib_filtfind.o: ../../src/common/filtfind.cpp + $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\monolib_fmapbase.o: ../../src/common/fmapbase.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< @@ -8744,6 +8764,12 @@ $(OBJS)\basedll_filename.o: ../../src/common/filename.cpp $(OBJS)\basedll_filesys.o: ../../src/common/filesys.cpp $(CXX) -c -o $@ $(BASEDLL_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\basedll_filtall.o: ../../src/common/filtall.cpp + $(CXX) -c -o $@ $(BASEDLL_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\basedll_filtfind.o: ../../src/common/filtfind.cpp + $(CXX) -c -o $@ $(BASEDLL_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\basedll_fmapbase.o: ../../src/common/fmapbase.cpp $(CXX) -c -o $@ $(BASEDLL_CXXFLAGS) $(CPPDEPS) $< @@ -8993,6 +9019,12 @@ $(OBJS)\baselib_filename.o: ../../src/common/filename.cpp $(OBJS)\baselib_filesys.o: ../../src/common/filesys.cpp $(CXX) -c -o $@ $(BASELIB_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\baselib_filtall.o: ../../src/common/filtall.cpp + $(CXX) -c -o $@ $(BASELIB_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\baselib_filtfind.o: ../../src/common/filtfind.cpp + $(CXX) -c -o $@ $(BASELIB_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\baselib_fmapbase.o: ../../src/common/fmapbase.cpp $(CXX) -c -o $@ $(BASELIB_CXXFLAGS) $(CPPDEPS) $< diff --git a/build/msw/makefile.vc b/build/msw/makefile.vc index c21b1b80fd..17b6295b4b 100644 --- a/build/msw/makefile.vc +++ b/build/msw/makefile.vc @@ -224,6 +224,8 @@ MONODLL_OBJECTS = \ $(OBJS)\monodll_filefn.obj \ $(OBJS)\monodll_filename.obj \ $(OBJS)\monodll_filesys.obj \ + $(OBJS)\monodll_filtall.obj \ + $(OBJS)\monodll_filtfind.obj \ $(OBJS)\monodll_fmapbase.obj \ $(OBJS)\monodll_fs_zip.obj \ $(OBJS)\monodll_hash.obj \ @@ -343,6 +345,8 @@ MONOLIB_OBJECTS = \ $(OBJS)\monolib_filefn.obj \ $(OBJS)\monolib_filename.obj \ $(OBJS)\monolib_filesys.obj \ + $(OBJS)\monolib_filtall.obj \ + $(OBJS)\monolib_filtfind.obj \ $(OBJS)\monolib_fmapbase.obj \ $(OBJS)\monolib_fs_zip.obj \ $(OBJS)\monolib_hash.obj \ @@ -464,6 +468,8 @@ BASEDLL_OBJECTS = \ $(OBJS)\basedll_filefn.obj \ $(OBJS)\basedll_filename.obj \ $(OBJS)\basedll_filesys.obj \ + $(OBJS)\basedll_filtall.obj \ + $(OBJS)\basedll_filtfind.obj \ $(OBJS)\basedll_fmapbase.obj \ $(OBJS)\basedll_fs_zip.obj \ $(OBJS)\basedll_hash.obj \ @@ -569,6 +575,8 @@ BASELIB_OBJECTS = \ $(OBJS)\baselib_filefn.obj \ $(OBJS)\baselib_filename.obj \ $(OBJS)\baselib_filesys.obj \ + $(OBJS)\baselib_filtall.obj \ + $(OBJS)\baselib_filtfind.obj \ $(OBJS)\baselib_fmapbase.obj \ $(OBJS)\baselib_fs_zip.obj \ $(OBJS)\baselib_hash.obj \ @@ -4857,6 +4865,12 @@ $(OBJS)\monodll_filename.obj: ..\..\src\common\filename.cpp $(OBJS)\monodll_filesys.obj: ..\..\src\common\filesys.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $** +$(OBJS)\monodll_filtall.obj: ..\..\src\common\filtall.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $** + +$(OBJS)\monodll_filtfind.obj: ..\..\src\common\filtfind.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $** + $(OBJS)\monodll_fmapbase.obj: ..\..\src\common\fmapbase.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $** @@ -6807,6 +6821,12 @@ $(OBJS)\monolib_filename.obj: ..\..\src\common\filename.cpp $(OBJS)\monolib_filesys.obj: ..\..\src\common\filesys.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $** +$(OBJS)\monolib_filtall.obj: ..\..\src\common\filtall.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $** + +$(OBJS)\monolib_filtfind.obj: ..\..\src\common\filtfind.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $** + $(OBJS)\monolib_fmapbase.obj: ..\..\src\common\fmapbase.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $** @@ -8760,6 +8780,12 @@ $(OBJS)\basedll_filename.obj: ..\..\src\common\filename.cpp $(OBJS)\basedll_filesys.obj: ..\..\src\common\filesys.cpp $(CXX) /c /nologo /TP /Fo$@ $(BASEDLL_CXXFLAGS) $** +$(OBJS)\basedll_filtall.obj: ..\..\src\common\filtall.cpp + $(CXX) /c /nologo /TP /Fo$@ $(BASEDLL_CXXFLAGS) $** + +$(OBJS)\basedll_filtfind.obj: ..\..\src\common\filtfind.cpp + $(CXX) /c /nologo /TP /Fo$@ $(BASEDLL_CXXFLAGS) $** + $(OBJS)\basedll_fmapbase.obj: ..\..\src\common\fmapbase.cpp $(CXX) /c /nologo /TP /Fo$@ $(BASEDLL_CXXFLAGS) $** @@ -9009,6 +9035,12 @@ $(OBJS)\baselib_filename.obj: ..\..\src\common\filename.cpp $(OBJS)\baselib_filesys.obj: ..\..\src\common\filesys.cpp $(CXX) /c /nologo /TP /Fo$@ $(BASELIB_CXXFLAGS) $** +$(OBJS)\baselib_filtall.obj: ..\..\src\common\filtall.cpp + $(CXX) /c /nologo /TP /Fo$@ $(BASELIB_CXXFLAGS) $** + +$(OBJS)\baselib_filtfind.obj: ..\..\src\common\filtfind.cpp + $(CXX) /c /nologo /TP /Fo$@ $(BASELIB_CXXFLAGS) $** + $(OBJS)\baselib_fmapbase.obj: ..\..\src\common\fmapbase.cpp $(CXX) /c /nologo /TP /Fo$@ $(BASELIB_CXXFLAGS) $** diff --git a/build/msw/makefile.wat b/build/msw/makefile.wat index c8899666da..16fcfcd992 100644 --- a/build/msw/makefile.wat +++ b/build/msw/makefile.wat @@ -2918,6 +2918,8 @@ MONODLL_OBJECTS = & $(OBJS)\monodll_filefn.obj & $(OBJS)\monodll_filename.obj & $(OBJS)\monodll_filesys.obj & + $(OBJS)\monodll_filtall.obj & + $(OBJS)\monodll_filtfind.obj & $(OBJS)\monodll_fmapbase.obj & $(OBJS)\monodll_fs_zip.obj & $(OBJS)\monodll_hash.obj & @@ -3032,6 +3034,8 @@ MONOLIB_OBJECTS = & $(OBJS)\monolib_filefn.obj & $(OBJS)\monolib_filename.obj & $(OBJS)\monolib_filesys.obj & + $(OBJS)\monolib_filtall.obj & + $(OBJS)\monolib_filtfind.obj & $(OBJS)\monolib_fmapbase.obj & $(OBJS)\monolib_fs_zip.obj & $(OBJS)\monolib_hash.obj & @@ -3148,6 +3152,8 @@ BASEDLL_OBJECTS = & $(OBJS)\basedll_filefn.obj & $(OBJS)\basedll_filename.obj & $(OBJS)\basedll_filesys.obj & + $(OBJS)\basedll_filtall.obj & + $(OBJS)\basedll_filtfind.obj & $(OBJS)\basedll_fmapbase.obj & $(OBJS)\basedll_fs_zip.obj & $(OBJS)\basedll_hash.obj & @@ -3248,6 +3254,8 @@ BASELIB_OBJECTS = & $(OBJS)\baselib_filefn.obj & $(OBJS)\baselib_filename.obj & $(OBJS)\baselib_filesys.obj & + $(OBJS)\baselib_filtall.obj & + $(OBJS)\baselib_filtfind.obj & $(OBJS)\baselib_fmapbase.obj & $(OBJS)\baselib_fs_zip.obj & $(OBJS)\baselib_hash.obj & @@ -4869,6 +4877,12 @@ $(OBJS)\monodll_filename.obj : .AUTODEPEND ..\..\src\common\filename.cpp $(OBJS)\monodll_filesys.obj : .AUTODEPEND ..\..\src\common\filesys.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< +$(OBJS)\monodll_filtall.obj : .AUTODEPEND ..\..\src\common\filtall.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< + +$(OBJS)\monodll_filtfind.obj : .AUTODEPEND ..\..\src\common\filtfind.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< + $(OBJS)\monodll_fmapbase.obj : .AUTODEPEND ..\..\src\common\fmapbase.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< @@ -6919,6 +6933,12 @@ $(OBJS)\monolib_filename.obj : .AUTODEPEND ..\..\src\common\filename.cpp $(OBJS)\monolib_filesys.obj : .AUTODEPEND ..\..\src\common\filesys.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< +$(OBJS)\monolib_filtall.obj : .AUTODEPEND ..\..\src\common\filtall.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< + +$(OBJS)\monolib_filtfind.obj : .AUTODEPEND ..\..\src\common\filtfind.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< + $(OBJS)\monolib_fmapbase.obj : .AUTODEPEND ..\..\src\common\fmapbase.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< @@ -8972,6 +8992,12 @@ $(OBJS)\basedll_filename.obj : .AUTODEPEND ..\..\src\common\filename.cpp $(OBJS)\basedll_filesys.obj : .AUTODEPEND ..\..\src\common\filesys.cpp $(CXX) -bt=nt -zq -fo=$^@ $(BASEDLL_CXXFLAGS) $< +$(OBJS)\basedll_filtall.obj : .AUTODEPEND ..\..\src\common\filtall.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(BASEDLL_CXXFLAGS) $< + +$(OBJS)\basedll_filtfind.obj : .AUTODEPEND ..\..\src\common\filtfind.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(BASEDLL_CXXFLAGS) $< + $(OBJS)\basedll_fmapbase.obj : .AUTODEPEND ..\..\src\common\fmapbase.cpp $(CXX) -bt=nt -zq -fo=$^@ $(BASEDLL_CXXFLAGS) $< @@ -9221,6 +9247,12 @@ $(OBJS)\baselib_filename.obj : .AUTODEPEND ..\..\src\common\filename.cpp $(OBJS)\baselib_filesys.obj : .AUTODEPEND ..\..\src\common\filesys.cpp $(CXX) -bt=nt -zq -fo=$^@ $(BASELIB_CXXFLAGS) $< +$(OBJS)\baselib_filtall.obj : .AUTODEPEND ..\..\src\common\filtall.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(BASELIB_CXXFLAGS) $< + +$(OBJS)\baselib_filtfind.obj : .AUTODEPEND ..\..\src\common\filtfind.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(BASELIB_CXXFLAGS) $< + $(OBJS)\baselib_fmapbase.obj : .AUTODEPEND ..\..\src\common\fmapbase.cpp $(CXX) -bt=nt -zq -fo=$^@ $(BASELIB_CXXFLAGS) $< diff --git a/build/msw/wx_base.dsp b/build/msw/wx_base.dsp index fd3c321ad2..76dd165f70 100644 --- a/build/msw/wx_base.dsp +++ b/build/msw/wx_base.dsp @@ -547,6 +547,14 @@ SOURCE=..\..\src\common\filesys.cpp # End Source File # Begin Source File +SOURCE=..\..\src\common\filtall.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\src\common\filtfind.cpp +# End Source File +# Begin Source File + SOURCE=..\..\src\common\fmapbase.cpp # End Source File # Begin Source File diff --git a/include/wx/stream.h b/include/wx/stream.h index 652c40481f..6d3da3c914 100644 --- a/include/wx/stream.h +++ b/include/wx/stream.h @@ -288,6 +288,7 @@ class WXDLLIMPEXP_BASE wxFilterInputStream : public wxInputStream public: wxFilterInputStream(); wxFilterInputStream(wxInputStream& stream); + wxFilterInputStream(wxInputStream *stream); virtual ~wxFilterInputStream(); char Peek() { return m_parent_i_stream->Peek(); } @@ -298,6 +299,7 @@ public: protected: wxInputStream *m_parent_i_stream; + bool m_owns; DECLARE_NO_COPY_CLASS(wxFilterInputStream) }; @@ -307,18 +309,74 @@ class WXDLLIMPEXP_BASE wxFilterOutputStream : public wxOutputStream public: wxFilterOutputStream(); wxFilterOutputStream(wxOutputStream& stream); + wxFilterOutputStream(wxOutputStream *stream); virtual ~wxFilterOutputStream(); wxFileOffset GetLength() const { return m_parent_o_stream->GetLength(); } wxOutputStream *GetFilterOutputStream() const { return m_parent_o_stream; } + bool Close(); + protected: wxOutputStream *m_parent_o_stream; + bool m_owns; DECLARE_NO_COPY_CLASS(wxFilterOutputStream) }; +enum wxStreamProtocolType +{ + wxSTREAM_PROTOCOL, // wxFileSystem protocol (should be only one) + wxSTREAM_MIMETYPE, // Mime types the stream handles + wxSTREAM_ENCODING, // The http Content-Encodings the stream handles + wxSTREAM_FILEEXTENSION // File extensions the stream handles +}; + +void WXDLLIMPEXP_BASE wxUseFilterClasses(); + +class WXDLLIMPEXP_BASE wxFilterClassFactory : public wxObject +{ +public: + virtual ~wxFilterClassFactory() { } + + virtual wxFilterInputStream *NewStream(wxInputStream& stream) const = 0; + virtual wxFilterOutputStream *NewStream(wxOutputStream& stream) const = 0; + virtual wxFilterInputStream *NewStream(wxInputStream *stream) const = 0; + virtual wxFilterOutputStream *NewStream(wxOutputStream *stream) const = 0; + + wxString GetProtocol() const { return wxString(*GetProtocols()); } + + virtual const wxChar * const *GetProtocols(wxStreamProtocolType type + = wxSTREAM_PROTOCOL) const = 0; + + bool CanHandle(const wxChar *protocol, + wxStreamProtocolType type + = wxSTREAM_PROTOCOL) const; + + static const wxFilterClassFactory *Find(const wxChar *protocol, + wxStreamProtocolType type + = wxSTREAM_PROTOCOL); + + static const wxFilterClassFactory *GetFirst(); + const wxFilterClassFactory *GetNext() const { return m_next; } + + void PushFront() { Remove(); m_next = sm_first; sm_first = this; } + void Remove(); + +protected: + wxFilterClassFactory() : m_next(this) { } + + wxFilterClassFactory& operator=(const wxFilterClassFactory&) + { return *this; } + +private: + static wxFilterClassFactory *sm_first; + wxFilterClassFactory *m_next; + + DECLARE_ABSTRACT_CLASS(wxFilterClassFactory) +}; + // ============================================================================ // buffered streams // ============================================================================ diff --git a/src/common/filtall.cpp b/src/common/filtall.cpp new file mode 100644 index 0000000000..7dab767d0a --- /dev/null +++ b/src/common/filtall.cpp @@ -0,0 +1,36 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/common/filtall.cpp +// Purpose: Link all filter streams +// Author: Mike Wetherell +// RCS-ID: $Id$ +// Copyright: (c) 2006 Mike Wetherell +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#if wxUSE_STREAMS + +#if wxUSE_ZLIB +#include "wx/zstream.h" +#endif + +// Reference filter classes to ensure they are linked into a statically +// linked program that uses Find or GetFirst to look for an filter handler. +// It is in its own file so that the user can override this behaviour by +// providing their own implementation. + +void wxUseFilterClasses() +{ +#if wxUSE_ZLIB + wxZlibClassFactory(); + wxGzipClassFactory(); +#endif +} + +#endif // wxUSE_STREAMS diff --git a/src/common/filtfind.cpp b/src/common/filtfind.cpp new file mode 100644 index 0000000000..bd7d5a6c8a --- /dev/null +++ b/src/common/filtfind.cpp @@ -0,0 +1,43 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/common/filtfind.cpp +// Purpose: Streams for filter formats +// Author: Mike Wetherell +// RCS-ID: $Id$ +// Copyright: (c) Mike Wetherell +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#if wxUSE_STREAMS + +#include "wx/stream.h" + +// These functions are in a separate file so that statically linked apps +// that do not call them to search for filter handlers will only link in +// the filter classes they use. + +const wxFilterClassFactory * +wxFilterClassFactory::Find(const wxChar *protocol, wxStreamProtocolType type) +{ + for (const wxFilterClassFactory *f = GetFirst(); f; f = f->GetNext()) + if (f->CanHandle(protocol, type)) + return f; + + return NULL; +} + +// static +const wxFilterClassFactory *wxFilterClassFactory::GetFirst() +{ + if (!sm_first) + wxUseFilterClasses(); + return sm_first; +} + +#endif // wxUSE_STREAMS diff --git a/src/common/stream.cpp b/src/common/stream.cpp index 18bcc6f518..618ae6ed32 100644 --- a/src/common/stream.cpp +++ b/src/common/stream.cpp @@ -1046,17 +1046,27 @@ wxFileOffset wxCountingOutputStream::OnSysTell() const // ---------------------------------------------------------------------------- wxFilterInputStream::wxFilterInputStream() + : m_parent_i_stream(NULL), + m_owns(false) { - m_parent_i_stream = NULL; } wxFilterInputStream::wxFilterInputStream(wxInputStream& stream) + : m_parent_i_stream(&stream), + m_owns(false) +{ +} + +wxFilterInputStream::wxFilterInputStream(wxInputStream *stream) + : m_parent_i_stream(stream), + m_owns(true) { - m_parent_i_stream = &stream; } wxFilterInputStream::~wxFilterInputStream() { + if (m_owns) + delete m_parent_i_stream; } // ---------------------------------------------------------------------------- @@ -1064,17 +1074,83 @@ wxFilterInputStream::~wxFilterInputStream() // ---------------------------------------------------------------------------- wxFilterOutputStream::wxFilterOutputStream() + : m_parent_o_stream(NULL), + m_owns(false) { - m_parent_o_stream = NULL; } wxFilterOutputStream::wxFilterOutputStream(wxOutputStream& stream) + : m_parent_o_stream(&stream), + m_owns(false) +{ +} + +wxFilterOutputStream::wxFilterOutputStream(wxOutputStream *stream) + : m_parent_o_stream(stream), + m_owns(true) +{ +} + +bool wxFilterOutputStream::Close() { - m_parent_o_stream = &stream; + if (m_parent_o_stream && m_owns) + return m_parent_o_stream->Close(); + else + return true; } wxFilterOutputStream::~wxFilterOutputStream() { + if (m_owns) + delete m_parent_o_stream; +} + +// ---------------------------------------------------------------------------- +// wxFilterClassFactory +// ---------------------------------------------------------------------------- + +IMPLEMENT_ABSTRACT_CLASS(wxFilterClassFactory, wxObject) + +wxFilterClassFactory *wxFilterClassFactory::sm_first = NULL; + +bool wxFilterClassFactory::CanHandle(const wxChar *protocol, + wxStreamProtocolType type) const +{ + if (type == wxSTREAM_FILEEXTENSION) + { + size_t len = wxStrlen(protocol); + + for (const wxChar * const *p = GetProtocols(type); p && *p; p++) + { + size_t l = wxStrlen(*p); + + if (l <= len && wxStrcmp(*p, protocol + len - l) == 0) + return true; + } + } + else + { + for (const wxChar * const *p = GetProtocols(type); p && *p; p++) + if (wxStrcmp(*p, protocol) == 0) + return true; + } + + return false; +} + +void wxFilterClassFactory::Remove() +{ + if (m_next != this) + { + wxFilterClassFactory **pp = &sm_first; + + while (*pp != this) + pp = &(*pp)->m_next; + + *pp = m_next; + + m_next = this; + } } // ---------------------------------------------------------------------------- diff --git a/src/wxWindows.dsp b/src/wxWindows.dsp index 34e01edce0..27e5643fc7 100644 --- a/src/wxWindows.dsp +++ b/src/wxWindows.dsp @@ -543,6 +543,14 @@ SOURCE=.\common\filesys.cpp # End Source File # Begin Source File +SOURCE=.\common\filtall.cpp +# End Source File +# Begin Source File + +SOURCE=.\common\filtfind.cpp +# End Source File +# Begin Source File + SOURCE=.\common\fldlgcmn.cpp # End Source File # Begin Source File -- 2.45.2