]> git.saurik.com Git - wxWidgets.git/blame - include/wx/zstream.h
Applied modified 3-state checkbox patch from Mathew Cucuzella
[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
9// Licence: wxWindows licence
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 {
abc11600
RN
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+
0915d0b2
VZ
37};
38
bddd7a8d 39class WXDLLIMPEXP_BASE wxZlibInputStream: public wxFilterInputStream {
79c3e0e1 40 public:
301deecc 41 wxZlibInputStream(wxInputStream& stream, int flags = wxZLIB_ZLIB | wxZLIB_GZIP);
79c3e0e1
GL
42 virtual ~wxZlibInputStream();
43
0915d0b2
VZ
44 char Peek() { return wxInputStream::Peek(); }
45 size_t GetSize() const { return wxInputStream::GetSize(); }
46
79c3e0e1 47 protected:
75ed1d15 48 size_t OnSysRead(void *buffer, size_t size);
0915d0b2 49 off_t OnSysTell() const { return m_pos; }
1678ad78
GL
50
51 protected:
79c3e0e1
GL
52 size_t m_z_size;
53 unsigned char *m_z_buffer;
856d2e52 54 struct z_stream_s *m_inflate;
0915d0b2 55 off_t m_pos;
22f3361e
VZ
56
57 DECLARE_NO_COPY_CLASS(wxZlibInputStream)
79c3e0e1
GL
58};
59
bddd7a8d 60class WXDLLIMPEXP_BASE wxZlibOutputStream: public wxFilterOutputStream {
79c3e0e1 61 public:
301deecc 62 wxZlibOutputStream(wxOutputStream& stream, int level = -1, int flags = wxZLIB_ZLIB);
79c3e0e1
GL
63 virtual ~wxZlibOutputStream();
64
0915d0b2
VZ
65 void Sync() { DoFlush(false); }
66 size_t GetSize() const { return (size_t)m_pos; }
79c3e0e1 67
79c3e0e1 68 protected:
75ed1d15 69 size_t OnSysWrite(const void *buffer, size_t size);
0915d0b2
VZ
70 off_t OnSysTell() const { return m_pos; }
71
72 virtual void DoFlush(bool final);
1678ad78
GL
73
74 protected:
79c3e0e1
GL
75 size_t m_z_size;
76 unsigned char *m_z_buffer;
856d2e52 77 struct z_stream_s *m_deflate;
0915d0b2 78 off_t m_pos;
22f3361e
VZ
79
80 DECLARE_NO_COPY_CLASS(wxZlibOutputStream)
79c3e0e1
GL
81};
82
83#endif
ce4169a4 84 // wxUSE_ZLIB && wxUSE_STREAMS
ac57418f
RR
85
86#endif
cc985fac
PA
87 // _WX_WXZSTREAM_H__
88