Marine Library  1.0
C++ library for Linux Networking Development
Public Member Functions | List of all members
CCompressorZlib Class Reference

A convenient interface for zlib compression algorithm. More...

#include <compress_zlib.hh>

Public Member Functions

 CCompressorZlib (int level=Z_DEFAULT_COMPRESSION)
 Constructor. More...
 
void setLevel (int lv)
 Set compression level. More...
 
int getLevel () const
 Get compression level. More...
 
Compression

Compress given data.

If output is not empty, the result will append to output.

Parameters
[in]inputData to be compressed
[out]outputA buffer to receive the result
Returns
true if succeeded; otherwise false
bool compress (const std::vector< char > &input, std::vector< char > &output) const
 
bool compress (const std::vector< signed char > &input, std::vector< signed char > &output) const
 
bool compress (const std::vector< unsigned char > &input, std::vector< unsigned char > &output) const
 
bool compress (const std::string &input, std::string &output) const
 
Decompression

Decompress given data.

If output is not empty, the result will append to output.

Parameters
[in]inputData to be decompressed
[out]outputA buffer to receive the result
Returns
true if succeeded; otherwise false
bool decompress (const std::vector< char > &input, std::vector< char > &output) const
 
bool decompress (const std::vector< signed char > &input, std::vector< signed char > &output) const
 
bool decompress (const std::vector< unsigned char > &input, std::vector< unsigned char > &output) const
 
bool decompress (const std::string &input, std::string &output) const
 

Detailed Description

A convenient interface for zlib compression algorithm.

You may need to link to zlib library (e.g. -lz) if you use CCompressorZlib.

Note
CCompressorZlib object can NOT be copied.

Constructor & Destructor Documentation

CCompressorZlib::CCompressorZlib ( int  level = Z_DEFAULT_COMPRESSION)
inline

Constructor.

The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
1 gives best speed, 9 gives best compression, 0 gives no compression at all (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION requests a default compromise between speed and compression (currently equivalent to level 6).

Parameters
levelCompression level (0 to 9, or Z_DEFAULT_COMPRESSION)

Member Function Documentation

int CCompressorZlib::getLevel ( ) const
inline

Get compression level.

Returns
Compression level
void CCompressorZlib::setLevel ( int  lv)
inline

Set compression level.

Parameters
lvCompression level (0 to 9, or Z_DEFAULT_COMPRESSION)

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