]> git.saurik.com Git - wxWidgets.git/blame - include/wx/zstream.h
wxMSWUniv wxWindowMSW vs. wxWindow fix.
[wxWidgets.git] / include / wx / zstream.h
CommitLineData
79c3e0e1
GL
1/////////////////////////////////////////////////////////////////////////////
2// Name: zstream.h
3// Purpose: Memory stream classes
4// Author: Guilhem Lavaux
0915d0b2 5// Modified by: Mike Wetherell
79c3e0e1
GL
6// Created: 11/07/98
7// RCS-ID: $Id$
8// Copyright: (c) Guilhem Lavaux
65571936 9// Licence: wxWindows licence
79c3e0e1 10/////////////////////////////////////////////////////////////////////////////
34138703
JS
11#ifndef _WX_WXZSTREAM_H__
12#define _WX_WXZSTREAM_H__
79c3e0e1 13
12028905 14#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
af49c4b8 15#pragma interface "zstream.h"
79c3e0e1
GL
16#endif
17
124031d5 18#include "wx/defs.h"
ac57418f 19
ce4169a4 20#if wxUSE_ZLIB && wxUSE_STREAMS
ac57418f 21
ed58dbea 22#include "wx/stream.h"
79c3e0e1 23
0915d0b2
VZ
24// Compression level
25enum {
26 wxZ_DEFAULT_COMPRESSION = -1,
27 wxZ_NO_COMPRESSION = 0,
28 wxZ_BEST_SPEED = 1,
29 wxZ_BEST_COMPRESSION = 9
30};
31
32// Flags
33enum {
4c68a102
VS
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
0915d0b2
VZ
41};
42
bddd7a8d 43class WXDLLIMPEXP_BASE wxZlibInputStream: public wxFilterInputStream {
79c3e0e1 44 public:
4c68a102 45 wxZlibInputStream(wxInputStream& stream, int flags = wxZLIB_AUTO);
79c3e0e1
GL
46 virtual ~wxZlibInputStream();
47
0915d0b2 48 char Peek() { return wxInputStream::Peek(); }
588066b7 49 wxFileOffset GetLength() const { return wxInputStream::GetLength(); }
0915d0b2 50
4c68a102
VS
51 static bool CanHandleGZip();
52
79c3e0e1 53 protected:
75ed1d15 54 size_t OnSysRead(void *buffer, size_t size);
4004775e 55 wxFileOffset OnSysTell() const { return m_pos; }
1678ad78
GL
56
57 protected:
79c3e0e1
GL
58 size_t m_z_size;
59 unsigned char *m_z_buffer;
856d2e52 60 struct z_stream_s *m_inflate;
4004775e 61 wxFileOffset m_pos;
4c68a102
VS
62#if WXWIN_COMPATIBILITY_2_4
63 bool m_24compatibilty;
64#endif
22f3361e 65
4c68a102 66 DECLARE_NO_COPY_CLASS(wxZlibInputStream)
79c3e0e1
GL
67};
68
bddd7a8d 69class WXDLLIMPEXP_BASE wxZlibOutputStream: public wxFilterOutputStream {
79c3e0e1 70 public:
301deecc 71 wxZlibOutputStream(wxOutputStream& stream, int level = -1, int flags = wxZLIB_ZLIB);
8f0ff178 72 virtual ~wxZlibOutputStream() { Close(); }
79c3e0e1 73
0915d0b2 74 void Sync() { DoFlush(false); }
8f0ff178 75 bool Close();
588066b7 76 wxFileOffset GetLength() const { return m_pos; }
79c3e0e1 77
4c68a102
VS
78 static bool CanHandleGZip();
79
79c3e0e1 80 protected:
75ed1d15 81 size_t OnSysWrite(const void *buffer, size_t size);
4004775e 82 wxFileOffset OnSysTell() const { return m_pos; }
0915d0b2
VZ
83
84 virtual void DoFlush(bool final);
1678ad78
GL
85
86 protected:
79c3e0e1
GL
87 size_t m_z_size;
88 unsigned char *m_z_buffer;
856d2e52 89 struct z_stream_s *m_deflate;
4004775e 90 wxFileOffset m_pos;
22f3361e 91
4c68a102 92 DECLARE_NO_COPY_CLASS(wxZlibOutputStream)
79c3e0e1
GL
93};
94
95#endif
ce4169a4 96 // wxUSE_ZLIB && wxUSE_STREAMS
ac57418f
RR
97
98#endif
cc985fac
PA
99 // _WX_WXZSTREAM_H__
100