]> git.saurik.com Git - wxWidgets.git/blame - include/wx/zstream.h
Minor corrections to make dist after reports
[wxWidgets.git] / include / wx / zstream.h
CommitLineData
79c3e0e1 1/////////////////////////////////////////////////////////////////////////////
ce7208d4 2// Name: wx/zstream.h
79c3e0e1
GL
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
124031d5 14#include "wx/defs.h"
ac57418f 15
ce4169a4 16#if wxUSE_ZLIB && wxUSE_STREAMS
ac57418f 17
ed58dbea 18#include "wx/stream.h"
79c3e0e1 19
0915d0b2
VZ
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 {
4c68a102
VS
30 wxZLIB_NO_HEADER = 0, // raw deflate stream, no header or checksum
31 wxZLIB_ZLIB = 1, // zlib header and checksum
32 wxZLIB_GZIP = 2, // gzip header and checksum, requires zlib 1.2.1+
33 wxZLIB_AUTO = 3 // autodetect header zlib or gzip
0915d0b2
VZ
34};
35
bddd7a8d 36class WXDLLIMPEXP_BASE wxZlibInputStream: public wxFilterInputStream {
79c3e0e1 37 public:
4c68a102 38 wxZlibInputStream(wxInputStream& stream, int flags = wxZLIB_AUTO);
55420742 39 wxZlibInputStream(wxInputStream *stream, int flags = wxZLIB_AUTO);
79c3e0e1
GL
40 virtual ~wxZlibInputStream();
41
0915d0b2 42 char Peek() { return wxInputStream::Peek(); }
588066b7 43 wxFileOffset GetLength() const { return wxInputStream::GetLength(); }
0915d0b2 44
4c68a102
VS
45 static bool CanHandleGZip();
46
79c3e0e1 47 protected:
75ed1d15 48 size_t OnSysRead(void *buffer, size_t size);
4004775e 49 wxFileOffset OnSysTell() const { return m_pos; }
1678ad78 50
55420742
MW
51 private:
52 void Init(int flags);
53
1678ad78 54 protected:
79c3e0e1
GL
55 size_t m_z_size;
56 unsigned char *m_z_buffer;
856d2e52 57 struct z_stream_s *m_inflate;
4004775e 58 wxFileOffset m_pos;
22f3361e 59
4c68a102 60 DECLARE_NO_COPY_CLASS(wxZlibInputStream)
79c3e0e1
GL
61};
62
bddd7a8d 63class WXDLLIMPEXP_BASE wxZlibOutputStream: public wxFilterOutputStream {
79c3e0e1 64 public:
301deecc 65 wxZlibOutputStream(wxOutputStream& stream, int level = -1, int flags = wxZLIB_ZLIB);
55420742 66 wxZlibOutputStream(wxOutputStream *stream, int level = -1, int flags = wxZLIB_ZLIB);
8f0ff178 67 virtual ~wxZlibOutputStream() { Close(); }
79c3e0e1 68
0915d0b2 69 void Sync() { DoFlush(false); }
8f0ff178 70 bool Close();
588066b7 71 wxFileOffset GetLength() const { return m_pos; }
79c3e0e1 72
4c68a102
VS
73 static bool CanHandleGZip();
74
79c3e0e1 75 protected:
75ed1d15 76 size_t OnSysWrite(const void *buffer, size_t size);
4004775e 77 wxFileOffset OnSysTell() const { return m_pos; }
0915d0b2
VZ
78
79 virtual void DoFlush(bool final);
1678ad78 80
55420742
MW
81 private:
82 void Init(int level, int flags);
83
1678ad78 84 protected:
79c3e0e1
GL
85 size_t m_z_size;
86 unsigned char *m_z_buffer;
856d2e52 87 struct z_stream_s *m_deflate;
4004775e 88 wxFileOffset m_pos;
22f3361e 89
4c68a102 90 DECLARE_NO_COPY_CLASS(wxZlibOutputStream)
79c3e0e1
GL
91};
92
55420742
MW
93class WXDLLIMPEXP_BASE wxZlibClassFactory: public wxFilterClassFactory
94{
95public:
96 wxZlibClassFactory();
97
98 wxFilterInputStream *NewStream(wxInputStream& stream) const
99 { return new wxZlibInputStream(stream); }
100 wxFilterOutputStream *NewStream(wxOutputStream& stream) const
101 { return new wxZlibOutputStream(stream, -1); }
102 wxFilterInputStream *NewStream(wxInputStream *stream) const
103 { return new wxZlibInputStream(stream); }
104 wxFilterOutputStream *NewStream(wxOutputStream *stream) const
105 { return new wxZlibOutputStream(stream, -1); }
106
107 const wxChar * const *GetProtocols(wxStreamProtocolType type
108 = wxSTREAM_PROTOCOL) const;
109
110private:
111 DECLARE_DYNAMIC_CLASS(wxZlibClassFactory)
112};
113
114class WXDLLIMPEXP_BASE wxGzipClassFactory: public wxFilterClassFactory
115{
116public:
117 wxGzipClassFactory();
118
119 wxFilterInputStream *NewStream(wxInputStream& stream) const
120 { return new wxZlibInputStream(stream); }
121 wxFilterOutputStream *NewStream(wxOutputStream& stream) const
122 { return new wxZlibOutputStream(stream, -1); }
123 wxFilterInputStream *NewStream(wxInputStream *stream) const
124 { return new wxZlibInputStream(stream); }
125 wxFilterOutputStream *NewStream(wxOutputStream *stream) const
126 { return new wxZlibOutputStream(stream, -1); }
127
128 const wxChar * const *GetProtocols(wxStreamProtocolType type
129 = wxSTREAM_PROTOCOL) const;
130
131private:
132 DECLARE_DYNAMIC_CLASS(wxGzipClassFactory)
133};
134
79c3e0e1 135#endif
ce4169a4 136 // wxUSE_ZLIB && wxUSE_STREAMS
ac57418f
RR
137
138#endif
cc985fac
PA
139 // _WX_WXZSTREAM_H__
140