diff --git a/include/wx/stream.h b/include/wx/stream.h index cad5148ab9..505bb34625 100644 --- a/include/wx/stream.h +++ b/include/wx/stream.h @@ -335,15 +335,10 @@ enum wxStreamProtocolType void WXDLLIMPEXP_BASE wxUseFilterClasses(); -class WXDLLIMPEXP_BASE wxFilterClassFactory : public wxObject +class WXDLLIMPEXP_BASE wxFilterClassFactoryBase : 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; + virtual ~wxFilterClassFactoryBase() { } wxString GetProtocol() const { return wxString(*GetProtocols()); } wxString PopExtension(const wxString& location) const; @@ -355,6 +350,22 @@ public: wxStreamProtocolType type = wxSTREAM_PROTOCOL) const; +protected: + wxString::size_type FindExtension(const wxChar *location) const; + + DECLARE_ABSTRACT_CLASS(wxFilterClassFactoryBase) +}; + +class WXDLLIMPEXP_BASE wxFilterClassFactory : public wxFilterClassFactoryBase +{ +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; + static const wxFilterClassFactory *Find(const wxChar *protocol, wxStreamProtocolType type = wxSTREAM_PROTOCOL); @@ -371,8 +382,6 @@ protected: wxFilterClassFactory& operator=(const wxFilterClassFactory&) { return *this; } - wxString::size_type FindExtension(const wxChar *location) const; - private: static wxFilterClassFactory *sm_first; wxFilterClassFactory *m_next; diff --git a/src/common/stream.cpp b/src/common/stream.cpp index 8aa12b5e24..5407bd2062 100644 --- a/src/common/stream.cpp +++ b/src/common/stream.cpp @@ -1106,19 +1106,18 @@ wxFilterOutputStream::~wxFilterOutputStream() } // ---------------------------------------------------------------------------- -// wxFilterClassFactory +// wxFilterClassFactoryBase // ---------------------------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(wxFilterClassFactory, wxObject) +IMPLEMENT_ABSTRACT_CLASS(wxFilterClassFactoryBase, wxObject) -wxFilterClassFactory *wxFilterClassFactory::sm_first = NULL; - -wxString wxFilterClassFactory::PopExtension(const wxString& location) const +wxString wxFilterClassFactoryBase::PopExtension(const wxString& location) const { return location.substr(0, FindExtension(location)); } -wxString::size_type wxFilterClassFactory::FindExtension(const wxChar *location) const +wxString::size_type wxFilterClassFactoryBase::FindExtension( + const wxChar *location) const { size_t len = wxStrlen(location); @@ -1135,8 +1134,8 @@ wxString::size_type wxFilterClassFactory::FindExtension(const wxChar *location) return wxString::npos; } -bool wxFilterClassFactory::CanHandle(const wxChar *protocol, - wxStreamProtocolType type) const +bool wxFilterClassFactoryBase::CanHandle(const wxChar *protocol, + wxStreamProtocolType type) const { if (type == wxSTREAM_FILEEXTENSION) return FindExtension(protocol) != wxString::npos; @@ -1148,6 +1147,14 @@ bool wxFilterClassFactory::CanHandle(const wxChar *protocol, return false; } +// ---------------------------------------------------------------------------- +// wxFilterClassFactory +// ---------------------------------------------------------------------------- + +IMPLEMENT_ABSTRACT_CLASS(wxFilterClassFactory, wxFilterClassFactoryBase) + +wxFilterClassFactory *wxFilterClassFactory::sm_first = NULL; + void wxFilterClassFactory::Remove() { if (m_next != this)