2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: zstream.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxZlibOutputStream
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-09-27 06:59:01 -04:00
|
|
|
|
|
|
|
/// 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
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxZlibOutputStream
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-27 06:59:01 -04:00
|
|
|
This stream compresses all data written to it.
|
|
|
|
|
|
|
|
The compressed output can be in zlib or gzip format.
|
2008-03-08 08:52:38 -05:00
|
|
|
Note that writing the gzip format requires zlib version 1.2.1 or greater
|
|
|
|
(the builtin version does support gzip format).
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-27 06:59:01 -04:00
|
|
|
The stream is not seekable, wxOutputStream::SeekO() returns
|
|
|
|
::wxInvalidOffset.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxbase}
|
|
|
|
@category{streams}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxOutputStream, wxZlibInputStream
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxZlibOutputStream : public wxFilterOutputStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//@{
|
|
|
|
/**
|
2008-09-27 06:59:01 -04:00
|
|
|
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).
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
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.
|
2008-09-27 06:59:01 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
The @a flags wxZLIB_ZLIB and wxZLIB_GZIP specify whether the output data
|
2008-03-08 08:52:38 -05:00
|
|
|
will be in zlib or gzip format. wxZLIB_ZLIB is the default.
|
2008-09-27 06:59:01 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
If @a flags is wxZLIB_NO_HEADER, then a raw deflate stream is output
|
2008-09-27 06:59:01 -04:00
|
|
|
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.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxZlibOutputStream(wxOutputStream& stream, int level = -1,
|
|
|
|
int flags = wxZLIB_ZLIB);
|
2008-03-08 09:43:31 -05:00
|
|
|
wxZlibOutputStream(wxOutputStream* stream, int level = -1,
|
|
|
|
int flags = wxZLIB_ZLIB);
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if zlib library in use can handle gzip compressed data.
|
|
|
|
*/
|
|
|
|
static bool CanHandleGZip();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxZlibInputStream
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
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).
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-27 06:59:01 -04:00
|
|
|
The stream is not seekable, wxInputStream::SeekI returns ::wxInvalidOffset.
|
|
|
|
Also wxStreamBase::GetSize() is not supported, it always returns 0.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxbase}
|
|
|
|
@category{streams}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxInputStream, wxZlibOutputStream.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
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.
|
2008-09-27 06:59:01 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
The @a flags wxZLIB_ZLIB and wxZLIB_GZIP specify whether the input data
|
2008-03-08 08:52:38 -05:00
|
|
|
is in zlib or gzip format. If wxZLIB_AUTO is used, then zlib will
|
|
|
|
autodetect the stream type, this is the default.
|
2008-09-27 06:59:01 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
If @a flags is wxZLIB_NO_HEADER, then the data is assumed to be a raw
|
2008-03-08 08:52:38 -05:00
|
|
|
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.
|
2008-09-27 06:59:01 -04:00
|
|
|
|
|
|
|
The values of the ::wxZLibFlags enumeration can be used.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxZlibInputStream(wxInputStream& stream, int flags = wxZLIB_AUTO);
|
2008-09-27 06:59:01 -04:00
|
|
|
wxZlibInputStream(wxInputStream* stream, int flags = wxZLIB_AUTO);
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if zlib library in use can handle gzip compressed data.
|
|
|
|
*/
|
|
|
|
static bool CanHandleGZip();
|
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|