X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/00375592f92f68c4ca3f44d8e839bcfd47adc4e1..0e9cfa51093774485315ddfa53e2b16e215109c2:/include/wx/archive.h diff --git a/include/wx/archive.h b/include/wx/archive.h index fb5a647383..67419a91fc 100644 --- a/include/wx/archive.h +++ b/include/wx/archive.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: archive.h +// Name: wx/archive.h // Purpose: Streams for archive formats // Author: Mike Wetherell // RCS-ID: $Id$ @@ -10,13 +10,9 @@ #ifndef _WX_ARCHIVE_H__ #define _WX_ARCHIVE_H__ -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma interface "archive.h" -#endif - #include "wx/defs.h" -#if wxUSE_ZLIB && wxUSE_STREAMS && wxUSE_ZIPSTREAM +#if wxUSE_STREAMS && wxUSE_ARCHIVE_STREAMS #include "wx/stream.h" #include "wx/filename.h" @@ -59,7 +55,7 @@ public: virtual void SetIsReadOnly(bool isReadOnly = true) = 0; virtual void SetName(const wxString& name, wxPathFormat format = wxPATH_NATIVE) = 0; - + wxArchiveEntry *Clone() const { return DoClone(); } void SetNotifier(wxArchiveNotifier& notifier); @@ -67,6 +63,7 @@ public: protected: wxArchiveEntry() : m_notifier(NULL) { } + wxArchiveEntry(const wxArchiveEntry& e) : wxObject(e), m_notifier(NULL) { } virtual void SetOffset(wxFileOffset offset) = 0; virtual wxArchiveEntry* DoClone() const = 0; @@ -97,16 +94,17 @@ public: typedef wxArchiveEntry entry_type; virtual ~wxArchiveInputStream() { } - + virtual bool OpenEntry(wxArchiveEntry& entry) = 0; virtual bool CloseEntry() = 0; wxArchiveEntry *GetNextEntry() { return DoGetNextEntry(); } virtual char Peek() { return wxInputStream::Peek(); } - + protected: wxArchiveInputStream(wxInputStream& stream, wxMBConv& conv); + wxArchiveInputStream(wxInputStream *stream, wxMBConv& conv); virtual wxArchiveEntry *DoGetNextEntry() = 0; @@ -125,7 +123,7 @@ private: // // Only one entry can be open for output at a time; another call to // PutNextEntry closes the current entry and begins the next. -// +// // The overload 'bool PutNextEntry(wxArchiveEntry *entry)' takes ownership // of the entry object. @@ -149,10 +147,10 @@ public: virtual bool CopyArchiveMetaData(wxArchiveInputStream& stream) = 0; virtual bool CloseEntry() = 0; - virtual bool Close() = 0; protected: wxArchiveOutputStream(wxOutputStream& stream, wxMBConv& conv); + wxArchiveOutputStream(wxOutputStream *stream, wxMBConv& conv); wxMBConv& GetConv() const { return m_conv; } @@ -161,47 +159,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 // @@ -212,14 +169,14 @@ private: #include #include -template -void WXDLLIMPEXP_BASE _wxSetArchiveIteratorValue( +template inline +void _wxSetArchiveIteratorValue( X& val, Y entry, void *WXUNUSED(d)) { val = X(entry); } -template -void WXDLLIMPEXP_BASE _wxSetArchiveIteratorValue( +template inline +void _wxSetArchiveIteratorValue( std::pair& val, Z entry, Z WXUNUSED(d)) { val = std::make_pair(X(entry->GetInternalName()), Y(entry)); @@ -230,7 +187,7 @@ template #else template #endif -class WXDLLIMPEXP_BASE wxArchiveIterator +class wxArchiveIterator { public: typedef std::input_iterator_tag iterator_category; @@ -250,7 +207,7 @@ public: if (m_rep) m_rep->AddRef(); } - + ~wxArchiveIterator() { if (m_rep) m_rep->UnRef(); @@ -284,14 +241,12 @@ public: return it; } - friend bool operator ==(const wxArchiveIterator& i, - const wxArchiveIterator& j) { - return i.m_rep == j.m_rep; + bool operator ==(const wxArchiveIterator& j) const { + return m_rep == j.m_rep; } - friend bool operator !=(const wxArchiveIterator& i, - const wxArchiveIterator& j) { - return !(i == j); + bool operator !=(const wxArchiveIterator& j) const { + return !(*this == j); } private: @@ -300,13 +255,13 @@ private: typename Arc::entry_type* m_entry; T m_value; int m_ref; - + public: Rep(Arc& arc, typename Arc::entry_type* entry) : m_arc(arc), m_entry(entry), m_value(), m_ref(1) { } ~Rep() { delete m_entry; } - + void AddRef() { m_ref++; } @@ -323,7 +278,7 @@ private: return NULL; } if (m_ref > 1) { - m_ref--; + m_ref--; return new Rep(m_arc, entry); } delete m_entry; @@ -348,6 +303,81 @@ typedef wxArchiveIterator