1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Memory stream classes
4 // Author: Guilhem Lavaux
5 // Modified by: Mike Wetherell
8 // Copyright: (c) Guilhem Lavaux
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_WXZSTREAM_H__
12 #define _WX_WXZSTREAM_H__
16 #if wxUSE_ZLIB && wxUSE_STREAMS
18 #include "wx/stream.h"
22 wxZ_DEFAULT_COMPRESSION
= -1,
23 wxZ_NO_COMPRESSION
= 0,
25 wxZ_BEST_COMPRESSION
= 9
30 #if WXWIN_COMPATIBILITY_2_4
31 wxZLIB_24COMPATIBLE
= 4, // read v2.4.x data without error
33 wxZLIB_NO_HEADER
= 0, // raw deflate stream, no header or checksum
34 wxZLIB_ZLIB
= 1, // zlib header and checksum
35 wxZLIB_GZIP
= 2, // gzip header and checksum, requires zlib 1.2.1+
36 wxZLIB_AUTO
= 3 // autodetect header zlib or gzip
39 class WXDLLIMPEXP_BASE wxZlibInputStream
: public wxFilterInputStream
{
41 wxZlibInputStream(wxInputStream
& stream
, int flags
= wxZLIB_AUTO
);
42 virtual ~wxZlibInputStream();
44 char Peek() { return wxInputStream::Peek(); }
45 wxFileOffset
GetLength() const { return wxInputStream::GetLength(); }
47 static bool CanHandleGZip();
50 size_t OnSysRead(void *buffer
, size_t size
);
51 wxFileOffset
OnSysTell() const { return m_pos
; }
55 unsigned char *m_z_buffer
;
56 struct z_stream_s
*m_inflate
;
58 #if WXWIN_COMPATIBILITY_2_4
59 bool m_24compatibilty
;
62 DECLARE_NO_COPY_CLASS(wxZlibInputStream
)
65 class WXDLLIMPEXP_BASE wxZlibOutputStream
: public wxFilterOutputStream
{
67 wxZlibOutputStream(wxOutputStream
& stream
, int level
= -1, int flags
= wxZLIB_ZLIB
);
68 virtual ~wxZlibOutputStream() { Close(); }
70 void Sync() { DoFlush(false); }
72 wxFileOffset
GetLength() const { return m_pos
; }
74 static bool CanHandleGZip();
77 size_t OnSysWrite(const void *buffer
, size_t size
);
78 wxFileOffset
OnSysTell() const { return m_pos
; }
80 virtual void DoFlush(bool final
);
84 unsigned char *m_z_buffer
;
85 struct z_stream_s
*m_deflate
;
88 DECLARE_NO_COPY_CLASS(wxZlibOutputStream
)
92 // wxUSE_ZLIB && wxUSE_STREAMS