c9114effb4a6c9e7aae7cf4d3b6654b5da623bf2
[platform/upstream/boost.git] / libs / iostreams / doc / classes / gzip.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <HTML>
3 <HEAD>
4     <TITLE>Gzip Filters</TITLE>
5     <LINK REL="stylesheet" HREF="../../../../boost.css">
6     <LINK REL="stylesheet" HREF="../theme/iostreams.css">
7 </HEAD>
8 <BODY>
9
10 <!-- Begin Banner -->
11
12     <H1 CLASS="title">Gzip Filters</H1>
13     <HR CLASS="banner">
14
15 <!-- End Banner -->
16
17 <DL class="page-index">
18   <DT><A href="#overview">Overview</A></DT>
19   <DT><A href="#acknowledgments">Acknowledgments</A></DT>
20   <DT><A href="#headers">Headers</A></DT>
21   <DT><A href="#synopsis">Synopsis</A></DT>
22   <DT><A HREF="#reference">Reference</A>
23     <DL class="page-index">
24       <DT><A HREF="#constants">namespace <CODE>boost::iostreams::gzip</CODE></A></DT>
25       <DT><A HREF="#gzip_params">Class <CODE>gzip_params</CODE></A></DT>
26       <DT><A HREF="#basic_gzip_compressor">Class template <CODE>gzip_compressor</CODE></A></DT>
27       <DT><A HREF="#basic_gzip_decompressor">Class template <CODE>gzip_decompressor</CODE></A></DT>
28       <DT><A HREF="#gzip_error">Class <CODE>gzip_error</CODE></A></DT>
29     </DL>
30   </DT>
31   <DT><A href="#examples">Examples</A></DT>
32   <DT><A href="#installation">Installation</A></DT>
33 </DL>
34
35 <A NAME="overview"></A>
36 <H2>Overview</H2>
37
38 <P>
39     The class templates <A HREF="#basic_gzip_compressor"><CODE>basic_gzip_compressor</CODE></A> and <A HREF="#basic_gzip_decompressor"><CODE>basic_gzip_decompressor</CODE></A> perform compression and decompression based on the G<SPAN STYLE="font-size:80%">ZIP</SPAN> format (<A CLASS="bib_ref" HREF="../bibliography.html#deutsch3">[Deutsch3]</A>) using Jean-loup Gailly's and Mark Adler's zlib compression library (<A CLASS="bib_ref" HREF="../bibliography.html#gailly">[Gailly]</A>). They are implementation as derived classes of the <A HREF="zlib.html">Zlib Filters</A>. The difference between the G<SPAN STYLE="font-size:80%">ZIP</SPAN> and Z<SPAN STYLE="font-size:80%">LIB</SPAN> formats is that data in the G<SPAN STYLE="font-size:80%">ZIP</SPAN> contains more header information and a different checksum (<A CLASS="bib_ref" HREF="../bibliography.html#deutsch1">[Deutsch1]</A>, <A CLASS="bib_ref" HREF="../bibliography.html#deutsch3">[Deutsch3]</A>).
40 </P>
41 <P>
42     Currently, <CODE>basic_gzip_compressor</CODE> is a <A HREF="../concepts/dual_use_filter.html">DualUseFilters</A>, but <CODE>basic_gzip_compressor</CODE> is only an <A HREF="../concepts/input_filter.html">InputFilter</A>.
43 </P>
44
45 <A NAME="acknowledgments"></A>
46 <H2>Acknowledgments</H2>
47
48 <P>
49     The gzip Filters were influences by the work of Jeff Garland (<A CLASS="bib_ref" HREF="../bibliography.html#garland">[Garland]</A>) and Jonathan de Halleux (<A CLASS="bib_ref" HREF="../bibliography.html#de_halleux">[de Halleux]</A>).
50 </P>
51
52 Thanks to <A HREF="mailto:jloup@gailly.net">Jean-loup Gailly</A> and <A HREF="mailto:&#109;&#097;&#100;&#108;&#101;&#114;&#064;&#097;&#108;&#117;&#109;&#110;&#105;&#046;&#099;&#097;&#108;&#116;&#101;&#099;&#104;&#046;&#101;&#100;&#117;">Mark Adler</A> for making their excellent library available to the public with a <A HREF="http://www.boost.org/more/lib_guide.htm#Requirements">Boost-compatible</A> license.
53
54 <A NAME="headers"></A>
55 <H2>Headers</H2>
56
57 <DL>
58   <DT><A CLASS="header" HREF="../../../../boost/iostreams/filter/gzip.hpp"><CODE>&lt;boost/iostreams/filter/gzip.hpp&gt;</CODE></A></DT>
59 </DL>
60
61 <A NAME="synopsis"></A>
62 <H2>Synopsis</H2>
63
64 <PRE CLASS="broken_ie"><SPAN CLASS="keyword">namespace</SPAN> boost { <SPAN CLASS="keyword">namespace</SPAN> iostreams {
65
66 <SPAN CLASS="keyword">namespace</SPAN> <A CLASS="documented" HREF="#constants">gzip</A> {
67                     
68 <SPAN CLASS="keyword">using</SPAN> <SPAN CLASS="keyword">namespace</SPAN> <A CLASS="documented" HREF="zlib.html#constants">boost::iostreams::zlib</A>;
69
70     <SPAN CLASS="comment">// Error codes used by gzip_error.</SPAN>
71
72 <SPAN CLASS="keyword">const</SPAN> <SPAN CLASS="keyword">int</SPAN> <A CLASS="documented" HREF="#zlib_error">zlib_error</A>;
73 <SPAN CLASS="keyword">const</SPAN> <SPAN CLASS="keyword">int</SPAN> <A CLASS="documented" HREF="#bad_crc">bad_crc</A>;
74 <SPAN CLASS="keyword">const</SPAN> <SPAN CLASS="keyword">int</SPAN> <A CLASS="documented" HREF="#bad_length">bad_length</A>;
75 <SPAN CLASS="keyword">const</SPAN> <SPAN CLASS="keyword">int</SPAN> <A CLASS="documented" HREF="#bad_header">bad_header</A>;
76 <SPAN CLASS="keyword">const</SPAN> <SPAN CLASS="keyword">int</SPAN> <A CLASS="documented" HREF="#bad_footer">bad_footer</A>;
77
78 }   <SPAN CLASS="comment">// End namespace boost::iostreams::gzip</SPAN>
79
80 <SPAN CLASS="keyword">struct</SPAN> <A CLASS="documented" HREF="#gzip_params">gzip_params</A>;
81
82 <SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> Alloc = std::allocator<<SPAN CLASS="keyword">char</SPAN>> >
83 <SPAN CLASS="keyword">struc</SPAN>t <A CLASS="documented" HREF="#basic_gzip_compressor">basic_gzip_compressor</A>;
84
85 <SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> Alloc = std::allocator<<SPAN CLASS="keyword">char</SPAN>> >
86 <SPAN CLASS="keyword">struct</SPAN> <A CLASS="documented" HREF="#basic_gzip_decompressor">basic_gzip_decompressor</A>;
87
88 <SPAN CLASS="keyword">typedef</SPAN> basic_gzip_compressor<>   <SPAN CLASS="defined">gzip_compressor</SPAN>;
89 <SPAN CLASS="keyword">typedef</SPAN> basic_gzip_decompressor<> <SPAN CLASS="defined">gzip_decompressor</SPAN>;
90
91 <SPAN CLASS="keyword">class</SPAN> <A CLASS="documented" HREF="#gzip_error">gzip_error</A>;
92
93 } } <SPAN CLASS="comment">// End namespace boost::io</SPAN></PRE>
94
95 <A NAME="reference"></A>
96 <H2>Reference</H2>
97
98 <A NAME="constants"></A>
99 <H3>Namespace <CODE>boost::iostreams::gzip</CODE></H3>
100
101 <P>The namespace <CODE>boost::iostreams::gzip</CODE> contains integral constants used to configure gzip Filters and to report errors. The constants have the following interpretations. (<I>See</I> <A CLASS="bib_ref" HREF="../bibliography.html#deutsch3">[Deutsch3]</A> for additional details.)</P>
102
103 <TABLE STYLE="margin-left:2em" BORDER=1 CELLPADDING=4>
104 <TR><TH>Constant</TH><TH>Interpretation</TH></TR>
105     <TR>
106         <TD VALIGN="top"><A NAME="zlib_error"></A><CODE>zlib_error</CODE></TD>
107         <TD>A zlib error has occurred; use <A HREF="#gzip_error_zlib_error_code"><CODE>gzip_error::zlib_error_code</CODE></A> to obtain an error code.</TD>
108     </TR>
109     <TR>
110         <TD VALIGN="top"><A NAME="bad_crc"></A><CODE>bad_crc</CODE></TD>
111         <TD>Recorded crc doesn't match data.</TD>
112     </TR>
113     <TR>
114         <TD VALIGN="top"><A NAME="bad_length"></A><CODE>bad_length</CODE></TD>
115         <TD>Recorded length doesn't match data.</TD>
116     </TR>
117     <TR>
118         <TD VALIGN="top"><A NAME="bad_header"></A><CODE>bad_header</CODE></TD>
119         <TD>Malformed file header.</TD>
120     </TR>
121     <TR>
122         <TD VALIGN="top"><A NAME="bad_footer"></A><CODE>bad_footer</CODE></TD>
123         <TD>Portion of file following compressed data is malformed.</TD>
124     </TR>
125 </TABLE>
126
127 <A NAME="gzip_params"></A>
128 <H3>Class <CODE>gzip_params</CODE></H3>
129
130 <H4>Description</H4>
131
132 <P>Encapsulates the parameters used to configure <A HREF="#basic_gzip_compressor"><CODE>basic_gzip_compressor</CODE></A> and <A HREF="#basic_gzip_decompressor"><CODE>basic_gzip_decompressor</CODE></A>.</P>
133
134 <H4>Synopsis</H4>
135
136 <PRE CLASS="broken_ie"><SPAN CLASS="keyword">struct</SPAN> <SPAN CLASS="defined">gzip_params</SPAN> : <A CLASS="documented" HREF="zlib.html#zlib_params">zlib_params</A> {
137
138     <SPAN CLASS="comment">// Non-explicit constructor.</SPAN>
139     <A CLASS="documented" HREF="#gzip_params_constructor">gzip_params</A>( <SPAN CLASS="keyword">int</SPAN> level              = <SPAN CLASS="omitted">default value</SPAN>,
140                  <SPAN CLASS="keyword">int</SPAN> method             = <SPAN CLASS="omitted">default value</SPAN>,
141                  <SPAN CLASS="keyword">int</SPAN> window_bits        = <SPAN CLASS="omitted">default value</SPAN>, 
142                  <SPAN CLASS="keyword">int</SPAN> mem_level          = <SPAN CLASS="omitted">default value</SPAN>, 
143                  <SPAN CLASS="keyword">int</SPAN> strategy           = <SPAN CLASS="omitted">default value</SPAN>,
144                  std::string file_name  = "",
145                  std::string comment    = "",
146                  std::time_t mtime      = 0 );
147
148     std::string  file_name;
149     std::string  comment;
150     std::time_t  mtime;
151 };</PRE>
152
153 <A NAME="gzip_params_constructor"></A>
154 <H4><CODE>gzip_params::gzip_params</CODE></H4>
155
156 <PRE CLASS="broken_ie">    gzip_params( <SPAN CLASS="keyword">int</SPAN> level              = <SPAN CLASS="omitted">default value</SPAN>,
157                  <SPAN CLASS="keyword">int</SPAN> method             = <SPAN CLASS="omitted">default value</SPAN>,
158                  <SPAN CLASS="keyword">int</SPAN> window_bits        = <SPAN CLASS="omitted">default value</SPAN>, 
159                  <SPAN CLASS="keyword">int</SPAN> mem_level          = <SPAN CLASS="omitted">default value</SPAN>, 
160                  <SPAN CLASS="keyword">int</SPAN> strategy           = <SPAN CLASS="omitted">default value</SPAN>,
161                  std::string file_name  = "",
162                  std::string comment    = "",
163                  std::time_t mtime      = 0 );</PRE>
164
165 <P>Constructs a <CODE>gzip_params</CODE> object, where the parameters have the following interpretations:</AP>
166
167 <TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2>
168 <TR>
169     <TR>
170         <TD VALIGN="top"><A NAME="level"></A><I>level</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
171         <TD>Compression level. Must be equal to <CODE>zlib::default_compression</CODE> or a value in the range <CODE>0-9</CODE>. The value <CODE>0</CODE> yields no compression, while <CODE>9</CODE> yields the best compression ratio. Affects compression only.</TD>
172     </TR>
173     <TR>
174         <TD VALIGN="top"><A NAME="method"></A><I>method</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
175         <TD>Compression method. Must equal <A HREF="zlib.html#deflated"><CODE>zlib::deflated</CODE></A>. Affects compression only.</TD>
176     </TR>
177     <TR>
178         <TD VALIGN="top"><A NAME="window_bits"></A><I>window_bits</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
179         <TD>The base two logarithm of the window size. Must be in the range 8-15; defaults to 15.</TD>
180     </TR>
181     <TR>
182         <TD VALIGN="top"><A NAME="mem_level"></A><I>mem_level</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
183         <TD>Specifies the amount of memory to be used. Must be in the range 1-9; defaults to 8. Affects compression only.</TD>
184     </TR>
185     <TR>
186         <TD VALIGN="top"><A NAME="strategy"></A><I>strategy</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
187         <TD>Must be <A HREF="zlib.html#default_strategy"><CODE>zlib::default_strategy</CODE></A>, <A HREF="zlib.html#filtered"><CODE>zlib::filtered</CODE></A> or <A HREF="zlib.html#huffman_only"><CODE>zlib::huffman_only</CODE></A>. Affects compression only. </TD>
188     </TR>
189     <TR>
190         <TD VALIGN="top"><A NAME="file_name"></A><I>file_name</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
191         <TD>Represents the optional section of the G<SPAN STYLE="font-size:80%">ZIP</SPAN> header containing a file name.</TD>
192     </TR>
193     <TR>
194         <TD VALIGN="top"><A NAME="comment"></A><I>comment</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
195         <TD>Represents the optional section of the G<SPAN STYLE="font-size:80%">ZIP</SPAN> header containing a comment.</TD>
196     </TR>
197     <TR>
198         <TD VALIGN="top"><A NAME="mtime"></A><I>mtime</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
199         <TD>Represents the optional section of the G<SPAN STYLE="font-size:80%">ZIP</SPAN> header containing a file modification time.</TD>
200     </TR>
201 </TABLE>
202
203 <P>See <A CLASS="bib_ref" HREF="../bibliography.html#gailly">[Gailly]</A> and <A CLASS="bib_ref" HREF="../bibliography.html#deutsch1">[Deutsch1]</A> for additional details.</P>
204
205 <A NAME="basic_gzip_compressor"></A>
206 <H3>Class template <CODE>basic_gzip_compressor</CODE></H3>
207
208 <H4>Description</H4>
209
210 <P>Model of <A HREF="../concepts/dual_use_filter.html">DualUseFilter</A> which compresses data in the G<SPAN STYLE="font-size:80%">ZIP</SPAN> format (<A CLASS="bib_ref" HREF="../bibliography.html#deutsch3">[Deutsch3]</A>).</P>
211
212 <H4>Synopsis</H4>
213
214 <PRE CLASS="broken_ie"><SPAN CLASS="keyword">template</SPAN>&lt;<SPAN CLASS="keyword">typename</SPAN> <A CLASS="documented" HREF="#basic_gzip_compressor_params">Alloc</A> = std::allocator&lt;<SPAN CLASS="keyword">char</SPAN>&gt; &gt;
215 <SPAN CLASS="keyword">struct</SPAN> <A CLASS="documented" HREF="#basic_gzip_compressor_params">basic_gzip_compressor</A> {
216     <SPAN CLASS="keyword">typedef</SPAN> <SPAN CLASS="keyword">char</SPAN>                    char_type;
217     <SPAN CLASS="keyword">typedef</SPAN> <SPAN CLASS="omitted">implementation-defined</SPAN>  category;
218
219     <A CLASS="documented" HREF="#basic_gzip_compressor_ctors">basic_gzip_compressor</A>( <SPAN CLASS="keyword">const</SPAN> <A CLASS="documented" HREF="#gzip_params">gzip_params</A>& = <SPAN CLASS="omitted">zlib::default_compression</SPAN>, 
220                            std::streamsize buffer_size = <SPAN CLASS="omitted">default value</SPAN> );
221
222     <SPAN CLASS="comment">// DualUseFilter members.</SPAN>
223 };
224
225 <SPAN CLASS="keyword">typedef</SPAN> basic_gzip_compressor<> <SPAN CLASS="defined">gzip_compressor</SPAN>;</PRE>
226
227 <A NAME="basic_gzip_compressor_params"></A>
228 <H4>Template Parameters</H4>
229
230 <TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2>
231 <TR>
232     <TR>
233         <TD VALIGN="top"><I>Alloc</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
234         <TD>A C++ standard library allocator type (<A CLASS="bib_ref" HREF="../bibliography.html#iso">[ISO]</A>, 20.1.5), used to allocate a character buffer and to configure zlib.</TD>
235     </TR>
236 </TABLE>
237
238 <A NAME="basic_gzip_compressor_ctors"></A>
239 <H4><CODE>basic_gzip_compressor::basic_gzip_compressor</CODE></H4>
240
241 <PRE CLASS="broken_ie">    basic_gzip_compressor( <SPAN CLASS="keyword">const</SPAN> gzip_params& = <SPAN CLASS="omitted">zlib::default_compression</SPAN>, 
242                            std::streamsize buffer_size = <SPAN CLASS="omitted">default value</SPAN> );</PRE>
243
244 <P>Constructs an instance of <CODE>basic_gzip_compressor</CODE> with the given parameters and buffer size. Since a <A CLASS="documented" HREF="#gzip_params"><CODE>gzip_params</CODE></A> object is implicitly constructible from an <CODE>int</CODE> representing a compression level, an <CODE>int</CODE> may be passed as the first constructor argument.</P>
245
246 <A NAME="basic_gzip_decompressor"></A>
247 <H3>Class template <CODE>basic_gzip_decompressor</CODE></H3>
248
249 <H4>Description</H4>
250
251 <P>Model of <A HREF="../concepts/dual_use_filter.html">DualUseFilter</A> which decompresses data in the G<SPAN STYLE="font-size:80%">ZIP</SPAN> format (<A CLASS="bib_ref" HREF="../bibliography.html#deutsch3">[Deutsch3]</A>).</P>
252
253 <H4>Synopsis</H4>
254
255 <PRE CLASS="broken_ie"><SPAN CLASS="keyword">template</SPAN>&lt;<SPAN CLASS="keyword">typename</SPAN> <A CLASS="documented" HREF="#basic_gzip_decompressor_params">Alloc</A> = std::allocator&lt;<SPAN CLASS="keyword">char</SPAN>&gt; &gt;
256 <SPAN CLASS="keyword">struct</SPAN> <A CLASS="documented" HREF="#basic_gzip_decompressor_params">basic_gzip_decompressor</A> {
257     <SPAN CLASS="keyword">typedef</SPAN> <SPAN CLASS="keyword">char</SPAN>                    char_type;
258     <SPAN CLASS="keyword">typedef</SPAN> <SPAN CLASS="omitted">implementation-defined</SPAN>  category;
259
260     <A CLASS="documented" HREF="#basic_gzip_decompressor_constructor">basic_gzip_decompressor</A>( <SPAN CLASS="keyword">int</SPAN> window_bits = <SPAN CLASS="omitted">default value</SPAN>, 
261                              std::streamsize buffer_size = 
262                                  <SPAN CLASS="omitted">default value</SPAN> );
263
264     <SPAN CLASS="comment">// DualUseFilter members.</SPAN>
265 };
266
267 <SPAN CLASS="keyword">typedef</SPAN> basic_gzip_decompressor<> <SPAN CLASS="defined">gzip_decompressor</SPAN>;</PRE>
268
269 <A NAME="basic_gzip_decompressor_params"></A>
270 <H4>Template Parameters</H4>
271
272 <TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2>
273 <TR>
274     <TR>
275         <TD VALIGN="top"><I>Alloc</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
276         <TD>A C++ standard library allocator type (<A CLASS="bib_ref" HREF="../bibliography.html#iso">[ISO]</A>, 20.1.5), used to allocate a character buffer and to configure zlib.</TD>
277     </TR>
278 </TABLE>
279
280 <A NAME="basic_gzip_decompressor_constructor"></A>
281 <H4><CODE>basic_gzip_decompressor::basic_gzip_decompressor</CODE></H4>
282
283 <PRE CLASS="broken_ie">    basic_gzip_decompressor( <SPAN CLASS="keyword">int</SPAN> window_bits = <SPAN CLASS="omitted">default value</SPAN>, 
284                              std::streamsize buffer_size = 
285                                  <SPAN CLASS="omitted">default value</SPAN> );</PRE>
286
287 <P>Constructs an instance of <CODE>basic_gzip_decompressor</CODE> with the given <A HREF="#window_bits">window bits</A> value and buffer size. Other parameters affecting decompression are set to default values.</P>
288
289 <A NAME="gzip_error"></A>
290 <H3>Class <CODE>gzip_error</CODE></H3>
291
292 <H4>Description</H4>
293
294 Used by the gzip Filters to report errors.
295
296 <H4>Synopsis</H4>
297
298 <PRE CLASS="broken_ie"><SPAN CLASS="keyword">class</SPAN> <SPAN CLASS="defined">gzip_error</SPAN> : <SPAN CLASS="keyword">public</SPAN> std::ios_base::failure {
299 <SPAN CLASS="keyword">public:</SPAN>
300     <A CLASS="documented" HREF="#gzip_error_constructor">gzip_error</A>(<SPAN CLASS="keyword">int</SPAN> error);
301     <A CLASS="documented" HREF="#gzip_error_constructor">gzip_error</A>(<SPAN CLASS="keyword">const</SPAN> <A CLASS="documented" HREF="zlib.html#zlib_error">zlib_error</A>& e);
302     <SPAN CLASS="keyword">int</SPAN> <A CLASS="documented" HREF="#gzip_error_error">error</A>() <SPAN CLASS="keyword">const</SPAN>;
303     <SPAN CLASS="keyword">int</SPAN> <A CLASS="documented" HREF="#gzip_error_zlib_error_code">zlib_error_code</A>() <SPAN CLASS="keyword">const</SPAN>;
304 };</PRE>
305
306 <A NAME="gzip_error_constructor"></A>
307 <H4><CODE>gzip_error::gzip_error</CODE></H4>
308
309 <PRE CLASS="broken_ie">    gzip_error(<SPAN CLASS="keyword">int</SPAN> error);
310     gzip_error(<SPAN CLASS="keyword">const</SPAN> <A HREF="#zlib_error">zlib_error</A>& e);</PRE>
311
312 <P>The first member constructs an instance of <CODE>gzip_error</CODE> with the given error code from the namespace <A HREF="#constants"><CODE>boost::iostreams::gzip</CODE></A>. The second constructs an instance of <CODE>gzip_error</CODE> based on an instance of <A HREF="zlib.html#zlib_error"><CODE>zlib_error</CODE></A>.</P>
313
314 <A NAME="gzip_error_error"></A>
315 <H4><CODE>gzip_error::error</CODE></H4>
316
317 <PRE CLASS="broken_ie">    <SPAN CLASS="keyword">void</SPAN> error() <SPAN CLASS="keyword">const</SPAN>;</PRE>
318
319 <P>Returns an error code from the namespace <A HREF="#constants"><CODE>boost::iostreams::gzip</CODE></A>.</P>
320
321 <A NAME="gzip_error_zlib_error_code"></A>
322 <PRE CLASS="broken_ie">    <SPAN CLASS="keyword">void</SPAN> zlib_error_code() <SPAN CLASS="keyword">const</SPAN>;</PRE>
323
324 <P>Returns an error code from the namespace <A HREF="zlib.html#constants"><CODE>boost::iostreams::zlib</CODE></A>. Meaningful only if <A HREF="#gzip_error_error"><CODE>error()</CODE></A> returns the constant <A HREF="#constants"><CODE>boost::iostreams::gzip::zlib_error</CODE></A>.</P>
325
326 <A NAME="examples"></A>
327 <H2>Examples</H2>
328
329 The following code decompresses data from a file and writes it to standard output.
330
331 <PRE CLASS="broken_ie"><SPAN CLASS="preprocessor">#include</SPAN> <SPAN CLASS="literal">&lt;fstream&gt;</SPAN>
332 <SPAN CLASS="preprocessor">#include</SPAN> <SPAN CLASS="literal">&lt;iostream&gt;</SPAN>
333 <SPAN CLASS="preprocessor">#include</SPAN> <A CLASS="header" HREF="../../../../boost/iostreams/filtering_streambuf.hpp"><SPAN CLASS="literal">&lt;boost/iostreams/filtering_streambuf.hpp&gt;</SPAN></A>
334 <SPAN CLASS="preprocessor">#include</SPAN> <A CLASS="header" HREF="../../../../boost/iostreams/copy.hpp"><SPAN CLASS="literal">&lt;boost/iostreams/copy.hpp&gt;</SPAN></A>
335 <SPAN CLASS="preprocessor">#include</SPAN> <A CLASS="header" HREF="../../../../boost/iostreams/filter/gzip.hpp"><SPAN CLASS="literal">&lt;boost/iostreams/filter/gzip.hpp&gt;</SPAN></A>
336
337 int main() 
338 {
339     <SPAN CLASS="keyword">using</SPAN> <SPAN CLASS="keyword">namespace</SPAN> std;
340
341     ifstream file(<SPAN CLASS="literal">"hello.gz"</SPAN>, ios_base::in | ios_base::binary);
342     filtering_streambuf&lt;input&gt; in;
343     in.push(gzip_decompressor());
344     in.push(file);
345     boost::iostreams::copy(in, cout);
346 }</PRE>
347
348 <A NAME="installation"></A>
349 <H3>Installation</H3>
350
351 <P>
352      The gzip Filters depend on the third-party zlib library, which is <I>not</I> included in the Boost distribution. Prebuilt zlib binaries are available on most UNIX and UNIX-like systems, and will be found automatically by the Boost build system. Windows users can obtain prebuilt binaries at the <A HREF="http://www.gzip.org/zlib/">zlib homepage</A>. Users can also configure the Boost Iostream library to build zlib from the source code, which is available at the zlib homepage. For details on configuring the build system to find your zlib installation, please see <A HREF="../installation.html">Installation</A>.
353 </P>
354
355 <!-- Adler's obfuscated address is copied from his homepage -->
356
357 <!-- Begin Footer -->
358
359 <HR>
360
361 <P CLASS="copyright">&copy; Copyright 2008 <a href="http://www.coderage.com/" target="_top">CodeRage, LLC</a><br/>&copy; Copyright 2004-2007 <a href="http://www.coderage.com/turkanis/" target="_top">Jonathan Turkanis</a></P>
362 <P CLASS="copyright"> 
363     Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at <A HREF="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)
364 </P>
365
366 <!-- End Footer -->
367
368 </BODY>