activemq-cpp-3.4.0
|
This class compresses data using the DEFLATE algorithm (see specification). More...
#include <src/main/decaf/util/zip/Deflater.h>
Public Member Functions | |
Deflater (int level, bool nowrap=false) | |
Creates a new compressor using the specified compression level. | |
Deflater () | |
Creates a new compressor with the default compression level. | |
virtual | ~Deflater () |
void | setInput (const unsigned char *buffer, int size, int offset, int length) |
Sets input data for compression. | |
void | setInput (const std::vector< unsigned char > &buffer, int offset, int length) |
Sets input data for compression. | |
void | setInput (const std::vector< unsigned char > &buffer) |
Sets input data for compression. | |
void | setDictionary (const unsigned char *buffer, int size, int offset, int length) |
Sets preset dictionary for compression. | |
void | setDictionary (const std::vector< unsigned char > &buffer, int offset, int length) |
Sets preset dictionary for compression. | |
void | setDictionary (const std::vector< unsigned char > &buffer) |
Sets preset dictionary for compression. | |
void | setStrategy (int strategy) |
Sets the compression strategy to the specified value. | |
void | setLevel (int level) |
Sets the compression level to the specified value. | |
bool | needsInput () const |
void | finish () |
When called, indicates that compression should end with the current contents of the input buffer. | |
bool | finished () const |
int | deflate (unsigned char *buffer, int size, int offset, int length) |
Fills specified buffer with compressed data. | |
int | deflate (std::vector< unsigned char > &buffer, int offset, int length) |
Fills specified buffer with compressed data. | |
int | deflate (std::vector< unsigned char > &buffer) |
Fills specified buffer with compressed data. | |
long long | getAdler () const |
long long | getBytesRead () const |
long long | getBytesWritten () const |
void | reset () |
Resets deflater so that a new set of input data can be processed. | |
void | end () |
Closes the compressor and discards any unprocessed input. | |
Static Public Attributes | |
static const int | BEST_SPEED |
Compression level for fastest compression. | |
static const int | BEST_COMPRESSION |
Compression level for best compression. | |
static const int | DEFAULT_COMPRESSION |
Default compression level. | |
static const int | DEFLATED |
Compression method for the deflate algorithm (the only one currently supported). | |
static const int | NO_COMPRESSION |
Compression level for no compression. | |
static const int | FILTERED |
Compression strategy best used for data consisting mostly of small values with a somewhat random distribution. | |
static const int | HUFFMAN_ONLY |
Compression strategy for Huffman coding only. | |
static const int | DEFAULT_STRATEGY |
Default compression strategy. |
This class compresses data using the DEFLATE algorithm (see specification).
Basically this class is part of the API to the stream based ZLIB compression library and is used as such by DeflaterOutputStream and its descendants.
The typical usage of a Deflater instance outside this package consists of a specific call to one of its constructors before being passed to an instance of DeflaterOutputStream.
decaf::util::zip::Deflater::Deflater | ( | int | level, |
bool | nowrap = false |
||
) |
Creates a new compressor using the specified compression level.
If 'nowrap' is true then the ZLIB header and checksum fields will not be used in order to support the compression format used in both GZIP and PKZIP.
level | The compression level to use (0-9). |
nowrap | If true uses GZip compatible compression (defaults to false). |
decaf::util::zip::Deflater::Deflater | ( | ) |
Creates a new compressor with the default compression level.
Compressed data will be generated in ZLIB format.
virtual decaf::util::zip::Deflater::~Deflater | ( | ) | [virtual] |
int decaf::util::zip::Deflater::deflate | ( | unsigned char * | buffer, |
int | size, | ||
int | offset, | ||
int | length | ||
) |
Fills specified buffer with compressed data.
Returns actual number of bytes of compressed data. A return value of 0 indicates that needsInput() should be called in order to determine if more input data is required.
buffer | The Buffer to write the compressed data to. |
size | The size of the passed buffer. |
offset | The position in the Buffer to start writing at. |
length | The maximum number of byte of data to write. |
NullPointerException | if buffer is NULL. |
IndexOutOfBoundsException | if the offset + length > size of the buffer. |
IllegalStateException | if in the end state. |
int decaf::util::zip::Deflater::deflate | ( | std::vector< unsigned char > & | buffer, |
int | offset, | ||
int | length | ||
) |
Fills specified buffer with compressed data.
Returns actual number of bytes of compressed data. A return value of 0 indicates that needsInput() should be called in order to determine if more input data is required.
buffer | The Buffer to write the compressed data to. |
offset | The position in the Buffer to start writing at. |
length | The maximum number of byte of data to write. |
IndexOutOfBoundsException | if the offset + length > size of the buffer. |
IllegalStateException | if in the end state. |
int decaf::util::zip::Deflater::deflate | ( | std::vector< unsigned char > & | buffer | ) |
Fills specified buffer with compressed data.
Returns actual number of bytes of compressed data. A return value of 0 indicates that needsInput() should be called in order to determine if more input data is required.
buffer | The Buffer to write the compressed data to. |
IllegalStateException | if in the end state. |
void decaf::util::zip::Deflater::end | ( | ) |
Closes the compressor and discards any unprocessed input.
This method should be called when the compressor is no longer being used, but will also be called automatically by the destructor. Once this method is called, the behavior of the Deflater object is undefined.
void decaf::util::zip::Deflater::finish | ( | ) |
When called, indicates that compression should end with the current contents of the input buffer.
bool decaf::util::zip::Deflater::finished | ( | ) | const |
long long decaf::util::zip::Deflater::getAdler | ( | ) | const |
IllegalStateException | if in the end state. |
long long decaf::util::zip::Deflater::getBytesRead | ( | ) | const |
IllegalStateException | if in the end state. |
long long decaf::util::zip::Deflater::getBytesWritten | ( | ) | const |
IllegalStateException | if in the end state. |
bool decaf::util::zip::Deflater::needsInput | ( | ) | const |
void decaf::util::zip::Deflater::reset | ( | ) |
Resets deflater so that a new set of input data can be processed.
Keeps current compression level and strategy settings.
IllegalStateException | if in the end state. |
void decaf::util::zip::Deflater::setDictionary | ( | const std::vector< unsigned char > & | buffer, |
int | offset, | ||
int | length | ||
) |
Sets preset dictionary for compression.
A preset dictionary is used when the history buffer can be predetermined. When the data is later uncompressed with Inflater.inflate(), Inflater.getAdler() can be called in order to get the Adler-32 value of the dictionary required for decompression.
buffer | The buffer containing the preset dictionary. |
offset | The position in the Buffer to start reading from. |
length | The number of bytes to read from the input buffer. |
IndexOutOfBoundsException | if the offset + length > size of the buffer. |
IllegalStateException | if in the end state. |
void decaf::util::zip::Deflater::setDictionary | ( | const unsigned char * | buffer, |
int | size, | ||
int | offset, | ||
int | length | ||
) |
Sets preset dictionary for compression.
A preset dictionary is used when the history buffer can be predetermined. When the data is later uncompressed with Inflater.inflate(), Inflater.getAdler() can be called in order to get the Adler-32 value of the dictionary required for decompression.
buffer | The buffer containing the preset dictionary. |
size | The size of the passed dictionary buffer. |
offset | The position in the Buffer to start reading from. |
length | The number of bytes to read from the input buffer. |
NullPointerException | if buffer is NULL. |
IndexOutOfBoundsException | if the offset + length > size of the buffer. |
IllegalStateException | if in the end state. |
void decaf::util::zip::Deflater::setDictionary | ( | const std::vector< unsigned char > & | buffer | ) |
Sets preset dictionary for compression.
A preset dictionary is used when the history buffer can be predetermined. When the data is later uncompressed with Inflater.inflate(), Inflater.getAdler() can be called in order to get the Adler-32 value of the dictionary required for decompression.
buffer | The buffer containing the preset dictionary. |
IllegalStateException | if in the end state. |
void decaf::util::zip::Deflater::setInput | ( | const std::vector< unsigned char > & | buffer | ) |
Sets input data for compression.
This should be called whenever needsInput() returns true indicating that more input data is required.
buffer | The Buffer to read in for compression. |
IllegalStateException | if in the end state. |
void decaf::util::zip::Deflater::setInput | ( | const std::vector< unsigned char > & | buffer, |
int | offset, | ||
int | length | ||
) |
Sets input data for compression.
This should be called whenever needsInput() returns true indicating that more input data is required.
buffer | The Buffer to read in for compression. |
offset | The position in the Buffer to start reading from. |
length | The number of bytes to read from the input buffer. |
IndexOutOfBoundsException | if the offset + length > size of the buffer. |
IllegalStateException | if in the end state. |
void decaf::util::zip::Deflater::setInput | ( | const unsigned char * | buffer, |
int | size, | ||
int | offset, | ||
int | length | ||
) |
Sets input data for compression.
This should be called whenever needsInput() returns true indicating that more input data is required.
buffer | The Buffer to read in for compression. |
size | The size in bytes of the buffer passed. |
offset | The position in the Buffer to start reading from. |
length | The number of bytes to read from the input buffer. |
NullPointerException | if buffer is NULL. |
IndexOutOfBoundsException | if the offset + length > size of the buffer. |
IllegalStateException | if in the end state. |
void decaf::util::zip::Deflater::setLevel | ( | int | level | ) |
Sets the compression level to the specified value.
level | The new Compression level to use. |
IllegalArgumentException | if the level value is invalid. |
IllegalStateException | if in the end state. |
void decaf::util::zip::Deflater::setStrategy | ( | int | strategy | ) |
Sets the compression strategy to the specified value.
strategy | The new Compression strategy to use. |
IllegalArgumentException | if the strategy value is invalid. |
IllegalStateException | if in the end state. |
const int decaf::util::zip::Deflater::BEST_COMPRESSION [static] |
Compression level for best compression.
const int decaf::util::zip::Deflater::BEST_SPEED [static] |
Compression level for fastest compression.
const int decaf::util::zip::Deflater::DEFAULT_COMPRESSION [static] |
Default compression level.
const int decaf::util::zip::Deflater::DEFAULT_STRATEGY [static] |
Default compression strategy.
const int decaf::util::zip::Deflater::DEFLATED [static] |
Compression method for the deflate algorithm (the only one currently supported).
const int decaf::util::zip::Deflater::FILTERED [static] |
Compression strategy best used for data consisting mostly of small values with a somewhat random distribution.
Forces more Huffman coding and less string matching.
const int decaf::util::zip::Deflater::HUFFMAN_ONLY [static] |
Compression strategy for Huffman coding only.
const int decaf::util::zip::Deflater::NO_COMPRESSION [static] |
Compression level for no compression.