Add wxUSE_ARCSTREAM so that other archive classes can be used without wxZip

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31891 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Michael Wetherell
2005-02-10 13:54:41 +00:00
parent 50bf89f702
commit 81f9033602
13 changed files with 234 additions and 77 deletions

View File

@@ -16,7 +16,7 @@
#include "wx/defs.h"
#if wxUSE_ZLIB && wxUSE_STREAMS && wxUSE_ZIPSTREAM
#if wxUSE_STREAMS && wxUSE_ARCSTREAM
#include "wx/stream.h"
#include "wx/filename.h"
@@ -161,47 +161,6 @@ private:
};
/////////////////////////////////////////////////////////////////////////////
// wxArchiveClassFactory
//
// A wxArchiveClassFactory instance for a particular archive type allows
// the creation of the other classes that may be needed.
class WXDLLIMPEXP_BASE wxArchiveClassFactory : public wxObject
{
public:
virtual ~wxArchiveClassFactory() { }
wxArchiveEntry *NewEntry() const
{ return DoNewEntry(); }
wxArchiveInputStream *NewStream(wxInputStream& stream) const
{ return DoNewStream(stream); }
wxArchiveOutputStream *NewStream(wxOutputStream& stream) const
{ return DoNewStream(stream); }
virtual wxString GetInternalName(
const wxString& name,
wxPathFormat format = wxPATH_NATIVE) const = 0;
void SetConv(wxMBConv& conv) { m_pConv = &conv; }
wxMBConv& GetConv() const { return *m_pConv; }
protected:
virtual wxArchiveEntry *DoNewEntry() const = 0;
virtual wxArchiveInputStream *DoNewStream(wxInputStream& stream) const = 0;
virtual wxArchiveOutputStream *DoNewStream(wxOutputStream& stream) const = 0;
wxArchiveClassFactory() : m_pConv(&wxConvLocal) { }
wxArchiveClassFactory& operator=(const wxArchiveClassFactory& WXUNUSED(f))
{ return *this; }
private:
wxMBConv *m_pConv;
DECLARE_ABSTRACT_CLASS(wxArchiveClassFactory)
};
/////////////////////////////////////////////////////////////////////////////
// wxArchiveIterator
//
@@ -346,6 +305,56 @@ typedef wxArchiveIterator<wxArchiveInputStream,
#endif // wxUSE_STL || defined WX_TEST_ARCHIVE_ITERATOR
#endif // wxUSE_STREAMS
/////////////////////////////////////////////////////////////////////////////
// wxArchiveClassFactory
//
// A wxArchiveClassFactory instance for a particular archive type allows
// the creation of the other classes that may be needed.
class WXDLLIMPEXP_BASE wxArchiveClassFactory : public wxObject
{
public:
typedef wxArchiveEntry entry_type;
typedef wxArchiveInputStream instream_type;
typedef wxArchiveOutputStream outstream_type;
typedef wxArchiveNotifier notifier_type;
#if wxUSE_STL || defined WX_TEST_ARCHIVE_ITERATOR
typedef wxArchiveIter iter_type;
typedef wxArchivePairIter pairiter_type;
#endif
virtual ~wxArchiveClassFactory() { }
wxArchiveEntry *NewEntry() const
{ return DoNewEntry(); }
wxArchiveInputStream *NewStream(wxInputStream& stream) const
{ return DoNewStream(stream); }
wxArchiveOutputStream *NewStream(wxOutputStream& stream) const
{ return DoNewStream(stream); }
virtual wxString GetInternalName(
const wxString& name,
wxPathFormat format = wxPATH_NATIVE) const = 0;
void SetConv(wxMBConv& conv) { m_pConv = &conv; }
wxMBConv& GetConv() const { return *m_pConv; }
protected:
virtual wxArchiveEntry *DoNewEntry() const = 0;
virtual wxArchiveInputStream *DoNewStream(wxInputStream& stream) const = 0;
virtual wxArchiveOutputStream *DoNewStream(wxOutputStream& stream) const = 0;
wxArchiveClassFactory() : m_pConv(&wxConvLocal) { }
wxArchiveClassFactory& operator=(const wxArchiveClassFactory& WXUNUSED(f))
{ return *this; }
private:
wxMBConv *m_pConv;
DECLARE_ABSTRACT_CLASS(wxArchiveClassFactory)
};
#endif // wxUSE_STREAMS && wxUSE_ARCSTREAM
#endif // _WX_ARCHIVE_H__

View File

