]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/archive.tex
commented and documented wxXRC_NO_RELOADING flag
[wxWidgets.git] / docs / latex / wx / archive.tex
... / ...
CommitLineData
1%
2% automatically generated by HelpGen $Revision$ from
3% wx/archive.h at 16/Sep/04 12:19:29
4%
5
6\section{\class{wxArchiveClassFactory}}\label{wxarchiveclassfactory}
7
8An abstract base class which serves as a common interface to
9archive class factories such as \helpref{wxZipClassFactory}{wxzipclassfactory}.
10
11For each supported archive type (such as zip) there is a class factory
12derived from wxArchiveClassFactory, which allows archive objects to be
13created in a generic way, without knowing the particular type of archive
14being used.
15
16\wxheading{Derived from}
17
18\helpref{wxObject}{wxobject}
19
20\wxheading{Include files}
21
22<wx/archive.h>
23
24\wxheading{See also}
25
26\helpref{Archive formats such as zip}{wxarc}\\
27\helpref{Generic archive programming}{wxarcgeneric}\\
28\helpref{wxArchiveEntry}{wxarchiveentry}\\
29\helpref{wxArchiveInputStream}{wxarchiveinputstream}\\
30\helpref{wxArchiveOutputStream}{wxarchiveoutputstream}
31
32\latexignore{\rtfignore{\wxheading{Members}}}
33
34
35\membersection{wxArchiveClassFactory::Get/SetConv}\label{wxarchiveclassfactoryconv}
36
37\constfunc{wxMBConv\&}{GetConv}{\void}
38
39\func{void}{SetConv}{\param{wxMBConv\& }{conv}}
40
41The \helpref{wxMBConv}{wxmbconv} object that the created streams
42will use when translating meta-data. The initial default, set by the
43constructor, is wxConvLocal.
44
45
46\membersection{wxArchiveClassFactory::GetInternalName}\label{wxarchiveclassfactorygetinternalname}
47
48\constfunc{wxString}{GetInternalName}{\param{const wxString\& }{name}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
49
50Calls the static GetInternalName() function for the archive entry type,
51for example
52 \helpref{wxZipEntry::GetInternalName()}{wxzipentrygetinternalname}.
53
54
55\membersection{wxArchiveClassFactory::NewEntry}\label{wxarchiveclassfactorynewentry}
56
57\constfunc{wxArchiveEntry*}{NewEntry}{\void}
58
59Create a new \helpref{wxArchiveEntry}{wxarchiveentry} object of the
60appropriate type.
61
62
63\membersection{wxArchiveClassFactory::NewStream}\label{wxarchiveclassfactorynewstream}
64
65\constfunc{wxArchiveInputStream*}{NewStream}{\param{wxInputStream\& }{stream}}
66
67\constfunc{wxArchiveOutputStream*}{NewStream}{\param{wxOutputStream\& }{stream}}
68
69Create a new \helpref{wxArchiveInputStream}{wxarchiveinputstream}
70or \helpref{wxArchiveOutputStream}{wxarchiveoutputstream} of the
71appropriate type.
72
73
74%
75% automatically generated by HelpGen $Revision$ from
76% wx/archive.h at 16/Sep/04 12:19:29
77%
78
79\section{\class{wxArchiveEntry}}\label{wxarchiveentry}
80
81An abstract base class which serves as a common interface to
82archive entry classes such as \helpref{wxZipEntry}{wxzipentry}.
83These hold the meta-data (filename, timestamp, etc.), for entries
84in archive files such as zips and tars.
85
86\wxheading{Derived from}
87
88\helpref{wxObject}{wxobject}
89
90\wxheading{Include files}
91
92<wx/archive.h>
93
94\wxheading{See also}
95
96\helpref{Archive formats such as zip}{wxarc}\\
97\helpref{Generic archive programming}{wxarcgeneric}\\
98\helpref{wxArchiveInputStream}{wxarchiveinputstream}\\
99\helpref{wxArchiveOutputStream}{wxarchiveoutputstream}\\
100\helpref{wxArchiveNotifier}{wxarchivenotifier}
101
102\wxheading{Non-seekable streams}
103
104This information applies only when reading archives from non-seekable
105streams. When the stream is
106seekable \helpref{GetNextEntry()}{wxarchiveinputstreamgetnextentry}
107returns a fully populated \helpref{wxArchiveEntry}{wxarchiveentry}.
108See '\helpref{Archives on non-seekable streams}{wxarcnoseek}' for
109more information.
110
111For generic programming, when the worst case must be assumed, you can
112rely on all the fields of wxArchiveEntry being fully populated when
113GetNextEntry() returns, with the the following exceptions:
114
115\begin{twocollist}\twocolwidtha{3cm}
116\twocolitem{\helpref{GetSize()}{wxarchiveentrysize}}{Guaranteed to be
117available after the entry has been read to \helpref{Eof()}{wxinputstreameof},
118or \helpref{CloseEntry()}{wxarchiveinputstreamcloseentry} has been called}
119\twocolitem{\helpref{IsReadOnly()}{wxarchiveentryisreadonly}}{Guaranteed to
120be available after the end of the archive has been reached, i.e. after
121GetNextEntry() returns NULL and Eof() is true}
122\end{twocollist}
123
124
125\latexignore{\rtfignore{\wxheading{Members}}}
126
127
128\membersection{wxArchiveEntry::Clone}\label{wxarchiveentryclone}
129
130\constfunc{wxArchiveEntry*}{Clone}{\void}
131
132Returns a copy of this entry object.
133
134
135\membersection{wxArchiveEntry::Get/SetDateTime}\label{wxarchiveentrydatetime}
136
137\constfunc{wxDateTime}{GetDateTime}{\void}
138
139\func{void}{SetDateTime}{\param{const wxDateTime\& }{dt}}
140
141The entry's timestamp.
142
143
144\membersection{wxArchiveEntry::GetInternalFormat}\label{wxarchiveentrygetinternalformat}
145
146\constfunc{wxPathFormat}{GetInternalFormat}{\void}
147
148Returns the path format used internally within the archive to store
149filenames.
150
151
152\membersection{wxArchiveEntry::GetInternalName}\label{wxarchiveentrygetinternalname}
153
154\constfunc{wxString}{GetInternalName}{\void}
155
156Returns the entry's filename in the internal format used within the
157archive. The name can include directory components, i.e. it can be a
158full path.
159
160The names of directory entries are returned without any trailing path
161separator. This gives a canonical name that can be used in comparisons.
162
163\wxheading{See also}
164
165\helpref{Looking up an archive entry by name}{wxarcbyname}
166
167
168\membersection{wxArchiveEntry::Get/SetName}\label{wxarchiveentryname}
169
170\constfunc{wxString}{GetName}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
171
172\func{void}{SetName}{\param{const wxString\& }{name}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
173
174The entry's name, by default in the native format. The name can include
175directory components, i.e. it can be a full path.
176
177If this is a directory entry, (i.e. if \helpref{IsDir()}{wxarchiveentryisdir}
178is true) then GetName() returns the name with a trailing path separator.
179
180Similarly, setting a name with a trailing path separator sets IsDir().
181
182
183\membersection{wxArchiveEntry::GetOffset}\label{wxarchiveentrygetoffset}
184
185\constfunc{off\_t}{GetOffset}{\void}
186
187Returns a numeric value unique to the entry within the archive.
188
189
190\membersection{wxArchiveEntry::Get/SetSize}\label{wxarchiveentrysize}
191
192\constfunc{off\_t}{GetSize}{\void}
193
194\func{void}{SetSize}{\param{off\_t }{size}}
195
196The size of the entry's data in bytes.
197
198
199\membersection{wxArchiveEntry::IsDir/SetIsDir}\label{wxarchiveentryisdir}
200
201\constfunc{bool}{IsDir}{\void}
202
203\func{void}{SetIsDir}{\param{bool }{isDir = true}}
204
205True if this is a directory entry.
206
207Directory entries are entries with no data, which are used to store
208the meta-data of directories. They also make it possible for completely
209empty directories to be stored.
210
211The names of entries within an archive can be complete paths, and
212unarchivers typically create whatever directories are necessary as they
213restore files, even if the archive contains no explicit directory entries.
214
215
216\membersection{wxArchiveEntry::IsReadOnly/SetIsReadOnly}\label{wxarchiveentryisreadonly}
217
218\constfunc{bool}{IsReadOnly}{\void}
219
220\func{void}{SetIsReadOnly}{\param{bool }{isReadOnly = true}}
221
222True if the entry is a read-only file.
223
224
225\membersection{wxArchiveEntry::Set/UnsetNotifier}\label{wxarchiveentrynotifier}
226
227\func{void}{SetNotifier}{\param{wxArchiveNotifier\& }{notifier}}
228
229\func{void}{UnsetNotifier}{\void}
230
231Sets the \helpref{notifier}{wxarchivenotifier} for this entry.
232Whenever the \helpref{wxArchiveInputStream}{wxarchiveinputstream} updates
233this entry, it will then invoke the associated
234notifier's \helpref{OnEntryUpdated}{wxarchivenotifieronentryupdated}
235method.
236
237Setting a notifier is not usually necessary. It is used to handle
238certain cases when modifying an archive in a pipeline (i.e. between
239non-seekable streams).
240
241\wxheading{See also}
242
243\helpref{Archives on non-seekable streams}{wxarcnoseek}\\
244\helpref{wxArchiveNotifier}{wxarchivenotifier}
245
246
247%
248% automatically generated by HelpGen $Revision$ from
249% wx/archive.h at 16/Sep/04 12:19:29
250%
251
252\section{\class{wxArchiveInputStream}}\label{wxarchiveinputstream}
253
254An abstract base class which serves as a common interface to
255archive input streams such as \helpref{wxZipInputStream}{wxzipinputstream}.
256
257\helpref{GetNextEntry()}{wxarchiveinputstreamgetnextentry} returns an
258 \helpref{wxArchiveEntry}{wxarchiveentry} object containing the meta-data
259for the next entry in the archive (and gives away ownership). Reading from
260the wxArchiveInputStream then returns the entry's data. Eof() becomes true
261after an attempt has been made to read past the end of the entry's data.
262When there are no more entries, GetNextEntry() returns NULL and sets Eof().
263
264\wxheading{Derived from}
265
266\helpref{wxFilterInputStream}{wxfilterinputstream}
267
268\wxheading{Include files}
269
270<wx/archive.h>
271
272\wxheading{Data structures}
273\begin{verbatim}
274typedef wxArchiveEntry entry_type
275\end{verbatim}
276
277\wxheading{See also}
278
279\helpref{Archive formats such as zip}{wxarc}\\
280\helpref{wxArchiveEntry}{wxarchiveentry}\\
281\helpref{wxArchiveOutputStream}{wxarchiveoutputstream}
282
283\latexignore{\rtfignore{\wxheading{Members}}}
284
285
286\membersection{wxArchiveInputStream::CloseEntry}\label{wxarchiveinputstreamcloseentry}
287
288\func{bool}{CloseEntry}{\void}
289
290Closes the current entry. On a non-seekable stream reads to the end of
291the current entry first.
292
293
294\membersection{wxArchiveInputStream::GetNextEntry}\label{wxarchiveinputstreamgetnextentry}
295
296\func{wxArchiveEntry*}{GetNextEntry}{\void}
297
298Closes the current entry if one is open, then reads the meta-data for
299the next entry and returns it in a \helpref{wxArchiveEntry}{wxarchiveentry}
300object, giving away ownership. Reading this wxArchiveInputStream then
301returns the entry's data.
302
303
304\membersection{wxArchiveInputStream::OpenEntry}\label{wxarchiveinputstreamopenentry}
305
306\func{bool}{OpenEntry}{\param{wxArchiveEntry\& }{entry}}
307
308Closes the current entry if one is open, then opens the entry specified
309by the \helpref{wxArchiveEntry}{wxarchiveentry} object.
310
311{\it entry} must be from the same archive file that this
312wxArchiveInputStream is reading, and it must be reading it from a
313seekable stream.
314
315\wxheading{See also}
316
317\helpref{Looking up an archive entry by name}{wxarcbyname}
318
319
320%
321% automatically generated by HelpGen $Revision$ from
322% wx/archive.h at 16/Sep/04 12:19:29
323%
324
325\section{\class{wxArchiveIterator}}\label{wxarchiveiterator}
326
327An input iterator template class that can be used to transfer an archive's
328catalogue to a container. It is only available if wxUSE\_STL is set to 1
329in setup.h, and the uses for it outlined below require a compiler which
330supports member templates.
331
332\begin{verbatim}
333template <class Arc, class T = typename Arc::entry_type*>
334class wxArchiveIterator
335{
336 // this constructor creates an 'end of sequence' object
337 wxArchiveIterator();
338
339 // template parameter 'Arc' should be the type of an archive input stream
340 wxArchiveIterator(Arc& arc) {
341
342 /* ... */
343};
344
345\end{verbatim}
346
347The first template parameter should be the type of archive input stream
348(e.g. \helpref{wxArchiveInputStream}{wxarchiveinputstream}) and the
349second can either be a pointer to an entry
350(e.g. \helpref{wxArchiveEntry}{wxarchiveentry}*), or a string/pointer pair
351(e.g. std::pair<wxString, wxArchiveEntry*>).
352
353The {\tt <wx/archive.h>} header defines the following typedefs:
354
355\begin{verbatim}
356 typedef wxArchiveIterator<wxArchiveInputStream> wxArchiveIter;
357
358 typedef wxArchiveIterator<wxArchiveInputStream,
359 std::pair<wxString, wxArchiveEntry*> > wxArchivePairIter;
360
361\end{verbatim}
362
363The header for any implementation of this interface should define similar
364typedefs for its types, for example in {\tt <wx/zipstrm.h>} there is:
365
366\begin{verbatim}
367 typedef wxArchiveIterator<wxZipInputStream> wxZipIter;
368
369 typedef wxArchiveIterator<wxZipInputStream,
370 std::pair<wxString, wxZipEntry*> > wxZipPairIter;
371
372\end{verbatim}
373
374Transferring the catalogue of an archive {\it arc} to a vector {\it cat},
375can then be done something like this:
376
377\begin{verbatim}
378 std::vector<wxArchiveEntry*> cat((wxArchiveIter)arc, wxArchiveIter());
379
380\end{verbatim}
381
382When the iterator is dereferenced, it gives away ownership of an entry
383object. So in the above example, when you have finished with {\it cat}
384you must delete the pointers it contains.
385
386If you have smart pointers with normal copy semantics (i.e. not auto\_ptr
387or \helpref{wxScopedPtr}{wxscopedptr}), then you can create an iterator
388which uses them instead. For example, with a smart pointer class for
389zip entries {\it ZipEntryPtr}:
390
391\begin{verbatim}
392 typedef std::vector<ZipEntryPtr> ZipCatalog;
393 typedef wxArchiveIterator<wxZipInputStream, ZipEntryPtr> ZipIter;
394 ZipCatalog cat((ZipIter)zip, ZipIter());
395
396\end{verbatim}
397
398Iterators that return std::pair objects can be used to
399populate a std::multimap, to allow entries to be looked
400up by name. The string is initialised using the wxArchiveEntry object's
401 \helpref{GetInternalName()}{wxarchiveentrygetinternalname} function.
402
403\begin{verbatim}
404 typedef std::multimap<wxString, wxZipEntry*> ZipCatalog;
405 ZipCatalog cat((wxZipPairIter)zip, wxZipPairIter());
406
407\end{verbatim}
408
409Note that this iterator also gives away ownership of an entry
410object each time it is dereferenced. So in the above example, when
411you have finished with {\it cat} you must delete the pointers it contains.
412
413Or if you have them, a pair containing a smart pointer can be used
414(again {\it ZipEntryPtr}), no worries about ownership:
415
416\begin{verbatim}
417 typedef std::multimap<wxString, ZipEntryPtr> ZipCatalog;
418 typedef wxArchiveIterator<wxZipInputStream,
419 std::pair<wxString, ZipEntryPtr> > ZipPairIter;
420 ZipCatalog cat((ZipPairIter)zip, ZipPairIter());
421
422\end{verbatim}
423
424\wxheading{Derived from}
425
426No base class
427
428\wxheading{Include files}
429
430<wx/archive.h>
431
432\wxheading{See also}
433
434\helpref{wxArchiveEntry}{wxarchiveentry}\\
435\helpref{wxArchiveInputStream}{wxarchiveinputstream}\\
436\helpref{wxArchiveOutputStream}{wxarchiveoutputstream}
437
438\wxheading{Data structures}
439\begin{verbatim}
440typedef std::input_iterator_tag iterator_category
441typedef T value_type
442typedef ptrdiff_t difference_type
443typedef T* pointer
444typedef T& reference
445\end{verbatim}
446
447\latexignore{\rtfignore{\wxheading{Members}}}
448
449
450\membersection{wxArchiveIterator::wxArchiveIterator}\label{wxarchiveiteratorwxarchiveiterator}
451
452\func{}{wxArchiveIterator}{\void}
453
454Construct an 'end of sequence' instance.
455
456\func{}{wxArchiveIterator}{\param{Arc\& }{arc}}
457
458Construct iterator that returns all the entries in the archive input
459stream {\it arc}.
460
461
462\membersection{wxArchiveIterator::operator*}\label{wxarchiveiteratoroperatorstar}
463
464\constfunc{const T\&}{operator*}{\void}
465
466Returns an entry object from the archive input stream, giving away
467ownership.
468
469
470\membersection{wxArchiveIterator::operator++}\label{wxarchiveiteratoroperatorincrement}
471
472\func{wxArchiveIterator\&}{operator++}{\void}
473
474\func{wxArchiveIterator\&}{operator++}{\param{int}{}}
475
476Position the input iterator at the next entry in the archive input stream.
477
478
479%
480% automatically generated by HelpGen $Revision$ from
481% wx/archive.h at 16/Sep/04 12:19:29
482%
483
484\section{\class{wxArchiveNotifier}}\label{wxarchivenotifier}
485
486If you need to know when a
487 \helpref{wxArchiveInputStream}{wxarchiveinputstream} updates a
488 \helpref{wxArchiveEntry}{wxarchiveentry} object, you can create
489a notifier by deriving from this abstract base class, overriding
490 \helpref{OnEntryUpdated()}{wxarchivenotifieronentryupdated}. An instance
491of your notifier class can then be assigned to the wxArchiveEntry object
492using \helpref{wxArchiveEntry::SetNotifier()}{wxarchiveentrynotifier}.
493Your OnEntryUpdated() method will then be invoked whenever the input
494stream updates the entry.
495
496Setting a notifier is not usually necessary. It is used to handle
497certain cases when modifying an archive in a pipeline (i.e. between
498non-seekable streams).
499See \helpref{Archives on non-seekable streams}{wxarcnoseek}.
500
501\wxheading{Derived from}
502
503No base class
504
505\wxheading{Include files}
506
507<wx/archive.h>
508
509\wxheading{See also}
510
511\helpref{Archives on non-seekable streams}{wxarcnoseek}\\
512\helpref{wxArchiveEntry}{wxarchiveentry}\\
513\helpref{wxArchiveInputStream}{wxarchiveinputstream}\\
514\helpref{wxArchiveOutputStream}{wxarchiveoutputstream}
515
516\latexignore{\rtfignore{\wxheading{Members}}}
517
518
519\membersection{wxArchiveNotifier::OnEntryUpdated}\label{wxarchivenotifieronentryupdated}
520
521\func{void}{OnEntryUpdated}{\param{class wxArchiveEntry\& }{entry}}
522
523This method must be overridden in your derived class.
524
525
526%
527% automatically generated by HelpGen $Revision$ from
528% wx/archive.h at 16/Sep/04 12:19:29
529%
530
531\section{\class{wxArchiveOutputStream}}\label{wxarchiveoutputstream}
532
533An abstract base class which serves as a common interface to
534archive output streams such as \helpref{wxZipOutputStream}{wxzipoutputstream}.
535
536\helpref{PutNextEntry()}{wxarchiveoutputstreamputnextentry} is used
537to create a new entry in the output archive, then the entry's data is
538written to the wxArchiveOutputStream. Another call to PutNextEntry()
539closes the current entry and begins the next.
540
541\wxheading{Derived from}
542
543\helpref{wxFilterOutputStream}{wxfilteroutputstream}
544
545\wxheading{Include files}
546
547<wx/archive.h>
548
549\wxheading{See also}
550
551\helpref{Archive formats such as zip}{wxarc}\\
552\helpref{wxArchiveEntry}{wxarchiveentry}\\
553\helpref{wxArchiveInputStream}{wxarchiveinputstream}
554
555\latexignore{\rtfignore{\wxheading{Members}}}
556
557
558\membersection{wxArchiveOutputStream::\destruct{wxArchiveOutputStream}}\label{wxarchiveoutputstreamdtor}
559
560\func{}{\destruct{wxArchiveOutputStream}}{\void}
561
562Calls \helpref{Close()}{wxarchiveoutputstreamclose} if it has not already
563been called.
564
565
566\membersection{wxArchiveOutputStream::Close}\label{wxarchiveoutputstreamclose}
567
568\func{bool}{Close}{\void}
569
570Closes the archive, returning true if it was successfully written.
571Called by the destructor if not called explicitly.
572
573
574\membersection{wxArchiveOutputStream::CloseEntry}\label{wxarchiveoutputstreamcloseentry}
575
576\func{bool}{CloseEntry}{\void}
577
578Close the current entry. It is called implicitly whenever another new
579entry is created with \helpref{CopyEntry()}{wxarchiveoutputstreamcopyentry}
580or \helpref{PutNextEntry()}{wxarchiveoutputstreamputnextentry}, or
581when the archive is closed.
582
583
584\membersection{wxArchiveOutputStream::CopyArchiveMetaData}\label{wxarchiveoutputstreamcopyarchivemetadata}
585
586\func{bool}{CopyArchiveMetaData}{\param{wxArchiveInputStream\& }{stream}}
587
588Some archive formats have additional meta-data that applies to the archive
589as a whole. For example in the case of zip there is a comment, which
590is stored at the end of the zip file. CopyArchiveMetaData() can be used
591to transfer such information when writing a modified copy of an archive.
592
593Since the position of the meta-data can vary between the various archive
594formats, it is best to call CopyArchiveMetaData() before transferring
595the entries. The \helpref{wxArchiveOutputStream}{wxarchiveoutputstream}
596will then hold on to the meta-data and write it at the correct point in
597the output file.
598
599When the input archive is being read from a non-seekable stream, the
600meta-data may not be available when CopyArchiveMetaData() is called,
601in which case the two streams set up a link and transfer the data
602when it becomes available.
603
604
605\membersection{wxArchiveOutputStream::CopyEntry}\label{wxarchiveoutputstreamcopyentry}
606
607\func{bool}{CopyEntry}{\param{wxArchiveEntry* }{entry}, \param{wxArchiveInputStream\& }{stream}}
608
609Takes ownership of {\it entry} and uses it to create a new entry in the
610archive. {\it entry} is then opened in the input stream {\it stream}
611and its contents copied to this stream.
612
613For archive types which compress entry data, CopyEntry() is likely to be
614much more efficient than transferring the data using Read() and Write()
615since it will copy them without decompressing and recompressing them.
616
617{\it entry} must be from the same archive file that {\it stream} is
618accessing. For non-seekable streams, {\it entry} must also be the last
619thing read from {\it stream}.
620
621
622\membersection{wxArchiveOutputStream::PutNextDirEntry}\label{wxarchiveoutputstreamputnextdirentry}
623
624\func{bool}{PutNextDirEntry}{\param{const wxString\& }{name}, \param{const wxDateTime\& }{dt = wxDateTime::Now()}}
625
626Create a new directory entry
627(see \helpref{wxArchiveEntry::IsDir()}{wxarchiveentryisdir})
628with the given name and timestamp.
629
630\helpref{PutNextEntry()}{wxarchiveoutputstreamputnextentry} can
631also be used to create directory entries, by supplying a name with
632a trailing path separator.
633
634
635\membersection{wxArchiveOutputStream::PutNextEntry}\label{wxarchiveoutputstreamputnextentry}
636
637\func{bool}{PutNextEntry}{\param{wxArchiveEntry* }{entry}}
638
639Takes ownership of {\it entry} and uses it to create a new entry in
640the archive. The entry's data can then be written by writing to this
641wxArchiveOutputStream.
642
643\func{bool}{PutNextEntry}{\param{const wxString\& }{name}, \param{const wxDateTime\& }{dt = wxDateTime::Now()}, \param{off\_t }{size = wxInvalidOffset}}
644
645Create a new entry with the given name, timestamp and size. The entry's
646data can then be written by writing to this wxArchiveOutputStream.
647
648