wxarchiveclassfactoryallows the creation of streams to handle archive formats such as zip and tar. for example, given a filename you can search for a factory that will handle it and create a stream to read it:
factory = wxarchiveclassfactory::find(filename, wxstream_fileext); if (factory) stream = factory->newstream(new wxffileinputstream(filename));find() can also search for a factory by mime type or wxfilesystem protocol. the available factories can be enumerated using getfirst() and getnext(). derived from include files <wx/archive.h> data structures
enum wxstreamprotocoltype { wxstream_protocol, // wxfilesystem protocol (should be only one) wxstream_mimetype, // mime types the stream handles wxstream_encoding, // not used for archives wxstream_fileext // file extensions the stream handles };see also
archive formats such as zip members
wxarchiveclassfactory::get/setconv
wxarchiveclassfactory::get/setconvwxmbconv& getconv() const void setconv(wxmbconv& conv) the wxmbconv object that the created streams will use when translating meta-data. the initial default, set by the constructor, is wxconvlocal.
wxarchiveclassfactory::canhandlebool canhandle(const wxchar* protocol, wxstreamprotocoltype type = wxstream_protocol) const returns true if this factory can handle the given protocol, mime type or file extension. when using wxstream_fileext for the second parameter, the first parameter can be a complete filename rather than just an extension.
wxarchiveclassfactory::findstatic const wxarchiveclassfactory* find(const wxchar* protocol, wxstreamprotocoltype type = wxstream_protocol) a static member that finds a factory that can handle a given protocol, mime type or file extension. returns a pointer to the class factory if found, or null otherwise. it does not give away ownership of the factory. when using wxstream_fileext for the second parameter, the first parameter can be a complete filename rather than just an extension.
wxarchiveclassfactory::getfirst/getnextstatic const wxarchiveclassfactory* getfirst() const wxarchiveclassfactory* getnext() const getfirst and getnext can be used to enumerate the available factories. for example, to list them:
wxstring list; const wxarchiveclassfactory *factory = wxarchiveclassfactory::getfirst(); while (factory) { list << factory->getprotocol() << _t("\n"); factory = factory->getnext(); }getfirst()/getnext() return a pointer to a factory or null if no more are available. they do not give away ownership of the factory.
wxarchiveclassfactory::getinternalnamewxstring getinternalname(const wxstring& name, wxpathformat format = wxpath_native) const calls the static getinternalname() function for the archive entry type, for example wxzipentry::getinternalname().
wxarchiveclassfactory::getprotocolwxstring getprotocol() const returns the wxfilesystem protocol supported by this factory. equivalent to wxstring(*getprotcols()).
wxarchiveclassfactory::getprotocolsconst wxchar * const* getprotocols(wxstreamprotocoltype type = wxstream_protocol) const returns the protocols, mime types or file extensions supported by this factory, as an array of null terminated strings. it does not give away ownership of the array or strings. for example, to list the file extensions a factory supports:
wxstring list; const wxchar *const *p; for (p = factory->getprotocols(wxstream_fileext); *p; p++) list << *p << _t("\n"); wxarchiveclassfactory::newentrywxarchiveentry* newentry() const create a new wxarchiveentry object of the appropriate type.
wxarchiveclassfactory::newstreamwxarchiveinputstream* newstream(wxinputstream& stream) const wxarchiveoutputstream* newstream(wxoutputstream& stream) const wxarchiveinputstream* newstream(wxinputstream* stream) const wxarchiveoutputstream* newstream(wxoutputstream* stream) const create a new input or output stream to read or write an archive. if the parent stream is passed as a pointer then the new archive stream takes ownership of it. if it is passed by reference then it does not.
wxarchiveclassfactory::pushfrontvoid pushfront() adds this class factory to the list returned by getfirst()/getnext(). it is not necessary to do this to use the archive streams. it is usually used when implementing streams, typically the implementation will add a static instance of its factory class. it can also be used to change the order of a factory already in the list, bringing it to the front. this isn't a thread safe operation so can't be done when other threads are running that will be using the list. the list does not take ownership of the factory.
wxarchiveclassfactory::removevoid remove() removes this class factory from the list returned by getfirst()/getnext(). removing from the list isn't a thread safe operation so can't be done when other threads are running that will be using the list. the list does not own the factories, so removing a factory does not delete it.
|