]> git.saurik.com Git - wxWidgets.git/blob - include/wx/zstream.h
Make list consistent with tree in terms of Vetoed changes closing the inline edit...
[wxWidgets.git] / include / wx / zstream.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: zstream.h
3 // Purpose: Memory stream classes
4 // Author: Guilhem Lavaux
5 // Modified by: Mike Wetherell
6 // Created: 11/07/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Guilhem Lavaux
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_WXZSTREAM_H__
12 #define _WX_WXZSTREAM_H__
13
14 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
15 #pragma interface "zstream.h"
16 #endif
17
18 #include "wx/defs.h"
19
20 #if wxUSE_ZLIB && wxUSE_STREAMS
21
22 #include "wx/stream.h"
23
24 // Compression level
25 enum {
26 wxZ_DEFAULT_COMPRESSION = -1,
27 wxZ_NO_COMPRESSION = 0,
28 wxZ_BEST_SPEED = 1,
29 wxZ_BEST_COMPRESSION = 9
30 };
31
32 // Flags
33 enum {
34 #if WXWIN_COMPATIBILITY_2_4
35 wxZLIB_24COMPATIBLE = 4, // read v2.4.x data without error
36 #endif
37 wxZLIB_NO_HEADER = 0, // raw deflate stream, no header or checksum
38 wxZLIB_ZLIB = 1, // zlib header and checksum
39 wxZLIB_GZIP = 2, // gzip header and checksum, requires zlib 1.2.1+
40 wxZLIB_AUTO = 3 // autodetect header zlib or gzip
41 };
42
43 class WXDLLIMPEXP_BASE wxZlibInputStream: public wxFilterInputStream {
44 public:
45 wxZlibInputStream(wxInputStream& stream, int flags = wxZLIB_AUTO);
46 virtual ~wxZlibInputStream();
47
48 char Peek() { return wxInputStream::Peek(); }
49 wxFileOffset GetLength() const { return wxInputStream::GetLength(); }
50
51 static bool CanHandleGZip();
52
53 protected:
54 size_t OnSysRead(void *buffer, size_t size);
55 wxFileOffset OnSysTell() const { return m_pos; }
56
57 protected:
58 size_t m_z_size;
59 unsigned char *m_z_buffer;
60 struct z_stream_s *m_inflate;
61 wxFileOffset m_pos;
62 #if WXWIN_COMPATIBILITY_2_4
63 bool m_24compatibilty;
64 #endif
65
66 DECLARE_NO_COPY_CLASS(wxZlibInputStream)
67 };
68
69 class WXDLLIMPEXP_BASE wxZlibOutputStream: public wxFilterOutputStream {
70 public:
71 wxZlibOutputStream(wxOutputStream& stream, int level = -1, int flags = wxZLIB_ZLIB);
72 virtual ~wxZlibOutputStream() { Close(); }
73
74 void Sync() { DoFlush(false); }
75 bool Close();
76 wxFileOffset GetLength() const { return m_pos; }
77
78 static bool CanHandleGZip();
79
80 protected:
81 size_t OnSysWrite(const void *buffer, size_t size);
82 wxFileOffset OnSysTell() const { return m_pos; }
83
84 virtual void DoFlush(bool final);
85
86 protected:
87 size_t m_z_size;
88 unsigned char *m_z_buffer;
89 struct z_stream_s *m_deflate;
90 wxFileOffset m_pos;
91
92 DECLARE_NO_COPY_CLASS(wxZlibOutputStream)
93 };
94
95 #endif
96 // wxUSE_ZLIB && wxUSE_STREAMS
97
98 #endif
99 // _WX_WXZSTREAM_H__
100