]> git.saurik.com Git - wxWidgets.git/blob - include/wx/zstream.h
Script tweaks
[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 size_t GetSize() const { return wxInputStream::GetSize(); }
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();
73
74 void Sync() { DoFlush(false); }
75 size_t GetSize() const { return (size_t)m_pos; }
76
77 static bool CanHandleGZip();
78
79 protected:
80 size_t OnSysWrite(const void *buffer, size_t size);
81 wxFileOffset OnSysTell() const { return m_pos; }
82
83 virtual void DoFlush(bool final);
84
85 protected:
86 size_t m_z_size;
87 unsigned char *m_z_buffer;
88 struct z_stream_s *m_deflate;
89 wxFileOffset m_pos;
90
91 DECLARE_NO_COPY_CLASS(wxZlibOutputStream)
92 };
93
94 #endif
95 // wxUSE_ZLIB && wxUSE_STREAMS
96
97 #endif
98 // _WX_WXZSTREAM_H__
99