@@ -924,6 +924,25 @@
# endif
#endif /* wxUSE_DYNLIB_CLASS */
#if wxUSE_ZIPSTREAM
# if !wxUSE_ZLIB
# ifdef wxABORT_ON_CONFIG_ERROR
# error "wxZip requires wxZlib"
# else
# undef wxUSE_ZLIB
# define wxUSE_ZLIB 1
# endif
# endif
# if !wxUSE_ARCSTREAM
# ifdef wxABORT_ON_CONFIG_ERROR
# error "wxZip requires wxArchive"
# else
# undef wxUSE_ARCSTREAM
# define wxUSE_ARCSTREAM 1
# endif
# endif
#endif /* wxUSE_ZIPSTREAM */
/* the rest of the tests is for the GUI settings only */
#if wxUSE_GUI

View File

@@ -391,6 +391,9 @@
// Set to 1 to enable virtual Internet filesystem (requires wxUSE_FILESYSTEM)
#define wxUSE_FS_INET 1
// wxArchive classes for accessing archives such as zip and tar
#define wxUSE_ARCSTREAM 1
// Set to 1 to compile wxZipInput/OutputStream classes.
#define wxUSE_ZIPSTREAM 1
@@ -575,11 +578,7 @@
// Default is 1 for the platforms where native status bar is supported.
//
// Recommended setting: 1 (there is no advantage in using the generic one)
#if defined(__WXMSW__) || defined(__WXMAC__)
#define wxUSE_NATIVE_STATUSBAR 1
#else
#define wxUSE_NATIVE_STATUSBAR 0
#endif
// wxToolBar related settings: if wxUSE_TOOLBAR is 0, don't compile any toolbar
// classes at all. Otherwise, use the native toolbar class unless

View File

@@ -385,6 +385,9 @@
// Set to 1 to enable virtual Internet filesystem (requires wxUSE_FILESYSTEM)
#define wxUSE_FS_INET 1
// wxArchive classes for accessing archives such as zip and tar
#define wxUSE_ARCSTREAM 1
// Set to 1 to compile wxZipInput/OutputStream classes.
#define wxUSE_ZIPSTREAM 1

View File

@@ -384,6 +384,9 @@
// Set to 1 to enable virtual Internet filesystem (requires wxUSE_FILESYSTEM)
#define wxUSE_FS_INET 0
// wxArchive classes for accessing archives such as zip and tar
#define wxUSE_ARCSTREAM 0
// Set to 1 to compile wxZipInput/OutputStream classes.
#define wxUSE_ZIPSTREAM 0

View File

@@ -375,6 +375,9 @@
// Set to 1 to enable virtual Internet filesystem (requires wxUSE_FILESYSTEM)
#define wxUSE_FS_INET 1
// wxArchive classes for accessing archives such as zip and tar
#define wxUSE_ARCSTREAM 1
// Set to 1 to compile wxZipInput/OutputStream classes.
#define wxUSE_ZIPSTREAM 1

View File

@@ -412,6 +412,9 @@
// Set to 1 to enable virtual ZIP filesystem (requires wxUSE_FILESYSTEM)
#define wxUSE_FS_ZIP 1
// wxArchive classes for accessing archives such as zip and tar
#define wxUSE_ARCSTREAM 1
// Set to 1 to compile wxZipInput/OutputStream classes.
#define wxUSE_ZIPSTREAM 1

View File

@@ -419,12 +419,31 @@ private:
};
/////////////////////////////////////////////////////////////////////////////
// Iterators
#if wxUSE_STL || defined WX_TEST_ARCHIVE_ITERATOR
typedef wxArchiveIterator<wxZipInputStream> wxZipIter;
typedef wxArchiveIterator<wxZipInputStream,
std::pair<wxString, wxZipEntry*> > wxZipPairIter;
#endif
/////////////////////////////////////////////////////////////////////////////
// wxZipClassFactory
class WXDLLIMPEXP_BASE wxZipClassFactory : public wxArchiveClassFactory
{
public:
typedef wxZipEntry entry_type;
typedef wxZipInputStream instream_type;
typedef wxZipOutputStream outstream_type;
typedef wxZipNotifier notifier_type;
#if wxUSE_STL || defined WX_TEST_ARCHIVE_ITERATOR
typedef wxZipIter iter_type;
typedef wxZipPairIter pairiter_type;
#endif
wxZipEntry *NewEntry() const
{ return new wxZipEntry; }
wxZipInputStream *NewStream(wxInputStream& stream) const
@@ -449,16 +468,6 @@ private:
};
/////////////////////////////////////////////////////////////////////////////
// Iterators
#if wxUSE_STL || defined WX_TEST_ARCHIVE_ITERATOR
typedef wxArchiveIterator<wxZipInputStream> wxZipIter;
typedef wxArchiveIterator<wxZipInputStream,
std::pair<wxString, wxZipEntry*> > wxZipPairIter;
#endif
/////////////////////////////////////////////////////////////////////////////
// wxZipEntry inlines