File: zstream.h

package info (click to toggle)
wxwidgets3.0 3.0.5.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 120,464 kB
  • sloc: cpp: 896,633; makefile: 52,303; ansic: 21,971; sh: 5,713; python: 2,940; xml: 1,534; perl: 264; javascript: 33
file content (151 lines) | stat: -rw-r--r-- 5,224 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/////////////////////////////////////////////////////////////////////////////
// Name:        zstream.h
// Purpose:     interface of wxZlibOutputStream
// Author:      wxWidgets team
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////


/// Compression level
enum wxZlibCompressionLevels {
    wxZ_DEFAULT_COMPRESSION = -1,
    wxZ_NO_COMPRESSION = 0,
    wxZ_BEST_SPEED = 1,
    wxZ_BEST_COMPRESSION = 9
};

/// Flags
enum wxZLibFlags {
    wxZLIB_NO_HEADER = 0,    //!< raw deflate stream, no header or checksum
    wxZLIB_ZLIB = 1,         //!< zlib header and checksum
    wxZLIB_GZIP = 2,         //!< gzip header and checksum, requires zlib 1.2.1+
    wxZLIB_AUTO = 3          //!< autodetect header zlib or gzip
};


/**
    @class wxZlibOutputStream

    This stream compresses all data written to it.

    The compressed output can be in zlib or gzip format.
    Note that writing the gzip format requires zlib version 1.2.1 or greater
    (the builtin version does support gzip format).

    The stream is not seekable, wxOutputStream::SeekO() returns
    ::wxInvalidOffset.

    @library{wxbase}
    @category{archive,streams}

    @see wxOutputStream, wxZlibInputStream
*/
class wxZlibOutputStream : public wxFilterOutputStream
{
public:
    //@{
    /**
        Creates a new write-only compressed stream.

        @a level means level of compression. It is number between 0 and 9
        (including these values) where 0 means no compression and 9 best but
        slowest compression. -1 is default value (currently equivalent to 6).

        If the parent stream is passed as a pointer then the new filter stream
        takes ownership of it. If it is passed by reference then it does not.

        The @a flags wxZLIB_ZLIB and wxZLIB_GZIP specify whether the output data
        will be in zlib or gzip format. wxZLIB_ZLIB is the default.

        If @a flags is wxZLIB_NO_HEADER, then a raw deflate stream is output
        without either zlib or gzip headers. This is a lower level mode, which
        is not usually used directly. It can be used to embed a raw deflate
        stream in a higher level protocol.

        The values of the ::wxZlibCompressionLevels and ::wxZLibFlags
        enumerations can be used.
    */
    wxZlibOutputStream(wxOutputStream& stream, int level = -1,
                       int flags = wxZLIB_ZLIB);
    wxZlibOutputStream(wxOutputStream* stream, int level = -1,
                       int flags = wxZLIB_ZLIB);
    //@}

    /**
        Returns @true if zlib library in use can handle gzip compressed data.
    */
    static bool CanHandleGZip();

    //@{
    /**
        Sets the dictionary to the specified chunk of data. This can improve
        compression rate but note that the dictionary has to be the same when
        you deflate the data as when you inflate the data, otherwise you
        will inflate corrupted data.

        Returns @true if the dictionary was successfully set.
    */
    bool SetDictionary(const char *data, const size_t datalen);
    bool SetDictionary(const wxMemoryBuffer &buf);
    //@}
};



/**
    @class wxZlibInputStream

    This filter stream decompresses a stream that is in zlib or gzip format.
    Note that reading the gzip format requires zlib version 1.2.1 or greater,
    (the builtin version does support gzip format).

    The stream is not seekable, wxInputStream::SeekI returns ::wxInvalidOffset.
    Also wxStreamBase::GetSize() is not supported, it always returns 0.

    @library{wxbase}
    @category{archive,streams}

    @see wxInputStream, wxZlibOutputStream.
*/
class wxZlibInputStream : public wxFilterInputStream
{
public:
    //@{
    /**
        If the parent stream is passed as a pointer then the new filter stream
        takes ownership of it. If it is passed by reference then it does not.

        The @a flags wxZLIB_ZLIB and wxZLIB_GZIP specify whether the input data
        is in zlib or gzip format. If wxZLIB_AUTO is used, then zlib will
        autodetect the stream type, this is the default.

        If @a flags is wxZLIB_NO_HEADER, then the data is assumed to be a raw
        deflate stream without either zlib or gzip headers. This is a lower level
        mode, which is not usually used directly. It can be used to read a raw
        deflate stream embedded in a higher level protocol.

        The values of the ::wxZLibFlags enumeration can be used.
    */
    wxZlibInputStream(wxInputStream& stream, int flags = wxZLIB_AUTO);
    wxZlibInputStream(wxInputStream* stream, int flags = wxZLIB_AUTO);
    //@}

    /**
        Returns @true if zlib library in use can handle gzip compressed data.
    */
    static bool CanHandleGZip();

    //@{
    /**
        Sets the dictionary to the specified chunk of data. This can improve
        compression rate but note that the dictionary has to be the same when
        you deflate the data as when you inflate the data, otherwise you
        will inflate corrupted data.

        Returns @true if the dictionary was successfully set.
    */
    bool SetDictionary(const char *data, const size_t datalen);
    bool SetDictionary(const wxMemoryBuffer &buf);
    //@}
};