]> git.saurik.com Git - wxWidgets.git/blame - include/wx/zstream.h
Source cleaning: whitespaces, tabs, -1/wxID_ANY/wxDefaultCoord, TRUE/true, FALSE...
[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
VZ
48 char Peek() { return wxInputStream::Peek(); }
49 size_t GetSize() const { return wxInputStream::GetSize(); }
50
4c68a102
VS
51 static bool CanHandleGZip();
52
79c3e0e1 53 protected:
75ed1d15 54 size_t OnSysRead(void *buffer, size_t size);
0915d0b2 55 off_t 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;
0915d0b2 61 off_t 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);
79c3e0e1
GL
72 virtual ~wxZlibOutputStream();
73
0915d0b2
VZ
74 void Sync() { DoFlush(false); }
75 size_t GetSize() const { return (size_t)m_pos; }
79c3e0e1 76
4c68a102
VS
77 static bool CanHandleGZip();
78
79c3e0e1 79 protected:
75ed1d15 80 size_t OnSysWrite(const void *buffer, size_t size);
0915d0b2
VZ
81 off_t OnSysTell() const { return m_pos; }
82
83 virtual void DoFlush(bool final);
1678ad78
GL
84
85 protected:
79c3e0e1
GL
86 size_t m_z_size;
87 unsigned char *m_z_buffer;
856d2e52 88 struct z_stream_s *m_deflate;
0915d0b2 89 off_t m_pos;
22f3361e 90
4c68a102 91 DECLARE_NO_COPY_CLASS(wxZlibOutputStream)
79c3e0e1
GL
92};
93
94#endif
ce4169a4 95 // wxUSE_ZLIB && wxUSE_STREAMS
ac57418f
RR
96
97#endif
cc985fac
PA
98 // _WX_WXZSTREAM_H__
99