class Poco::DeflatingOutputStream
Overview
This stream compresses all data passing through it using zlib’s deflate algorithm. More…
#include <DeflatingStream.h> class DeflatingOutputStream: public ostream, public Poco::DeflatingIOS { public: // construction DeflatingOutputStream( std::ostream& ostr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION ); DeflatingOutputStream( std::ostream& ostr, int windowBits, int level ); // methods int close(); protected: // methods virtual int sync(); };
Inherited Members
public: // methods DeflatingStreamBuf* rdbuf(); protected: // fields DeflatingStreamBuf _buf;
Detailed Documentation
This stream compresses all data passing through it using zlib’s deflate algorithm.
After all data has been written to the stream, close() must be called to ensure completion of compression. Example:
std::ofstream ostr("data.gz", std::ios::binary); DeflatingOutputStream deflater(ostr, DeflatingStreamBuf::STREAM_GZIP); deflater << "Hello, world!" << std::endl; deflater.close(); ostr.close();
Construction
DeflatingOutputStream( std::ostream& ostr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION )
Creates a DeflatingOutputStream for compressing data passed through and forwarding it to the given output stream.
DeflatingOutputStream( std::ostream& ostr, int windowBits, int level )
Creates a DeflatingOutputStream for compressing data passed through and forwarding it to the given output stream.
Please refer to the zlib documentation of deflateInit2() for a description of the windowBits parameter.
Methods
int close()
Finishes up the stream.
Must be called when deflating to an output stream.