Base class factory on the wxFilter base class and implement the new Find feature.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42508 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -104,6 +104,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxArchiveInputStream(wxInputStream& stream, wxMBConv& conv);
|
wxArchiveInputStream(wxInputStream& stream, wxMBConv& conv);
|
||||||
|
wxArchiveInputStream(wxInputStream *stream, wxMBConv& conv);
|
||||||
|
|
||||||
virtual wxArchiveEntry *DoGetNextEntry() = 0;
|
virtual wxArchiveEntry *DoGetNextEntry() = 0;
|
||||||
|
|
||||||
@@ -149,6 +150,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxArchiveOutputStream(wxOutputStream& stream, wxMBConv& conv);
|
wxArchiveOutputStream(wxOutputStream& stream, wxMBConv& conv);
|
||||||
|
wxArchiveOutputStream(wxOutputStream *stream, wxMBConv& conv);
|
||||||
|
|
||||||
wxMBConv& GetConv() const { return m_conv; }
|
wxMBConv& GetConv() const { return m_conv; }
|
||||||
|
|
||||||
@@ -308,7 +310,9 @@ typedef wxArchiveIterator<wxArchiveInputStream,
|
|||||||
// A wxArchiveClassFactory instance for a particular archive type allows
|
// A wxArchiveClassFactory instance for a particular archive type allows
|
||||||
// the creation of the other classes that may be needed.
|
// the creation of the other classes that may be needed.
|
||||||
|
|
||||||
class WXDLLIMPEXP_BASE wxArchiveClassFactory : public wxObject
|
void WXDLLIMPEXP_BASE wxUseArchiveClasses();
|
||||||
|
|
||||||
|
class WXDLLIMPEXP_BASE wxArchiveClassFactory : public wxFilterClassFactoryBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef wxArchiveEntry entry_type;
|
typedef wxArchiveEntry entry_type;
|
||||||
@@ -328,6 +332,10 @@ public:
|
|||||||
{ return DoNewStream(stream); }
|
{ return DoNewStream(stream); }
|
||||||
wxArchiveOutputStream *NewStream(wxOutputStream& stream) const
|
wxArchiveOutputStream *NewStream(wxOutputStream& stream) const
|
||||||
{ return DoNewStream(stream); }
|
{ return DoNewStream(stream); }
|
||||||
|
wxArchiveInputStream *NewStream(wxInputStream *stream) const
|
||||||
|
{ return DoNewStream(stream); }
|
||||||
|
wxArchiveOutputStream *NewStream(wxOutputStream *stream) const
|
||||||
|
{ return DoNewStream(stream); }
|
||||||
|
|
||||||
virtual wxString GetInternalName(
|
virtual wxString GetInternalName(
|
||||||
const wxString& name,
|
const wxString& name,
|
||||||
@@ -336,19 +344,33 @@ public:
|
|||||||
void SetConv(wxMBConv& conv) { m_pConv = &conv; }
|
void SetConv(wxMBConv& conv) { m_pConv = &conv; }
|
||||||
wxMBConv& GetConv() const { return *m_pConv; }
|
wxMBConv& GetConv() const { return *m_pConv; }
|
||||||
|
|
||||||
|
static const wxArchiveClassFactory *Find(const wxChar *protocol,
|
||||||
|
wxStreamProtocolType type
|
||||||
|
= wxSTREAM_PROTOCOL);
|
||||||
|
|
||||||
|
static const wxArchiveClassFactory *GetFirst();
|
||||||
|
const wxArchiveClassFactory *GetNext() const { return m_next; }
|
||||||
|
|
||||||
|
void PushFront() { Remove(); m_next = sm_first; sm_first = this; }
|
||||||
|
void Remove();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// old compilers don't support covarient returns, so 'Do' methods are
|
// old compilers don't support covarient returns, so 'Do' methods are
|
||||||
// used to simulate them
|
// used to simulate them
|
||||||
virtual wxArchiveEntry *DoNewEntry() const = 0;
|
virtual wxArchiveEntry *DoNewEntry() const = 0;
|
||||||
virtual wxArchiveInputStream *DoNewStream(wxInputStream& stream) const = 0;
|
virtual wxArchiveInputStream *DoNewStream(wxInputStream& stream) const = 0;
|
||||||
virtual wxArchiveOutputStream *DoNewStream(wxOutputStream& stream) const = 0;
|
virtual wxArchiveOutputStream *DoNewStream(wxOutputStream& stream) const = 0;
|
||||||
|
virtual wxArchiveInputStream *DoNewStream(wxInputStream *stream) const = 0;
|
||||||
|
virtual wxArchiveOutputStream *DoNewStream(wxOutputStream *stream) const = 0;
|
||||||
|
|
||||||
wxArchiveClassFactory() : m_pConv(&wxConvLocal) { }
|
wxArchiveClassFactory() : m_pConv(&wxConvLocal), m_next(this) { }
|
||||||
wxArchiveClassFactory& operator=(const wxArchiveClassFactory& WXUNUSED(f))
|
wxArchiveClassFactory& operator=(const wxArchiveClassFactory& WXUNUSED(f))
|
||||||
{ return *this; }
|
{ return *this; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxMBConv *m_pConv;
|
wxMBConv *m_pConv;
|
||||||
|
static wxArchiveClassFactory *sm_first;
|
||||||
|
wxArchiveClassFactory *m_next;
|
||||||
|
|
||||||
DECLARE_ABSTRACT_CLASS(wxArchiveClassFactory)
|
DECLARE_ABSTRACT_CLASS(wxArchiveClassFactory)
|
||||||
};
|
};
|
||||||
|
41
src/common/arcall.cpp
Normal file
41
src/common/arcall.cpp
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: src/common/arcall.cpp
|
||||||
|
// Purpose: wxArchive link all archive 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_ARCHIVE_STREAMS
|
||||||
|
|
||||||
|
#if wxUSE_ZIPSTREAM
|
||||||
|
#include "wx/zipstrm.h"
|
||||||
|
#endif
|
||||||
|
#if wxUSE_TARSTREAM
|
||||||
|
#include "wx/tarstrm.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Reference archive classes to ensure they are linked into a statically
|
||||||
|
// linked program that uses Find or GetFirst to look for an archive handler.
|
||||||
|
// It is in its own file so that the user can override this behaviour by
|
||||||
|
// providing their own implementation.
|
||||||
|
|
||||||
|
void wxUseArchiveClasses()
|
||||||
|
{
|
||||||
|
#if wxUSE_ZIPSTREAM
|
||||||
|
wxZipClassFactory();
|
||||||
|
#endif
|
||||||
|
#if wxUSE_TARSTREAM
|
||||||
|
wxTarClassFactory();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_ARCHIVE_STREAMS
|
43
src/common/arcfind.cpp
Normal file
43
src/common/arcfind.cpp
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: src/common/arcfind.cpp
|
||||||
|
// Purpose: Streams for archive 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_ARCHIVE_STREAMS
|
||||||
|
|
||||||
|
#include "wx/archive.h"
|
||||||
|
|
||||||
|
// These functions are in a separate file so that statically linked apps
|
||||||
|
// that do not call them to search for archive handlers will only link in
|
||||||
|
// the archive classes they use.
|
||||||
|
|
||||||
|
const wxArchiveClassFactory *
|
||||||
|
wxArchiveClassFactory::Find(const wxChar *protocol, wxStreamProtocolType type)
|
||||||
|
{
|
||||||
|
for (const wxArchiveClassFactory *f = GetFirst(); f; f = f->GetNext())
|
||||||
|
if (f->CanHandle(protocol, type))
|
||||||
|
return f;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
const wxArchiveClassFactory *wxArchiveClassFactory::GetFirst()
|
||||||
|
{
|
||||||
|
if (!sm_first)
|
||||||
|
wxUseArchiveClasses();
|
||||||
|
return sm_first;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_ARCHIVE_STREAMS
|
@@ -16,18 +16,10 @@
|
|||||||
|
|
||||||
#if wxUSE_STREAMS && wxUSE_ARCHIVE_STREAMS
|
#if wxUSE_STREAMS && wxUSE_ARCHIVE_STREAMS
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/archive.h"
|
#include "wx/archive.h"
|
||||||
#include "wx/link.h"
|
|
||||||
|
|
||||||
IMPLEMENT_ABSTRACT_CLASS(wxArchiveEntry, wxObject)
|
IMPLEMENT_ABSTRACT_CLASS(wxArchiveEntry, wxObject)
|
||||||
IMPLEMENT_ABSTRACT_CLASS(wxArchiveClassFactory, wxObject)
|
IMPLEMENT_ABSTRACT_CLASS(wxArchiveClassFactory, wxFilterClassFactoryBase)
|
||||||
|
|
||||||
#if wxUSE_ZIPSTREAM
|
|
||||||
wxFORCE_LINK_MODULE(zipstrm)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -40,6 +32,13 @@ wxArchiveInputStream::wxArchiveInputStream(wxInputStream& stream,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxArchiveInputStream::wxArchiveInputStream(wxInputStream *stream,
|
||||||
|
wxMBConv& conv)
|
||||||
|
: wxFilterInputStream(stream),
|
||||||
|
m_conv(conv)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// wxArchiveOutputStream
|
// wxArchiveOutputStream
|
||||||
@@ -51,6 +50,13 @@ wxArchiveOutputStream::wxArchiveOutputStream(wxOutputStream& stream,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxArchiveOutputStream::wxArchiveOutputStream(wxOutputStream *stream,
|
||||||
|
wxMBConv& conv)
|
||||||
|
: wxFilterOutputStream(stream),
|
||||||
|
m_conv(conv)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// wxArchiveEntry
|
// wxArchiveEntry
|
||||||
@@ -68,4 +74,25 @@ wxArchiveEntry& wxArchiveEntry::operator=(const wxArchiveEntry& WXUNUSED(e))
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// wxArchiveClassFactory
|
||||||
|
|
||||||
|
wxArchiveClassFactory *wxArchiveClassFactory::sm_first = NULL;
|
||||||
|
|
||||||
|
void wxArchiveClassFactory::Remove()
|
||||||
|
{
|
||||||
|
if (m_next != this)
|
||||||
|
{
|
||||||
|
wxArchiveClassFactory **pp = &sm_first;
|
||||||
|
|
||||||
|
while (*pp != this)
|
||||||
|
pp = &(*pp)->m_next;
|
||||||
|
|
||||||
|
*pp = m_next;
|
||||||
|
|
||||||
|
m_next = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // wxUSE_STREAMS && wxUSE_ARCHIVE_STREAMS
|
#endif // wxUSE_STREAMS && wxUSE_ARCHIVE_STREAMS
|
||||||
|
Reference in New Issue
Block a user