📄 archive.tex
字号:
\helpref{wxArchiveEntry}{wxarchiveentry} object containing the meta-datafor the next entry in the archive (and gives away ownership). Reading fromthe wxArchiveInputStream then returns the entry's data. Eof() becomes trueafter an attempt has been made to read past the end of the entry's data.When there are no more entries, GetNextEntry() returns NULL and sets Eof().\wxheading{Derived from}\helpref{wxFilterInputStream}{wxfilterinputstream}\wxheading{Include files}<wx/archive.h>\wxheading{Data structures}\begin{verbatim}typedef wxArchiveEntry entry_type\end{verbatim}\wxheading{See also}\helpref{Archive formats such as zip}{wxarc}\\\helpref{wxArchiveEntry}{wxarchiveentry}\\\helpref{wxArchiveOutputStream}{wxarchiveoutputstream}\latexignore{\rtfignore{\wxheading{Members}}}\membersection{wxArchiveInputStream::CloseEntry}\label{wxarchiveinputstreamcloseentry}\func{bool}{CloseEntry}{\void}Closes the current entry. On a non-seekable stream reads to the end ofthe current entry first.\membersection{wxArchiveInputStream::GetNextEntry}\label{wxarchiveinputstreamgetnextentry}\func{wxArchiveEntry*}{GetNextEntry}{\void}Closes the current entry if one is open, then reads the meta-data forthe next entry and returns it in a \helpref{wxArchiveEntry}{wxarchiveentry}object, giving away ownership. Reading this wxArchiveInputStream thenreturns the entry's data.\membersection{wxArchiveInputStream::OpenEntry}\label{wxarchiveinputstreamopenentry}\func{bool}{OpenEntry}{\param{wxArchiveEntry\& }{entry}}Closes the current entry if one is open, then opens the entry specifiedby the \helpref{wxArchiveEntry}{wxarchiveentry} object.{\it entry} must be from the same archive file that thiswxArchiveInputStream is reading, and it must be reading it from aseekable stream.\wxheading{See also}\helpref{Looking up an archive entry by name}{wxarcbyname}%% automatically generated by HelpGen $Revision: 1.4 $ from% wx/archive.h at 16/Sep/04 12:19:29%\section{\class{wxArchiveIterator}}\label{wxarchiveiterator}An input iterator template class that can be used to transfer an archive'scatalogue to a container. It is only available if wxUSE\_STL is set to 1in setup.h, and the uses for it outlined below require a compiler whichsupports member templates.\begin{verbatim}template <class Arc, class T = typename Arc::entry_type*>class wxArchiveIterator{ // this constructor creates an 'end of sequence' object wxArchiveIterator(); // template parameter 'Arc' should be the type of an archive input stream wxArchiveIterator(Arc& arc) { /* ... */};\end{verbatim}The first template parameter should be the type of archive input stream(e.g. \helpref{wxArchiveInputStream}{wxarchiveinputstream}) and thesecond can either be a pointer to an entry(e.g. \helpref{wxArchiveEntry}{wxarchiveentry}*), or a string/pointer pair(e.g. std::pair<wxString, wxArchiveEntry*>).The {\tt <wx/archive.h>} header defines the following typedefs:\begin{verbatim} typedef wxArchiveIterator<wxArchiveInputStream> wxArchiveIter; typedef wxArchiveIterator<wxArchiveInputStream, std::pair<wxString, wxArchiveEntry*> > wxArchivePairIter;\end{verbatim}The header for any implementation of this interface should define similartypedefs for its types, for example in {\tt <wx/zipstrm.h>} there is:\begin{verbatim} typedef wxArchiveIterator<wxZipInputStream> wxZipIter; typedef wxArchiveIterator<wxZipInputStream, std::pair<wxString, wxZipEntry*> > wxZipPairIter;\end{verbatim}Transferring the catalogue of an archive {\it arc} to a vector {\it cat},can then be done something like this:\begin{verbatim} std::vector<wxArchiveEntry*> cat((wxArchiveIter)arc, wxArchiveIter());\end{verbatim}When the iterator is dereferenced, it gives away ownership of an entryobject. So in the above example, when you have finished with {\it cat}you must delete the pointers it contains.If you have smart pointers with normal copy semantics (i.e. not auto\_ptror \helpref{wxScopedPtr}{wxscopedptr}), then you can create an iteratorwhich uses them instead. For example, with a smart pointer class forzip entries {\it ZipEntryPtr}:\begin{verbatim} typedef std::vector<ZipEntryPtr> ZipCatalog; typedef wxArchiveIterator<wxZipInputStream, ZipEntryPtr> ZipIter; ZipCatalog cat((ZipIter)zip, ZipIter());\end{verbatim}Iterators that return std::pair objects can be used topopulate a std::multimap, to allow entries to be lookedup by name. The string is initialised using the wxArchiveEntry object's \helpref{GetInternalName()}{wxarchiveentrygetinternalname} function.\begin{verbatim} typedef std::multimap<wxString, wxZipEntry*> ZipCatalog; ZipCatalog cat((wxZipPairIter)zip, wxZipPairIter());\end{verbatim} Note that this iterator also gives away ownership of an entry object each time it is dereferenced. So in the above example, whenyou have finished with {\it cat} you must delete the pointers it contains.Or if you have them, a pair containing a smart pointer can be used(again {\it ZipEntryPtr}), no worries about ownership:\begin{verbatim} typedef std::multimap<wxString, ZipEntryPtr> ZipCatalog; typedef wxArchiveIterator<wxZipInputStream, std::pair<wxString, ZipEntryPtr> > ZipPairIter; ZipCatalog cat((ZipPairIter)zip, ZipPairIter());\end{verbatim}\wxheading{Derived from}No base class\wxheading{Include files}<wx/archive.h>\wxheading{See also}\helpref{wxArchiveEntry}{wxarchiveentry}\\\helpref{wxArchiveInputStream}{wxarchiveinputstream}\\\helpref{wxArchiveOutputStream}{wxarchiveoutputstream}\wxheading{Data structures}\begin{verbatim}typedef std::input_iterator_tag iterator_categorytypedef T value_typetypedef ptrdiff_t difference_typetypedef T* pointertypedef T& reference\end{verbatim}\latexignore{\rtfignore{\wxheading{Members}}}\membersection{wxArchiveIterator::wxArchiveIterator}\label{wxarchiveiteratorwxarchiveiterator}\func{}{wxArchiveIterator}{\void}Construct an 'end of sequence' instance.\func{}{wxArchiveIterator}{\param{Arc\& }{arc}}Construct iterator that returns all the entries in the archive inputstream {\it arc}.\membersection{wxArchiveIterator::operator*}\label{wxarchiveiteratoroperatorstar}\constfunc{const T\&}{operator*}{\void}Returns an entry object from the archive input stream, giving awayownership.\membersection{wxArchiveIterator::operator++}\label{wxarchiveiteratoroperatorincrement}\func{wxArchiveIterator\&}{operator++}{\void}\func{wxArchiveIterator\&}{operator++}{\param{int}{}}Position the input iterator at the next entry in the archive input stream.%% automatically generated by HelpGen $Revision: 1.4 $ from% wx/archive.h at 16/Sep/04 12:19:29%\section{\class{wxArchiveNotifier}}\label{wxarchivenotifier}If you need to know when a \helpref{wxArchiveInputStream}{wxarchiveinputstream} updates a \helpref{wxArchiveEntry}{wxarchiveentry} object, you can createa notifier by deriving from this abstract base class, overriding \helpref{OnEntryUpdated()}{wxarchivenotifieronentryupdated}. An instanceof your notifier class can then be assigned to the wxArchiveEntry objectusing \helpref{wxArchiveEntry::SetNotifier()}{wxarchiveentrynotifier}.Your OnEntryUpdated() method will then be invoked whenever the inputstream updates the entry.Setting a notifier is not usually necessary. It is used to handlecertain cases when modifying an archive in a pipeline (i.e. betweennon-seekable streams).See \helpref{Archives on non-seekable streams}{wxarcnoseek}.\wxheading{Derived from}No base class\wxheading{Include files}<wx/archive.h>\wxheading{See also}\helpref{Archives on non-seekable streams}{wxarcnoseek}\\\helpref{wxArchiveEntry}{wxarchiveentry}\\\helpref{wxArchiveInputStream}{wxarchiveinputstream}\\\helpref{wxArchiveOutputStream}{wxarchiveoutputstream}\latexignore{\rtfignore{\wxheading{Members}}}\membersection{wxArchiveNotifier::OnEntryUpdated}\label{wxarchivenotifieronentryupdated}\func{void}{OnEntryUpdated}{\param{class wxArchiveEntry\& }{entry}}This method must be overridden in your derived class.%% automatically generated by HelpGen $Revision: 1.4 $ from% wx/archive.h at 16/Sep/04 12:19:29%\section{\class{wxArchiveOutputStream}}\label{wxarchiveoutputstream}An abstract base class which serves as a common interface toarchive output streams such as \helpref{wxZipOutputStream}{wxzipoutputstream}.\helpref{PutNextEntry()}{wxarchiveoutputstreamputnextentry} is usedto create a new entry in the output archive, then the entry's data iswritten to the wxArchiveOutputStream. Another call to PutNextEntry()closes the current entry and begins the next.\wxheading{Derived from}\helpref{wxFilterOutputStream}{wxfilteroutputstream}\wxheading{Include files}<wx/archive.h>\wxheading{See also}\helpref{Archive formats such as zip}{wxarc}\\\helpref{wxArchiveEntry}{wxarchiveentry}\\\helpref{wxArchiveInputStream}{wxarchiveinputstream}\latexignore{\rtfignore{\wxheading{Members}}}\membersection{wxArchiveOutputStream::\destruct{wxArchiveOutputStream}}\label{wxarchiveoutputstreamdtor}\func{}{\destruct{wxArchiveOutputStream}}{\void}Calls \helpref{Close()}{wxarchiveoutputstreamclose} if it has not alreadybeen called.\membersection{wxArchiveOutputStream::Close}\label{wxarchiveoutputstreamclose}\func{bool}{Close}{\void}Closes the archive, returning true if it was successfully written.Called by the destructor if not called explicitly.\membersection{wxArchiveOutputStream::CloseEntry}\label{wxarchiveoutputstreamcloseentry}\func{bool}{CloseEntry}{\void}Close the current entry. It is called implicitly whenever another newentry is created with \helpref{CopyEntry()}{wxarchiveoutputstreamcopyentry}or \helpref{PutNextEntry()}{wxarchiveoutputstreamputnextentry}, orwhen the archive is closed.\membersection{wxArchiveOutputStream::CopyArchiveMetaData}\label{wxarchiveoutputstreamcopyarchivemetadata}\func{bool}{CopyArchiveMetaData}{\param{wxArchiveInputStream\& }{stream}}Some archive formats have additional meta-data that applies to the archiveas a whole. For example in the case of zip there is a comment, whichis stored at the end of the zip file. CopyArchiveMetaData() can be usedto transfer such information when writing a modified copy of an archive.Since the position of the meta-data can vary between the various archiveformats, it is best to call CopyArchiveMetaData() before transferringthe entries. The \helpref{wxArchiveOutputStream}{wxarchiveoutputstream}will then hold on to the meta-data and write it at the correct point inthe output file.When the input archive is being read from a non-seekable stream, themeta-data may not be available when CopyArchiveMetaData() is called,in which case the two streams set up a link and transfer the datawhen it becomes available.\membersection{wxArchiveOutputStream::CopyEntry}\label{wxarchiveoutputstreamcopyentry}\func{bool}{CopyEntry}{\param{wxArchiveEntry* }{entry}, \param{wxArchiveInputStream\& }{stream}}Takes ownership of {\it entry} and uses it to create a new entry in thearchive. {\it entry} is then opened in the input stream {\it stream}and its contents copied to this stream.For archive types which compress entry data, CopyEntry() is likely to bemuch more efficient than transferring the data using Read() and Write()since it will copy them without decompressing and recompressing them.{\it entry} must be from the same archive file that {\it stream} isaccessing. For non-seekable streams, {\it entry} must also be the lastthing read from {\it stream}.\membersection{wxArchiveOutputStream::PutNextDirEntry}\label{wxarchiveoutputstreamputnextdirentry}\func{bool}{PutNextDirEntry}{\param{const wxString\& }{name}, \param{const wxDateTime\& }{dt = wxDateTime::Now()}}Create a new directory entry(see \helpref{wxArchiveEntry::IsDir()}{wxarchiveentryisdir})with the given name and timestamp.\helpref{PutNextEntry()}{wxarchiveoutputstreamputnextentry} canalso be used to create directory entries, by supplying a name witha trailing path separator.\membersection{wxArchiveOutputStream::PutNextEntry}\label{wxarchiveoutputstreamputnextentry}\func{bool}{PutNextEntry}{\param{wxArchiveEntry* }{entry}}Takes ownership of {\it entry} and uses it to create a new entry inthe archive. The entry's data can then be written by writing to thiswxArchiveOutputStream.\func{bool}{PutNextEntry}{\param{const wxString\& }{name}, \param{const wxDateTime\& }{dt = wxDateTime::Now()}, \param{off\_t }{size = wxInvalidOffset}}Create a new entry with the given name, timestamp and size. The entry'sdata can then be written by writing to this wxArchiveOutputStream.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -