]> git.saurik.com Git - wxWidgets.git/blob - include/wx/zstream.h
don't use numbers in URLs if truncateFilenames=no
[wxWidgets.git] / include / wx / zstream.h
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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
15 #pragma interface "zstream.h"
16 #endif
17
18 #include "wx/defs.h"
19
20 #if wxUSE_ZLIB && wxUSE_STREAMS
21
22 #include "wx/stream.h"
23
24 // Compression level
25 enum {
26 wxZ_DEFAULT_COMPRESSION = -1,
27 wxZ_NO_COMPRESSION = 0,
28 wxZ_BEST_SPEED = 1,
29 wxZ_BEST_COMPRESSION = 9
30 };
31
32 // Flags
33 enum {
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+
37 };
38
39 class WXDLLIMPEXP_BASE wxZlibInputStream: public wxFilterInputStream {
40 public:
41 wxZlibInputStream(wxInputStream& stream, int flags = wxZLIB_ZLIB | wxZLIB_GZIP);
42 virtual ~wxZlibInputStream();
43
44 char Peek() { return wxInputStream::Peek(); }
45 size_t GetSize() const { return wxInputStream::GetSize(); }
46
47 protected:
48 size_t OnSysRead(void *buffer, size_t size);
49 off_t OnSysTell() const { return m_pos; }
50
51 protected:
52 size_t m_z_size;
53 unsigned char *m_z_buffer;
54 struct z_stream_s *m_inflate;
55 off_t m_pos;
56
57 DECLARE_NO_COPY_CLASS(wxZlibInputStream)
58 };
59
60 class WXDLLIMPEXP_BASE wxZlibOutputStream: public wxFilterOutputStream {
61 public:
62 wxZlibOutputStream(wxOutputStream& stream, int level = -1, int flags = wxZLIB_ZLIB);
63 virtual ~wxZlibOutputStream();
64
65 void Sync() { DoFlush(false); }
66 size_t GetSize() const { return (size_t)m_pos; }
67
68 protected:
69 size_t OnSysWrite(const void *buffer, size_t size);
70 off_t OnSysTell() const { return m_pos; }
71
72 virtual void DoFlush(bool final);
73
74 protected:
75 size_t m_z_size;
76 unsigned char *m_z_buffer;
77 struct z_stream_s *m_deflate;
78 off_t m_pos;
79
80 DECLARE_NO_COPY_CLASS(wxZlibOutputStream)
81 };
82
83 #endif
84 // wxUSE_ZLIB && wxUSE_STREAMS
85
86 #endif
87 // _WX_WXZSTREAM_H__
88