]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: zstream.h | |
e54c96f1 | 3 | // Purpose: interface of wxZlibOutputStream |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
e7d0a28b FM |
9 | |
10 | /// Compression level | |
11 | enum wxZlibCompressionLevels { | |
12 | wxZ_DEFAULT_COMPRESSION = -1, | |
13 | wxZ_NO_COMPRESSION = 0, | |
14 | wxZ_BEST_SPEED = 1, | |
15 | wxZ_BEST_COMPRESSION = 9 | |
16 | }; | |
17 | ||
18 | /// Flags | |
19 | enum wxZLibFlags { | |
20 | wxZLIB_NO_HEADER = 0, //!< raw deflate stream, no header or checksum | |
21 | wxZLIB_ZLIB = 1, //!< zlib header and checksum | |
22 | wxZLIB_GZIP = 2, //!< gzip header and checksum, requires zlib 1.2.1+ | |
23 | wxZLIB_AUTO = 3 //!< autodetect header zlib or gzip | |
24 | }; | |
25 | ||
26 | ||
23324ae1 FM |
27 | /** |
28 | @class wxZlibOutputStream | |
7c913512 | 29 | |
e7d0a28b FM |
30 | This stream compresses all data written to it. |
31 | ||
32 | The compressed output can be in zlib or gzip format. | |
23324ae1 FM |
33 | Note that writing the gzip format requires zlib version 1.2.1 or greater |
34 | (the builtin version does support gzip format). | |
7c913512 | 35 | |
e7d0a28b FM |
36 | The stream is not seekable, wxOutputStream::SeekO() returns |
37 | ::wxInvalidOffset. | |
7c913512 | 38 | |
23324ae1 FM |
39 | @library{wxbase} |
40 | @category{streams} | |
7c913512 | 41 | |
e54c96f1 | 42 | @see wxOutputStream, wxZlibInputStream |
23324ae1 FM |
43 | */ |
44 | class wxZlibOutputStream : public wxFilterOutputStream | |
45 | { | |
46 | public: | |
47 | //@{ | |
48 | /** | |
e7d0a28b FM |
49 | Creates a new write-only compressed stream. |
50 | ||
51 | @a level means level of compression. It is number between 0 and 9 | |
52 | (including these values) where 0 means no compression and 9 best but | |
53 | slowest compression. -1 is default value (currently equivalent to 6). | |
54 | ||
23324ae1 FM |
55 | If the parent stream is passed as a pointer then the new filter stream |
56 | takes ownership of it. If it is passed by reference then it does not. | |
e7d0a28b | 57 | |
4cc4bfaf | 58 | The @a flags wxZLIB_ZLIB and wxZLIB_GZIP specify whether the output data |
23324ae1 | 59 | will be in zlib or gzip format. wxZLIB_ZLIB is the default. |
e7d0a28b | 60 | |
4cc4bfaf | 61 | If @a flags is wxZLIB_NO_HEADER, then a raw deflate stream is output |
e7d0a28b FM |
62 | without either zlib or gzip headers. This is a lower level mode, which |
63 | is not usually used directly. It can be used to embed a raw deflate | |
64 | stream in a higher level protocol. | |
65 | ||
66 | The values of the ::wxZlibCompressionLevels and ::wxZLibFlags | |
67 | enumerations can be used. | |
23324ae1 FM |
68 | */ |
69 | wxZlibOutputStream(wxOutputStream& stream, int level = -1, | |
70 | int flags = wxZLIB_ZLIB); | |
7c913512 FM |
71 | wxZlibOutputStream(wxOutputStream* stream, int level = -1, |
72 | int flags = wxZLIB_ZLIB); | |
23324ae1 FM |
73 | //@} |
74 | ||
75 | /** | |
76 | Returns @true if zlib library in use can handle gzip compressed data. | |
77 | */ | |
78 | static bool CanHandleGZip(); | |
79 | }; | |
80 | ||
81 | ||
e54c96f1 | 82 | |
23324ae1 FM |
83 | /** |
84 | @class wxZlibInputStream | |
7c913512 | 85 | |
23324ae1 FM |
86 | This filter stream decompresses a stream that is in zlib or gzip format. |
87 | Note that reading the gzip format requires zlib version 1.2.1 or greater, | |
88 | (the builtin version does support gzip format). | |
7c913512 | 89 | |
e7d0a28b FM |
90 | The stream is not seekable, wxInputStream::SeekI returns ::wxInvalidOffset. |
91 | Also wxStreamBase::GetSize() is not supported, it always returns 0. | |
7c913512 | 92 | |
23324ae1 FM |
93 | @library{wxbase} |
94 | @category{streams} | |
7c913512 | 95 | |
e54c96f1 | 96 | @see wxInputStream, wxZlibOutputStream. |
23324ae1 FM |
97 | */ |
98 | class wxZlibInputStream : public wxFilterInputStream | |
99 | { | |
100 | public: | |
101 | //@{ | |
102 | /** | |
103 | If the parent stream is passed as a pointer then the new filter stream | |
104 | takes ownership of it. If it is passed by reference then it does not. | |
e7d0a28b | 105 | |
4cc4bfaf | 106 | The @a flags wxZLIB_ZLIB and wxZLIB_GZIP specify whether the input data |
23324ae1 FM |
107 | is in zlib or gzip format. If wxZLIB_AUTO is used, then zlib will |
108 | autodetect the stream type, this is the default. | |
e7d0a28b | 109 | |
4cc4bfaf | 110 | If @a flags is wxZLIB_NO_HEADER, then the data is assumed to be a raw |
23324ae1 FM |
111 | deflate stream without either zlib or gzip headers. This is a lower level |
112 | mode, which is not usually used directly. It can be used to read a raw | |
113 | deflate stream embedded in a higher level protocol. | |
e7d0a28b FM |
114 | |
115 | The values of the ::wxZLibFlags enumeration can be used. | |
23324ae1 FM |
116 | */ |
117 | wxZlibInputStream(wxInputStream& stream, int flags = wxZLIB_AUTO); | |
e7d0a28b | 118 | wxZlibInputStream(wxInputStream* stream, int flags = wxZLIB_AUTO); |
23324ae1 FM |
119 | //@} |
120 | ||
121 | /** | |
122 | Returns @true if zlib library in use can handle gzip compressed data. | |
123 | */ | |
124 | static bool CanHandleGZip(); | |
125 | }; | |
e54c96f1 | 126 |