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

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

#include <compress_quicklz.hh>

Public Member Functions

 CCompressorQuickLZ ()
 Default constructor.
 
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< unsigned char > &input, std::vector< unsigned char > &output) const
 
bool compress (const std::vector< signed char > &input, std::vector< signed 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< unsigned char > &input, std::vector< unsigned char > &output) const
 
bool decompress (const std::vector< signed char > &input, std::vector< signed char > &output) const
 
bool decompress (const std::string &input, std::string &output) const
 

Detailed Description

A convenient interface for QuickLZ compression algorithm.

Note
CCompressorQuickLZ object can NOT be copied.

There are 3 macros that can impact the behavior of CCompressorQuickLZ.

QLZ_COMPRESSION_LEVEL
Compression level, default 3.
Valid values are 1, 2 or 3.
1 gives fastest compression speed. 3 gives fastest decompression speed and best compression ratio.
Example code:
#define QLZ_COMPRESSION_LEVEL 1
QLZ_STREAMING_BUFFER
Streaming compression buffer size, default 0. If it is:
  • 0: Streaming compression is disabled;
  • A positive number: Bytes size of scratch buffer for streaming compression.
The suggested buffer sizes are 100000 or 1000000. If it's too small, streaming compression may NOT function properly.
Example code:
#define QLZ_STREAMING_BUFFER 100000
QLZ_MEMORY_SAFE
Whether to enable memory access checks, undefined by default.
If QLZ_MEMORY_SAFE is defined, it is guaranteed that decompression of corrupted data cannot crash. But this could decrease decompression speed by 10-20%. Compression speed is not affected.
Example code:
#define QLZ_MEMORY_SAFE

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