zlibcomplete
Simple C++ wrapper for zlib using RAII and std::string with flush.
 All Classes Namespaces Files Functions Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
zlibcomplete::RawDeflater Class Reference

Raw ZLib compression class using std::string for input and output. More...

#include <zlibraw.hpp>

Inheritance diagram for zlibcomplete::RawDeflater:

Public Member Functions

 RawDeflater (int level=9, flush_parameter autoFlush=auto_flush, int windowBits=15)
 
 ~RawDeflater (void)
 
std::string deflate (const std::string &input)
 Compresses data. Uses std::string for input and output. More...
 
std::string finish (void)
 Writes a termination block to the raw zlib stream indicating the end. More...
 

Detailed Description

Raw ZLib compression class using std::string for input and output.

Implements raw zlib compression using std::string for input and output. To use, simply call compress() zero or more times and then call finish(). This class does not write a header, so it is necessary to match up the window_bits parameter for the inflate and deflate methods. This class implements RFC 1951.

Constructor & Destructor Documentation

zlibcomplete::RawDeflater::RawDeflater ( int  level = 9,
flush_parameter  autoFlush = auto_flush,
int  windowBits = 15 
)

Accepts the standard three parameters for compression constructors.

Parameters
levelCompression level 1-9, defaulting to 9, the best compression.
flush_parameterFlush mode, either auto_flush or no_flush, defaulting to auto_flush mode.
window_bitsSize of history window between 8 and 15, defaulting to 15. It is important to pass the same number to the RawInflater constructor.
zlibcomplete::RawDeflater::~RawDeflater ( void  )

Member Function Documentation

std::string zlibcomplete::RawDeflater::deflate ( const std::string &  input)

Compresses data. Uses std::string for input and output.

Accepts a std::string of any size containing data to compress. Returns as much raw zlib compressed data as possible. In auto_flush mode, this will ensure that the returned data is immediately decompressible to the original data. In no_flush mode, the data may not all be available until the rest of the compressed data is written using more compress() or a finish() call. After calling compress() zero or more times, it is necessary to call finish() exactly once.

Parameters
inputAny amount of data to compress.
Return values
std::stringcontaining compressed data.
std::string zlibcomplete::RawDeflater::finish ( void  )

Writes a termination block to the raw zlib stream indicating the end.

Flushes any remaining data that has not yet been written and then writes a terminal block to the compressed data stream. Returns this compressed data as a std::string. This function should be called exactly once for each compressed data stream.

Return values
std::stringcontaining the last piece of compressed data.

The documentation for this class was generated from the following files: