]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/archive.h
Applied #15226 with modifications: wxRichTextCtrl: Implement setting properties with...
[wxWidgets.git] / interface / wx / archive.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: archive.h
4cbfec15 3// Purpose: interface of wxArchive* classes
23324ae1 4// Author: wxWidgets team
526954c5 5// Licence: wxWindows licence
23324ae1
FM
6/////////////////////////////////////////////////////////////////////////////
7
8/**
9 @class wxArchiveInputStream
7c913512 10
d2aa927a 11 This is an abstract base class which serves as a common interface to
23324ae1 12 archive input streams such as wxZipInputStream.
7c913512 13
4cbfec15
FM
14 wxArchiveInputStream::GetNextEntry returns an wxArchiveEntry object containing
15 the meta-data for the next entry in the archive (and gives away ownership).
16
17 Reading from the wxArchiveInputStream then returns the entry's data. Eof()
18 becomes @true after an attempt has been made to read past the end of the
19 entry's data.
20
23324ae1 21 When there are no more entries, GetNextEntry() returns @NULL and sets Eof().
7c913512 22
23324ae1 23 @library{wxbase}
c6cf894a 24 @category{archive,streams}
7c913512 25
4cbfec15 26 @see @ref overview_archive, wxArchiveEntry, wxArchiveOutputStream
23324ae1
FM
27*/
28class wxArchiveInputStream : public wxFilterInputStream
29{
30public:
31 /**
32 Closes the current entry. On a non-seekable stream reads to the end of
33 the current entry first.
34 */
d2aa927a 35 virtual bool CloseEntry() = 0;
23324ae1
FM
36
37 /**
38 Closes the current entry if one is open, then reads the meta-data for
4cbfec15
FM
39 the next entry and returns it in a wxArchiveEntry object, giving away
40 ownership. Reading this wxArchiveInputStream then returns the entry's data.
23324ae1
FM
41 */
42 wxArchiveEntry* GetNextEntry();
43
44 /**
45 Closes the current entry if one is open, then opens the entry specified
46 by the wxArchiveEntry object.
4cbfec15
FM
47
48 @a entry must be from the same archive file that this wxArchiveInputStream
49 is reading, and it must be reading it from a seekable stream.
23324ae1 50 */
d2aa927a 51 virtual bool OpenEntry(wxArchiveEntry& entry) = 0;
23324ae1
FM
52};
53
54
e54c96f1 55
23324ae1
FM
56/**
57 @class wxArchiveOutputStream
7c913512 58
d2aa927a 59 This is an abstract base class which serves as a common interface to
23324ae1 60 archive output streams such as wxZipOutputStream.
7c913512 61
4cbfec15
FM
62 wxArchiveOutputStream::PutNextEntry is used to create a new entry in the
63 output archive, then the entry's data is written to the wxArchiveOutputStream.
64 Another call to PutNextEntry() closes the current entry and begins the next.
7c913512 65
23324ae1 66 @library{wxbase}
c6cf894a 67 @category{archive,streams}
7c913512 68
4cbfec15 69 @see @ref overview_archive, wxArchiveEntry, wxArchiveInputStream
23324ae1
FM
70*/
71class wxArchiveOutputStream : public wxFilterOutputStream
72{
73public:
74 /**
4cbfec15 75 Calls Close() if it has not already been called.
23324ae1 76 */
8d483c9b 77 virtual ~wxArchiveOutputStream();
23324ae1
FM
78
79 /**
80 Closes the archive, returning @true if it was successfully written.
81 Called by the destructor if not called explicitly.
cc6e1a74
FM
82
83 @see wxOutputStream::Close()
23324ae1 84 */
cc6e1a74 85 virtual bool Close();
23324ae1
FM
86
87 /**
4cbfec15
FM
88 Close the current entry.
89 It is called implicitly whenever another new entry is created with CopyEntry()
90 or PutNextEntry(), or when the archive is closed.
23324ae1 91 */
d2aa927a 92 virtual bool CloseEntry() = 0;
23324ae1
FM
93
94 /**
95 Some archive formats have additional meta-data that applies to the archive
4cbfec15
FM
96 as a whole.
97 For example in the case of zip there is a comment, which is stored at the end
98 of the zip file. CopyArchiveMetaData() can be used to transfer such information
99 when writing a modified copy of an archive.
100
23324ae1
FM
101 Since the position of the meta-data can vary between the various archive
102 formats, it is best to call CopyArchiveMetaData() before transferring
4cbfec15
FM
103 the entries. The wxArchiveOutputStream will then hold on to the meta-data
104 and write it at the correct point in the output file.
105
23324ae1
FM
106 When the input archive is being read from a non-seekable stream, the
107 meta-data may not be available when CopyArchiveMetaData() is called,
108 in which case the two streams set up a link and transfer the data
109 when it becomes available.
110 */
d2aa927a 111 virtual bool CopyArchiveMetaData(wxArchiveInputStream& stream) = 0;
23324ae1
FM
112
113 /**
4cc4bfaf 114 Takes ownership of @a entry and uses it to create a new entry in the
71f8a117 115 archive. @a entry is then opened in the input stream @a stream
23324ae1 116 and its contents copied to this stream.
4cbfec15 117
23324ae1
FM
118 For archive types which compress entry data, CopyEntry() is likely to be
119 much more efficient than transferring the data using Read() and Write()
120 since it will copy them without decompressing and recompressing them.
4cbfec15 121
4cc4bfaf
FM
122 @a entry must be from the same archive file that @a stream is
123 accessing. For non-seekable streams, @a entry must also be the last
71f8a117 124 thing read from @a stream.
23324ae1 125 */
cc6e1a74 126 virtual bool CopyEntry(wxArchiveEntry* entry,
1d497b99 127 wxArchiveInputStream& stream) = 0;
23324ae1
FM
128
129 /**
4cbfec15
FM
130 Create a new directory entry (see wxArchiveEntry::IsDir) with the given
131 name and timestamp.
132
133 PutNextEntry() can also be used to create directory entries, by supplying
134 a name with a trailing path separator.
23324ae1 135 */
cc6e1a74 136 virtual bool PutNextDirEntry(const wxString& name,
1d497b99 137 const wxDateTime& dt = wxDateTime::Now()) = 0;
23324ae1 138
23324ae1 139 /**
4cbfec15
FM
140 Takes ownership of entry and uses it to create a new entry in the archive.
141 The entry's data can then be written by writing to this wxArchiveOutputStream.
142 */
1d497b99 143 virtual bool PutNextEntry(wxArchiveEntry* entry) = 0;
4cbfec15
FM
144
145 /**
23324ae1
FM
146 Create a new entry with the given name, timestamp and size. The entry's
147 data can then be written by writing to this wxArchiveOutputStream.
148 */
cc6e1a74
FM
149 virtual bool PutNextEntry(const wxString& name,
150 const wxDateTime& dt = wxDateTime::Now(),
1d497b99 151 wxFileOffset size = wxInvalidOffset) = 0;
23324ae1
FM
152};
153
154
e54c96f1 155
23324ae1
FM
156/**
157 @class wxArchiveEntry
7c913512 158
d2aa927a 159 This is an abstract base class which serves as a common interface to
23324ae1
FM
160 archive entry classes such as wxZipEntry.
161 These hold the meta-data (filename, timestamp, etc.), for entries
162 in archive files such as zips and tars.
7c913512 163
3a74a290 164 @section archiveentry_nonseekable About non-seekable streams
c427b5e3
FM
165
166 This information applies only when reading archives from non-seekable streams.
167 When the stream is seekable GetNextEntry() returns a fully populated wxArchiveEntry.
4cbfec15
FM
168 See @ref overview_archive_noseek for more information.
169
170 For generic programming, when the worst case must be assumed, you can rely on
171 all the fields of wxArchiveEntry being fully populated when
4c51a665 172 wxArchiveInputStream::GetNextEntry() returns, with the following exceptions:
4cbfec15
FM
173
174 @li GetSize(): guaranteed to be available after the entry has been read to Eof(),
175 or CloseEntry() has been called;
176 @li IsReadOnly(): guaranteed to be available after the end of the archive has
177 been reached, i.e. after GetNextEntry() returns NULL and Eof() is true.
178
23324ae1 179 @library{wxbase}
c6cf894a 180 @category{archive,streams}
7c913512 181
4cbfec15
FM
182 @see @ref overview_archive, @ref overview_archive_generic,
183 wxArchiveInputStream, wxArchiveOutputStream, wxArchiveNotifier
23324ae1
FM
184*/
185class wxArchiveEntry : public wxObject
186{
187public:
188 /**
189 Returns a copy of this entry object.
190 */
328f5751 191 wxArchiveEntry* Clone() const;
23324ae1 192
23324ae1 193 /**
4cbfec15 194 Gets the entry's timestamp.
23324ae1 195 */
d2aa927a 196 virtual wxDateTime GetDateTime() const = 0;
4cbfec15
FM
197
198 /**
199 Sets the entry's timestamp.
200 */
d2aa927a 201 virtual void SetDateTime(const wxDateTime& dt) = 0;
23324ae1 202
23324ae1 203 /**
4cbfec15
FM
204 Returns the entry's name, by default in the native format.
205 The name can include directory components, i.e. it can be a full path.
206
207 If this is a directory entry, (i.e. if IsDir() is @true) then the
208 returned string is the name with a trailing path separator.
23324ae1 209 */
d2aa927a 210 virtual wxString GetName(wxPathFormat format = wxPATH_NATIVE) const = 0;
4cbfec15
FM
211
212 /**
213 Sets the entry's name.
214 Setting a name with a trailing path separator sets IsDir().
215
216 @see GetName()
217 */
cc6e1a74 218 virtual void SetName(const wxString& name,
1d497b99 219 wxPathFormat format = wxPATH_NATIVE) = 0;
23324ae1 220
23324ae1 221 /**
4cbfec15 222 Returns the size of the entry's data in bytes.
23324ae1 223 */
d2aa927a 224 virtual wxFileOffset GetSize() const = 0;
4cbfec15
FM
225
226 /**
227 Sets the size of the entry's data in bytes.
228 */
d2aa927a 229 virtual void SetSize(wxFileOffset size) = 0;
23324ae1
FM
230
231 /**
232 Returns the path format used internally within the archive to store
233 filenames.
234 */
d2aa927a 235 virtual wxPathFormat GetInternalFormat() const = 0;
23324ae1
FM
236
237 /**
238 Returns the entry's filename in the internal format used within the
239 archive. The name can include directory components, i.e. it can be a
240 full path.
4cbfec15 241
23324ae1
FM
242 The names of directory entries are returned without any trailing path
243 separator. This gives a canonical name that can be used in comparisons.
3c4f71cc 244
4cbfec15 245 @see @ref overview_archive_byname
23324ae1 246 */
d2aa927a 247 virtual wxString GetInternalName() const = 0;
23324ae1
FM
248
249 /**
250 Returns a numeric value unique to the entry within the archive.
251 */
d2aa927a 252 virtual wxFileOffset GetOffset() const = 0;
23324ae1 253
23324ae1 254 /**
4cbfec15
FM
255 Returns @true if this is a directory entry.
256
23324ae1
FM
257 Directory entries are entries with no data, which are used to store
258 the meta-data of directories. They also make it possible for completely
259 empty directories to be stored.
4cbfec15
FM
260
261 @note
23324ae1
FM
262 The names of entries within an archive can be complete paths, and
263 unarchivers typically create whatever directories are necessary as they
264 restore files, even if the archive contains no explicit directory entries.
265 */
d2aa927a 266 virtual bool IsDir() const = 0;
4cbfec15
FM
267
268 /**
269 Marks this entry as a directory if @a isDir is @true. See IsDir() for more info.
270 */
d2aa927a 271 virtual void SetIsDir(bool isDir = true) = 0;
23324ae1 272
23324ae1 273 /**
4cbfec15 274 Returns @true if the entry is a read-only file.
23324ae1 275 */
d2aa927a 276 virtual bool IsReadOnly() const = 0;
4cbfec15
FM
277
278 /**
279 Sets this entry as a read-only file.
280 */
d2aa927a 281 virtual void SetIsReadOnly(bool isReadOnly = true) = 0;
23324ae1 282
23324ae1 283 /**
4cbfec15
FM
284 Sets the notifier (see wxArchiveNotifier) for this entry.
285
286 Whenever the wxArchiveInputStream updates this entry, it will then invoke
287 the associated notifier's wxArchiveNotifier::OnEntryUpdated method.
288
23324ae1
FM
289 Setting a notifier is not usually necessary. It is used to handle
290 certain cases when modifying an archive in a pipeline (i.e. between
291 non-seekable streams).
292 */
293 void SetNotifier(wxArchiveNotifier& notifier);
4cbfec15
FM
294
295 /**
296 Unsets the notifier eventually attached to this entry.
297 */
cc6e1a74 298 virtual void UnsetNotifier();
23324ae1
FM
299};
300
301
e54c96f1 302
23324ae1
FM
303/**
304 @class wxArchiveClassFactory
7c913512 305
4cbfec15 306 Allows the creation of streams to handle archive formats such as zip and tar.
7c913512 307
23324ae1
FM
308 For example, given a filename you can search for a factory that will
309 handle it and create a stream to read it:
7c913512 310
23324ae1 311 @code
4cbfec15 312 factory = wxArchiveClassFactory::Find(filename, wxSTREAM_FILEEXT);
23324ae1 313 if (factory)
4cbfec15 314 stream = factory->NewStream(new wxFFileInputStream(filename));
23324ae1 315 @endcode
7c913512 316
4cbfec15
FM
317 wxArchiveClassFactory::Find can also search for a factory by MIME type
318 or wxFileSystem protocol.
319
3c4f71cc 320 The available factories can be enumerated using
4cbfec15 321 wxArchiveClassFactory::GetFirst() and wxArchiveClassFactory::GetNext().
7c913512 322
23324ae1 323 @library{wxbase}
c6cf894a 324 @category{archive,streams}
7c913512 325
4cbfec15
FM
326 @see @ref overview_archive, @ref overview_archive_generic, wxArchiveEntry,
327 wxArchiveInputStream, wxArchiveOutputStream, wxFilterClassFactory
23324ae1
FM
328*/
329class wxArchiveClassFactory : public wxObject
330{
331public:
332 /**
333 Returns @true if this factory can handle the given protocol, MIME type
334 or file extension.
4cbfec15 335
23324ae1
FM
336 When using wxSTREAM_FILEEXT for the second parameter, the first parameter
337 can be a complete filename rather than just an extension.
338 */
d56f17d8 339 bool CanHandle(const wxString& protocol,
328f5751 340 wxStreamProtocolType type = wxSTREAM_PROTOCOL) const;
23324ae1
FM
341
342 /**
343 A static member that finds a factory that can handle a given protocol, MIME
344 type or file extension. Returns a pointer to the class factory if found, or
345 @NULL otherwise. It does not give away ownership of the factory.
4cbfec15 346
23324ae1
FM
347 When using wxSTREAM_FILEEXT for the second parameter, the first parameter
348 can be a complete filename rather than just an extension.
349 */
382f12e4 350 static const wxArchiveClassFactory* Find(const wxString& protocol,
7c913512 351 wxStreamProtocolType type = wxSTREAM_PROTOCOL);
23324ae1 352
23324ae1 353 /**
4cbfec15
FM
354 Returns the wxMBConv object that the created streams will use when
355 translating meta-data. The initial default, set by the constructor,
356 is wxConvLocal.
23324ae1 357 */
d56f17d8 358 wxMBConv& GetConv() const;
4cbfec15
FM
359
360 /**
361 Sets the wxMBConv object that the created streams will use when
362 translating meta-data.
363 */
364 void SetConv(wxMBConv& conv);
23324ae1
FM
365
366 //@{
367 /**
368 GetFirst and GetNext can be used to enumerate the available factories.
23324ae1 369 For example, to list them:
4cbfec15
FM
370
371 @code
372 wxString list;
373 const wxArchiveClassFactory *factory = wxArchiveClassFactory::GetFirst();
3c4f71cc 374
4cbfec15 375 while (factory) {
9a83f860 376 list << factory->GetProtocol() << wxT("\n");
4cbfec15
FM
377 factory = factory->GetNext();
378 }
379 @endcode
3c4f71cc 380
4cbfec15 381 GetFirst() and GetNext() return a pointer to a factory or @NULL if no more
23324ae1
FM
382 are available. They do not give away ownership of the factory.
383 */
57bf907d 384 static const wxArchiveClassFactory* GetFirst();
328f5751 385 const wxArchiveClassFactory* GetNext() const;
23324ae1
FM
386 //@}
387
388 /**
389 Calls the static GetInternalName() function for the archive entry type,
4cbfec15 390 for example wxZipEntry::GetInternalName.
23324ae1 391 */
d56f17d8
FM
392 virtual wxString GetInternalName(const wxString& name,
393 wxPathFormat format = wxPATH_NATIVE) const = 0;
23324ae1
FM
394
395 /**
4cbfec15
FM
396 Returns the wxFileSystem protocol supported by this factory.
397 Equivalent to @code wxString(*GetProtocols()) @endcode.
23324ae1 398 */
328f5751 399 wxString GetProtocol() const;
23324ae1
FM
400
401 /**
402 Returns the protocols, MIME types or file extensions supported by this
4cbfec15
FM
403 factory, as an array of null terminated strings.
404
405 It does not give away ownership of the array or strings.
23324ae1 406 For example, to list the file extensions a factory supports:
4cbfec15
FM
407
408 @code
409 wxString list;
410 const wxChar *const *p;
3c4f71cc 411
4cbfec15 412 for (p = factory->GetProtocols(wxSTREAM_FILEEXT); *p; p++)
9a83f860 413 list << *p << wxT("\n");
0801f345 414 @endcode
23324ae1 415 */
d56f17d8 416 virtual const wxChar** GetProtocols(wxStreamProtocolType type = wxSTREAM_PROTOCOL) const = 0;
23324ae1
FM
417
418 /**
4cbfec15 419 Create a new wxArchiveEntry object of the appropriate type.
23324ae1 420 */
328f5751 421 wxArchiveEntry* NewEntry() const;
23324ae1
FM
422
423 //@{
424 /**
425 Create a new input or output stream to read or write an archive.
4cbfec15 426
23324ae1
FM
427 If the parent stream is passed as a pointer then the new archive stream
428 takes ownership of it. If it is passed by reference then it does not.
429 */
328f5751 430 wxArchiveInputStream* NewStream(wxInputStream& stream) const;
4cbfec15
FM
431 wxArchiveOutputStream* NewStream(wxOutputStream& stream) const;
432 wxArchiveInputStream* NewStream(wxInputStream* stream) const;
433 wxArchiveOutputStream* NewStream(wxOutputStream* stream) const;
23324ae1
FM
434 //@}
435
436 /**
4cbfec15
FM
437 Adds this class factory to the list returned by GetFirst() or GetNext().
438
23324ae1 439 It is not necessary to do this to use the archive streams. It is usually
7c913512 440 used when implementing streams, typically the implementation will
23324ae1 441 add a static instance of its factory class.
4cbfec15 442
23324ae1
FM
443 It can also be used to change the order of a factory already in the list,
444 bringing it to the front. This isn't a thread safe operation
445 so can't be done when other threads are running that will be using the list.
23324ae1
FM
446 The list does not take ownership of the factory.
447 */
448 void PushFront();
449
450 /**
4cbfec15
FM
451 Removes this class factory from the list returned by GetFirst() and GetNext().
452
453 Removing from the list isn't a thread safe operation so can't be done when
454 other threads are running that will be using the list.
23324ae1
FM
455 The list does not own the factories, so removing a factory does not delete it.
456 */
457 void Remove();
458};
459
460
e54c96f1 461
23324ae1
FM
462/**
463 @class wxArchiveNotifier
7c913512 464
4cbfec15
FM
465 If you need to know when a wxArchiveInputStream updates a wxArchiveEntry
466 object, you can create a notifier by deriving from this abstract base class,
467 overriding wxArchiveNotifier::OnEntryUpdated.
468
469 An instance of your notifier class can then be assigned to the wxArchiveEntry
470 object using wxArchiveEntry::SetNotifier.
23324ae1
FM
471 Your OnEntryUpdated() method will then be invoked whenever the input
472 stream updates the entry.
7c913512 473
23324ae1
FM
474 Setting a notifier is not usually necessary. It is used to handle
475 certain cases when modifying an archive in a pipeline (i.e. between
476 non-seekable streams).
4cbfec15 477 See @ref overview_archive_noseek.
7c913512 478
23324ae1 479 @library{wxbase}
c6cf894a 480 @category{archive,streams}
7c913512 481
4cbfec15
FM
482 @see @ref overview_archive_noseek, wxArchiveEntry, wxArchiveInputStream,
483 wxArchiveOutputStream
23324ae1 484*/
7c913512 485class wxArchiveNotifier
23324ae1
FM
486{
487public:
488 /**
489 This method must be overridden in your derived class.
490 */
d56f17d8 491 virtual void OnEntryUpdated(wxArchiveEntry& entry) = 0;
23324ae1
FM
492};
493
494
e54c96f1 495
23324ae1
FM
496/**
497 @class wxArchiveIterator
7c913512 498
23324ae1
FM
499 An input iterator template class that can be used to transfer an archive's
500 catalogue to a container. It is only available if wxUSE_STL is set to 1
501 in setup.h, and the uses for it outlined below require a compiler which
502 supports member templates.
7c913512 503
23324ae1 504 @code
1bc693a9 505 template<class Arc, class T = typename Arc::entry_type*>
23324ae1
FM
506 class wxArchiveIterator
507 {
508 // this constructor creates an 'end of sequence' object
509 wxArchiveIterator();
7c913512 510
23324ae1
FM
511 // template parameter 'Arc' should be the type of an archive input stream
512 wxArchiveIterator(Arc& arc) {
4cc4bfaf
FM
513 // ...
514 }
515 };
516 @endcode
7c913512 517
4cc4bfaf 518 The first template parameter should be the type of archive input stream
4cbfec15 519 (e.g. wxArchiveInputStream) and the second can either be a pointer to an entry
1bc693a9
FM
520 (e.g. wxArchiveEntry*), or a string/pointer pair
521 (e.g. std::pair<wxString,wxArchiveEntry*>).
7c913512 522
4cc4bfaf 523 The @c wx/archive.h header defines the following typedefs:
7c913512 524
4cc4bfaf 525 @code
4cbfec15 526 typedef wxArchiveIterator<wxArchiveInputStream> wxArchiveIter;
7c913512 527
4cbfec15
FM
528 typedef wxArchiveIterator<wxArchiveInputStream,
529 std::pair<wxString, wxArchiveEntry*> > wxArchivePairIter;
4cc4bfaf 530 @endcode
7c913512 531
4cc4bfaf
FM
532 The header for any implementation of this interface should define similar
533 typedefs for its types, for example in @c wx/zipstrm.h there is:
7c913512 534
4cc4bfaf 535 @code
4cbfec15 536 typedef wxArchiveIterator<wxZipInputStream> wxZipIter;
7c913512 537
4cbfec15
FM
538 typedef wxArchiveIterator<wxZipInputStream,
539 std::pair<wxString, wxZipEntry*> > wxZipPairIter;
4cc4bfaf 540 @endcode
7c913512 541
4cc4bfaf
FM
542 Transferring the catalogue of an archive @e arc to a vector @e cat,
543 can then be done something like this:
7c913512 544
4cc4bfaf 545 @code
4cbfec15 546 std::vector<wxArchiveEntry*> cat((wxArchiveIter)arc, wxArchiveIter());
4cc4bfaf 547 @endcode
7c913512 548
4cc4bfaf
FM
549 When the iterator is dereferenced, it gives away ownership of an entry
550 object. So in the above example, when you have finished with @e cat
551 you must delete the pointers it contains.
7c913512 552
4cc4bfaf 553 If you have smart pointers with normal copy semantics (i.e. not auto_ptr
4cbfec15
FM
554 or wxScopedPtr), then you can create an iterator which uses them instead.
555
556 For example, with a smart pointer class for zip entries @e ZipEntryPtr:
7c913512 557
4cc4bfaf 558 @code
4cbfec15
FM
559 typedef std::vector<ZipEntryPtr> ZipCatalog;
560 typedef wxArchiveIterator<wxZipInputStream, ZipEntryPtr> ZipIter;
561 ZipCatalog cat((ZipIter)zip, ZipIter());
4cc4bfaf 562 @endcode
7c913512 563
4cbfec15
FM
564 Iterators that return std::pair objects can be used to populate a std::multimap,
565 to allow entries to be looked up by name.
566 The string is initialised using the wxArchiveEntry object's
567 wxArchiveEntry::GetInternalName function.
7c913512 568
4cc4bfaf 569 @code
4cbfec15
FM
570 typedef std::multimap<wxString, wxZipEntry*> ZipCatalog;
571 ZipCatalog cat((wxZipPairIter)zip, wxZipPairIter());
4cc4bfaf 572 @endcode
7c913512 573
4cc4bfaf
FM
574 Note that this iterator also gives away ownership of an entry
575 object each time it is dereferenced. So in the above example, when
576 you have finished with @e cat you must delete the pointers it contains.
7c913512 577
4cc4bfaf
FM
578 Or if you have them, a pair containing a smart pointer can be used
579 (again @e ZipEntryPtr), no worries about ownership:
7c913512 580
4cc4bfaf 581 @code
4cbfec15
FM
582 typedef std::multimap<wxString, ZipEntryPtr> ZipCatalog;
583 typedef wxArchiveIterator<wxZipInputStream,
584 std::pair<wxString, ZipEntryPtr> > ZipPairIter;
585 ZipCatalog cat((ZipPairIter)zip, ZipPairIter());
4cc4bfaf 586 @endcode
7c913512 587
4cc4bfaf 588 @library{wxbase}
c6cf894a 589 @category{archive,streams}
7c913512 590
e54c96f1 591 @see wxArchiveEntry, wxArchiveInputStream, wxArchiveOutputStream
23324ae1 592*/
7c913512 593class wxArchiveIterator
23324ae1
FM
594{
595public:
4cc4bfaf 596 /**
4cbfec15 597 Default constructor.
4cc4bfaf
FM
598 */
599 wxArchiveIterator();
4cbfec15
FM
600
601 /**
602 Construct the iterator that returns all the entries in the archive input
71f8a117 603 stream @a arc.
4cbfec15 604 */
4cc4bfaf 605 wxArchiveIterator(Arc& arc);
23324ae1 606
4cc4bfaf
FM
607 /**
608 Returns an entry object from the archive input stream, giving away
609 ownership.
610 */
328f5751 611 const T operator*() const;
23324ae1 612
4cc4bfaf
FM
613 //@{
614 /**
615 Position the input iterator at the next entry in the archive input stream.
616 */
617 wxArchiveIterator operator++();
4cbfec15 618 wxArchiveIterator operator++(int);
4cc4bfaf 619 //@}
23324ae1 620};
e54c96f1 621