wxWidgets: wxZlibOutputStream Class Reference

| Version: 3.2.2

Static Public Member Functions | List of all members
wxZlibOutputStream Class Reference
Class List by Category » Archive support | Class List by Category » Streams

`#include <wx/zstream.h>`

Inheritance diagram for wxZlibOutputStream:
[legend]

## Detailed Description

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 support, Streams

See also
  wxOutputStream, wxZlibInputStream

## Public Member Functions
| wxZlibOutputStream (wxOutputStream &stream, int level=-1, int flags=wxZLIB_ZLIB)
| Creates a new write-only compressed stream. More...
| wxZlibOutputStream (wxOutputStream *stream, int level=-1, int flags=wxZLIB_ZLIB)
| Creates a new write-only compressed stream. More...
bool | SetDictionary (const char *data, size_t datalen)
| Sets the dictionary to the specified chunk of data. More...
bool | SetDictionary (const wxMemoryBuffer &buf)
| Sets the dictionary to the specified chunk of data. More...
Public Member Functions inherited from wxFilterOutputStream
| wxFilterOutputStream (wxOutputStream &stream)
| Initializes a "filter" stream. More...
| wxFilterOutputStream (wxOutputStream *stream)
| Initializes a "filter" stream. More...
Public Member Functions inherited from wxOutputStream
| wxOutputStream ()
| Creates a dummy wxOutputStream object. More...
virtual | ~wxOutputStream ()
| Destructor. More...
virtual bool | Close ()
| Closes the stream, returning false if an error occurs. More...
virtual size_t | LastWrite () const
| Returns the number of bytes written during the last Write(). More...
void | PutC (char c)
| Puts the specified character in the output queue and increments the stream position. More...
virtual wxFileOffset | SeekO (wxFileOffset pos, wxSeekMode mode=wxFromStart)
| Changes the stream current position. More...
virtual wxFileOffset | TellO () const
| Returns the current stream position. More...
virtual wxOutputStream & | Write (const void *buffer, size_t size)
| Writes up to the specified amount of bytes using the data of buffer. More...
wxOutputStream & | Write (wxInputStream &stream_in)
| Reads data from the specified input stream and stores them in the current stream. More...
bool | WriteAll (const void *buffer, size_t size)
| Writes exactly the specified number of bytes from the buffer. More...
Public Member Functions inherited from wxStreamBase
| wxStreamBase ()
| Creates a dummy stream object. More...
virtual | ~wxStreamBase ()
| Destructor. More...
wxStreamError | GetLastError () const
| This function returns the last error. More...
virtual wxFileOffset | GetLength () const
| Returns the length of the stream in bytes. More...
virtual size_t | GetSize () const
| This function returns the size of the stream. More...
virtual bool | IsOk () const
| Returns true if no error occurred on the stream. More...
virtual bool | IsSeekable () const
| Returns true if the stream supports seeking to arbitrary offsets. More...
void | Reset (wxStreamError error=wxSTREAM_NO_ERROR)
| Resets the stream state. More...
bool | operator! () const
| Returns the opposite of IsOk(). More...

## Static Public Member Functions
static bool | CanHandleGZip ()
| Returns true if zlib library in use can handle gzip compressed data. More...

## Additional Inherited Members
Protected Member Functions inherited from wxOutputStream
size_t | OnSysWrite (const void *buffer, size_t bufsize)
| Internal function. More...
Protected Member Functions inherited from wxStreamBase
virtual wxFileOffset | OnSysSeek (wxFileOffset pos, wxSeekMode mode)
| Internal function. More...
virtual wxFileOffset | OnSysTell () const
| Internal function. More...

## Constructor & Destructor Documentation

## ◆ wxZlibOutputStream() [1/2]

wxZlibOutputStream::wxZlibOutputStream | ( | wxOutputStream & | stream,
|  | int | level = `-1`,
|  | int | flags = `wxZLIB_ZLIB`
| ) |  |

Creates a new write-only compressed stream.

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 flags wxZLIB_ZLIB and wxZLIB_GZIP specify whether the output data will be in zlib or gzip format. wxZLIB_ZLIB is the default.

If 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() [2/2]

wxZlibOutputStream::wxZlibOutputStream | ( | wxOutputStream * | stream,
|  | int | level = `-1`,
|  | int | flags = `wxZLIB_ZLIB`
| ) |  |

Creates a new write-only compressed stream.

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 flags wxZLIB_ZLIB and wxZLIB_GZIP specify whether the output data will be in zlib or gzip format. wxZLIB_ZLIB is the default.

If 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.

## Member Function Documentation

## ◆ CanHandleGZip()

static bool wxZlibOutputStream::CanHandleGZip | ( |  | ) |
| static

Returns true if zlib library in use can handle gzip compressed data.

## ◆ SetDictionary() [1/2]

bool wxZlibOutputStream::SetDictionary | ( | const char * | data,
|  | size_t | datalen
| ) |  |

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.

## ◆ SetDictionary() [2/2]

bool wxZlibOutputStream::SetDictionary | ( | const wxMemoryBuffer & | buf | ) |

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.