Factory some of wxFilterClassFactory into a base class.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42492 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
9a88fc5836
commit
58211774c8
@ -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;
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user