1% 2% automatically generated by HelpGen $Revision: 42795 $ from 3% include/wx/stream.h at 28/Oct/06 18:49:10 4% 5 6\section{\class{wxFilterClassFactory}}\label{wxfilterclassfactory} 7 8Allows the creation of filter streams to handle compression formats such 9as gzip and bzip2. 10 11For example, given a filename you can search for a factory that will 12handle it and create a stream to decompress it: 13 14\begin{verbatim} 15 factory = wxFilterClassFactory::Find(filename, wxSTREAM_FILEEXT); 16 if (factory) 17 stream = factory->NewStream(new wxFFileInputStream(filename)); 18\end{verbatim} 19 20\helpref{Find()}{wxfilterclassfactoryfind} can also search 21for a factory by MIME type, HTTP encoding or by wxFileSystem protocol. 22The available factories can be enumerated 23using \helpref{GetFirst() and GetNext()}{wxfilterclassfactorygetfirst}. 24 25\wxheading{Derived from} 26 27\helpref{wxObject}{wxobject} 28 29\wxheading{Include files} 30 31<wx/stream.h> 32 33\wxheading{Data structures} 34 35\begin{verbatim} 36enum wxStreamProtocolType 37{ 38 wxSTREAM_PROTOCOL, // wxFileSystem protocol (should be only one) 39 wxSTREAM_MIMETYPE, // MIME types the stream handles 40 wxSTREAM_ENCODING, // The HTTP Content-Encodings the stream handles 41 wxSTREAM_FILEEXT // File extensions the stream handles 42}; 43 44\end{verbatim} 45 46\wxheading{See also} 47 48\helpref{wxFilterInputStream}{wxfilterinputstream}\\ 49\helpref{wxFilterOutputStream}{wxfilteroutputstream}\\ 50\helpref{wxArchiveClassFactory}{wxarchiveclassfactory}\\ 51\helpref{Archive formats such as zip}{wxarc} 52 53\latexignore{\rtfignore{\wxheading{Members}}} 54 55 56\membersection{wxFilterClassFactory::CanHandle}\label{wxfilterclassfactorycanhandle} 57 58\constfunc{bool}{CanHandle}{\param{const wxChar* }{protocol}, \param{wxStreamProtocolType }{type = wxSTREAM\_PROTOCOL}} 59 60Returns true if this factory can handle the given protocol, MIME type, HTTP 61encoding or file extension. 62 63When using wxSTREAM\_FILEEXT for the second parameter, the first parameter 64can be a complete filename rather than just an extension. 65 66 67\membersection{wxFilterClassFactory::Find}\label{wxfilterclassfactoryfind} 68 69\func{static const wxFilterClassFactory*}{Find}{\param{const wxChar* }{protocol}, \param{wxStreamProtocolType }{type = wxSTREAM\_PROTOCOL}} 70 71A static member that finds a factory that can handle a given protocol, MIME 72type, HTTP encoding or file extension. Returns a pointer to the class 73factory if found, or NULL otherwise. It does not give away ownership of the 74factory. 75 76When using wxSTREAM\_FILEEXT for the second parameter, the first parameter 77can be a complete filename rather than just an extension. 78 79 80\membersection{wxFilterClassFactory::GetFirst/GetNext}\label{wxfilterclassfactorygetfirst} 81 82\func{static const wxFilterClassFactory*}{GetFirst}{\void} 83 84\constfunc{const wxFilterClassFactory*}{GetNext}{\void} 85 86GetFirst and GetNext can be used to enumerate the available factories. 87 88For example, to list them: 89 90\begin{verbatim} 91 wxString list; 92 const wxFilterClassFactory *factory = wxFilterClassFactory::GetFirst(); 93 94 while (factory) { 95 list << factory->GetProtocol() << _T("\n"); 96 factory = factory->GetNext(); 97 } 98 99\end{verbatim} 100 101GetFirst()/GetNext() return a pointer to a factory or NULL if no more 102are available. They do not give away ownership of the factory. 103 104 105\membersection{wxFilterClassFactory::GetProtocol}\label{wxfilterclassfactorygetprotocol} 106 107\constfunc{wxString}{GetProtocol}{\void} 108 109Returns the wxFileSystem protocol supported by this factory. Equivalent 110to wxString(*GetProtcols()). 111 112 113\membersection{wxFilterClassFactory::GetProtocols}\label{wxfilterclassfactorygetprotocols} 114 115\constfunc{const wxChar * const*}{GetProtocols}{\param{wxStreamProtocolType }{type = wxSTREAM\_PROTOCOL}} 116 117Returns the protocols, MIME types, HTTP encodings or file extensions 118supported by this factory, as an array of null terminated strings. It does 119not give away ownership of the array or strings. 120 121For example, to list the file extensions a factory supports: 122 123\begin{verbatim} 124 wxString list; 125 const wxChar *const *p; 126 127 for (p = factory->GetProtocols(wxSTREAM_FILEEXT); *p; p++) 128 list << *p << _T("\n"); 129 130\end{verbatim} 131 132 133\membersection{wxFilterClassFactory::NewStream}\label{wxfilterclassfactorynewstream} 134 135\constfunc{wxFilterInputStream*}{NewStream}{\param{wxInputStream\& }{stream}} 136 137\constfunc{wxFilterOutputStream*}{NewStream}{\param{wxOutputStream\& }{stream}} 138 139\constfunc{wxFilterInputStream*}{NewStream}{\param{wxInputStream* }{stream}} 140 141\constfunc{wxFilterOutputStream*}{NewStream}{\param{wxOutputStream* }{stream}} 142 143Create a new input or output stream to decompress or compress a given stream. 144 145If the parent stream is passed as a pointer then the new filter stream 146takes ownership of it. If it is passed by reference then it does not. 147 148 149\membersection{wxFilterClassFactory::PopExtension}\label{wxfilterclassfactorypopextension} 150 151\constfunc{wxString}{PopExtension}{\param{const wxString\& }{location}} 152 153Remove the file extension of {\it location} if it is one of the file 154extensions handled by this factory. 155 156 157\membersection{wxFilterClassFactory::PushFront}\label{wxfilterclassfactorypushfront} 158 159\func{void}{PushFront}{\void} 160 161Adds this class factory to the list returned 162by \helpref{GetFirst()/GetNext()}{wxfilterclassfactorygetfirst}. 163 164It is not necessary to do this to use the filter streams. It is usually 165used when implementing streams, typically the implementation will 166add a static instance of its factory class. 167 168It can also be used to change the order of a factory already in the list, 169bringing it to the front. This isn't a thread safe operation 170so can't be done when other threads are running that will be using the list. 171 172The list does not take ownership of the factory. 173 174 175\membersection{wxFilterClassFactory::Remove}\label{wxfilterclassfactoryremove} 176 177\func{void}{Remove}{\void} 178 179Removes this class factory from the list returned 180by \helpref{GetFirst()/GetNext()}{wxfilterclassfactorygetfirst}. 181 182Removing from the list isn't a thread safe operation 183so can't be done when other threads are running that will be using the list. 184 185The list does not own the factories, so removing a factory does not delete it. 186 187