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__
14 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
15 #pragma interface "zstream.h"
20 #if wxUSE_ZLIB && wxUSE_STREAMS
22 #include "wx/stream.h"
26 wxZ_DEFAULT_COMPRESSION
= -1,
27 wxZ_NO_COMPRESSION
= 0,
29 wxZ_BEST_COMPRESSION
= 9
34 #if WXWIN_COMPATIBILITY_2_4
35 wxZLIB_24COMPATIBLE
= 4, // read v2.4.x data without error
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
43 class WXDLLIMPEXP_BASE wxZlibInputStream
: public wxFilterInputStream
{
45 wxZlibInputStream(wxInputStream
& stream
, int flags
= wxZLIB_AUTO
);
46 virtual ~wxZlibInputStream();
48 char Peek() { return wxInputStream::Peek(); }
49 wxFileOffset
GetLength() const { return wxInputStream::GetLength(); }
51 static bool CanHandleGZip();
54 size_t OnSysRead(void *buffer
, size_t size
);
55 wxFileOffset
OnSysTell() const { return m_pos
; }
59 unsigned char *m_z_buffer
;
60 struct z_stream_s
*m_inflate
;
62 #if WXWIN_COMPATIBILITY_2_4
63 bool m_24compatibilty
;
66 DECLARE_NO_COPY_CLASS(wxZlibInputStream
)
69 class WXDLLIMPEXP_BASE wxZlibOutputStream
: public wxFilterOutputStream
{
71 wxZlibOutputStream(wxOutputStream
& stream
, int level
= -1, int flags
= wxZLIB_ZLIB
);
72 virtual ~wxZlibOutputStream() { Close(); }
74 void Sync() { DoFlush(false); }
76 wxFileOffset
GetLength() const { return m_pos
; }
78 static bool CanHandleGZip();
81 size_t OnSysWrite(const void *buffer
, size_t size
);
82 wxFileOffset
OnSysTell() const { return m_pos
; }
84 virtual void DoFlush(bool final
);
88 unsigned char *m_z_buffer
;
89 struct z_stream_s
*m_deflate
;
92 DECLARE_NO_COPY_CLASS(wxZlibOutputStream
)
96 // wxUSE_ZLIB && wxUSE_STREAMS