]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/zstream.h
made wxHtmlWindow::SetPage virtual so that the behaviour can be customized
[wxWidgets.git] / include / wx / zstream.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: zstream.h
3// Purpose: Memory stream classes
4// Author: Guilhem Lavaux
5// Modified by: Mike Wetherell
6// Created: 11/07/98
7// RCS-ID: $Id$
8// Copyright: (c) Guilhem Lavaux
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11#ifndef _WX_WXZSTREAM_H__
12#define _WX_WXZSTREAM_H__
13
14#include "wx/defs.h"
15
16#if wxUSE_ZLIB && wxUSE_STREAMS
17
18#include "wx/stream.h"
19
20// Compression level
21enum {
22 wxZ_DEFAULT_COMPRESSION = -1,
23 wxZ_NO_COMPRESSION = 0,
24 wxZ_BEST_SPEED = 1,
25 wxZ_BEST_COMPRESSION = 9
26};
27
28// Flags
29enum {
30#if WXWIN_COMPATIBILITY_2_4
31 wxZLIB_24COMPATIBLE = 4, // read v2.4.x data without error
32#endif
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
37};
38
39class WXDLLIMPEXP_BASE wxZlibInputStream: public wxFilterInputStream {
40 public:
41 wxZlibInputStream(wxInputStream& stream, int flags = wxZLIB_AUTO);
42 virtual ~wxZlibInputStream();
43
44 char Peek() { return wxInputStream::Peek(); }
45 wxFileOffset GetLength() const { return wxInputStream::GetLength(); }
46
47 static bool CanHandleGZip();
48
49 protected:
50 size_t OnSysRead(void *buffer, size_t size);
51 wxFileOffset OnSysTell() const { return m_pos; }
52
53 protected:
54 size_t m_z_size;
55 unsigned char *m_z_buffer;
56 struct z_stream_s *m_inflate;
57 wxFileOffset m_pos;
58#if WXWIN_COMPATIBILITY_2_4
59 bool m_24compatibilty;
60#endif
61
62 DECLARE_NO_COPY_CLASS(wxZlibInputStream)
63};
64
65class WXDLLIMPEXP_BASE wxZlibOutputStream: public wxFilterOutputStream {
66 public:
67 wxZlibOutputStream(wxOutputStream& stream, int level = -1, int flags = wxZLIB_ZLIB);
68 virtual ~wxZlibOutputStream() { Close(); }
69
70 void Sync() { DoFlush(false); }
71 bool Close();
72 wxFileOffset GetLength() const { return m_pos; }
73
74 static bool CanHandleGZip();
75
76 protected:
77 size_t OnSysWrite(const void *buffer, size_t size);
78 wxFileOffset OnSysTell() const { return m_pos; }
79
80 virtual void DoFlush(bool final);
81
82 protected:
83 size_t m_z_size;
84 unsigned char *m_z_buffer;
85 struct z_stream_s *m_deflate;
86 wxFileOffset m_pos;
87
88 DECLARE_NO_COPY_CLASS(wxZlibOutputStream)
89};
90
91#endif
92 // wxUSE_ZLIB && wxUSE_STREAMS
93
94#endif
95 // _WX_WXZSTREAM_H__
96