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 wxZLIB_NO_HEADER
= 0, // raw deflate stream, no header or checksum
35 wxZLIB_ZLIB
= 1, // zlib header and checksum
36 wxZLIB_GZIP
= 2 // gzip header and checksum, requires zlib 1.2+
39 class WXDLLIMPEXP_BASE wxZlibInputStream
: public wxFilterInputStream
{
41 wxZlibInputStream(wxInputStream
& stream
, int flags
= wxZLIB_ZLIB
| wxZLIB_GZIP
);
42 virtual ~wxZlibInputStream();
44 char Peek() { return wxInputStream::Peek(); }
45 size_t GetSize() const { return wxInputStream::GetSize(); }
48 size_t OnSysRead(void *buffer
, size_t size
);
49 off_t
OnSysTell() const { return m_pos
; }
53 unsigned char *m_z_buffer
;
54 struct z_stream_s
*m_inflate
;
57 DECLARE_NO_COPY_CLASS(wxZlibInputStream
)
60 class WXDLLIMPEXP_BASE wxZlibOutputStream
: public wxFilterOutputStream
{
62 wxZlibOutputStream(wxOutputStream
& stream
, int level
= -1, int flags
= wxZLIB_ZLIB
);
63 virtual ~wxZlibOutputStream();
65 void Sync() { DoFlush(false); }
66 size_t GetSize() const { return (size_t)m_pos
; }
69 size_t OnSysWrite(const void *buffer
, size_t size
);
70 off_t
OnSysTell() const { return m_pos
; }
72 virtual void DoFlush(bool final
);
76 unsigned char *m_z_buffer
;
77 struct z_stream_s
*m_deflate
;
80 DECLARE_NO_COPY_CLASS(wxZlibOutputStream
)
84 // wxUSE_ZLIB && wxUSE_STREAMS