This class uncompresses data that was compressed using the DEFLATE algorithm (see specification).
More...
#include <src/main/decaf/util/zip/Inflater.h>
Public Member Functions |
| Inflater () |
| Creates a new decompressor.
|
| Inflater (bool nowrap) |
| Creates a new decompressor.
|
virtual | ~Inflater () |
void | setInput (const unsigned char *buffer, int size, int offset, int length) |
| Sets input data for decompression.
|
void | setInput (const std::vector< unsigned char > &buffer, int offset, int length) |
| Sets input data for decompression.
|
void | setInput (const std::vector< unsigned char > &buffer) |
| Sets input data for decompression.
|
int | getRemaining () const |
| Returns the total number of bytes remaining in the input buffer.
|
void | setDictionary (const unsigned char *buffer, int size, int offset, int length) |
| Sets the preset dictionary to the given array of bytes.
|
void | setDictionary (const std::vector< unsigned char > &buffer, int offset, int length) |
| Sets the preset dictionary to the given array of bytes.
|
void | setDictionary (const std::vector< unsigned char > &buffer) |
| Sets the preset dictionary to the given array of bytes.
|
bool | needsInput () const |
bool | needsDictionary () const |
void | finish () |
| When called, indicates that decompression should end with the current contents of the input buffer.
|
bool | finished () const |
int | inflate (unsigned char *buffer, int size, int offset, int length) |
| Uncompresses bytes into specified buffer.
|
int | inflate (std::vector< unsigned char > &buffer, int offset, int length) |
| Uncompresses bytes into specified buffer.
|
int | inflate (std::vector< unsigned char > &buffer) |
| Uncompresses bytes into specified buffer.
|
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 decompressor and discards any unprocessed input.
|
Detailed Description
This class uncompresses data that was compressed 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 InflaterInputStream and its descendants.
The typical usage of a Inflater outside this package consists of a specific call to one of its constructors before being passed to an instance of InflaterInputStream.
- See also:
- InflaterInputStream
-
Deflater
- Since:
- 1.0
Constructor & Destructor Documentation
decaf::util::zip::Inflater::Inflater |
( |
| ) |
|
Creates a new decompressor.
This constructor defaults the inflater to use the ZLIB header and checksum fields.
decaf::util::zip::Inflater::Inflater |
( |
bool |
nowrap | ) |
|
Creates a new decompressor.
If the parameter 'nowrap' is true then the ZLIB header and checksum fields will not be used. This provides compatibility with the compression format used by both GZIP and PKZIP.
Note: When using the 'nowrap' option it is also necessary to provide an extra "dummy" byte as input. This is required by the ZLIB native library in order to support certain optimizations.
virtual decaf::util::zip::Inflater::~Inflater |
( |
| ) |
[virtual] |
Member Function Documentation
void decaf::util::zip::Inflater::end |
( |
| ) |
|
Closes the decompressor and discards any unprocessed input.
This method should be called when the decompressor is no longer being used, but will also be called automatically by the destructor. Once this method is called, the behavior of the Inflater object is undefined.
void decaf::util::zip::Inflater::finish |
( |
| ) |
|
When called, indicates that decompression should end with the current contents of the input buffer.
bool decaf::util::zip::Inflater::finished |
( |
| ) |
const |
- Returns:
- true if the end of the compressed data output stream has been reached.
long long decaf::util::zip::Inflater::getAdler |
( |
| ) |
const |
- Returns:
- the ADLER-32 value of the uncompressed data.
- Exceptions:
-
IllegalStateException | if in the end state. |
long long decaf::util::zip::Inflater::getBytesRead |
( |
| ) |
const |
- Returns:
- the total number of compressed bytes input so far.
- Exceptions:
-
IllegalStateException | if in the end state. |
long long decaf::util::zip::Inflater::getBytesWritten |
( |
| ) |
const |
- Returns:
- the total number of decompressed bytes output so far.
- Exceptions:
-
IllegalStateException | if in the end state. |
int decaf::util::zip::Inflater::getRemaining |
( |
| ) |
const |
Returns the total number of bytes remaining in the input buffer.
This can be used to find out what bytes still remain in the input buffer after decompression has finished.
- Returns:
- the total number of bytes remaining in the input buffer
int decaf::util::zip::Inflater::inflate |
( |
std::vector< unsigned char > & |
buffer | ) |
|
Uncompresses bytes into specified buffer.
Returns actual number of bytes uncompressed. A return value of 0 indicates that needsInput() or needsDictionary() should be called in order to determine if more input data or a preset dictionary is required. In the latter case, getAdler() can be used to get the Adler-32 value of the dictionary required.
- Parameters:
-
buffer | The Buffer to write the compressed data to. |
- Exceptions:
-
IllegalStateException | if in the end state. |
DataFormatException | if the compressed data format is invalid. |
int decaf::util::zip::Inflater::inflate |
( |
std::vector< unsigned char > & |
buffer, |
|
|
int |
offset, |
|
|
int |
length |
|
) |
| |
Uncompresses bytes into specified buffer.
Returns actual number of bytes uncompressed. A return value of 0 indicates that needsInput() or needsDictionary() should be called in order to determine if more input data or a preset dictionary is required. In the latter case, getAdler() can be used to get the Adler-32 value of the dictionary required.
- Parameters:
-
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. |
- Exceptions:
-
IllegalStateException | if in the end state. |
IndexOutOfBoundsException | if the offset + length > size of the buffer. |
DataFormatException | if the compressed data format is invalid. |
int decaf::util::zip::Inflater::inflate |
( |
unsigned char * |
buffer, |
|
|
int |
size, |
|
|
int |
offset, |
|
|
int |
length |
|
) |
| |
Uncompresses bytes into specified buffer.
Returns actual number of bytes uncompressed. A return value of 0 indicates that needsInput() or needsDictionary() should be called in order to determine if more input data or a preset dictionary is required. In the latter case, getAdler() can be used to get the Adler-32 value of the dictionary required.
- Parameters:
-
buffer | The Buffer to write the compressed data to. |
size | The size of the buffer passed in. |
offset | The position in the Buffer to start writing at. |
length | The maximum number of byte of data to write. |
- Exceptions:
-
NullPointerException | if buffer is NULL. |
IllegalStateException | if in the end state. |
IndexOutOfBoundsException | if the offset + length > size of the buffer. |
DataFormatException | if the compressed data format is invalid. |
bool decaf::util::zip::Inflater::needsDictionary |
( |
| ) |
const |
- Returns:
- true if a preset dictionary is needed for decompression.
bool decaf::util::zip::Inflater::needsInput |
( |
| ) |
const |
- Returns:
- true if the input data buffer is empty and setInput() should be called in order to provide more input
void decaf::util::zip::Inflater::reset |
( |
| ) |
|
Resets deflater so that a new set of input data can be processed.
Keeps current decompression level and strategy settings.
- Exceptions:
-
IllegalStateException | if in the end state. |
void decaf::util::zip::Inflater::setDictionary |
( |
const std::vector< unsigned char > & |
buffer, |
|
|
int |
offset, |
|
|
int |
length |
|
) |
| |
Sets the preset dictionary to the given array of bytes.
Should be called when inflate() returns 0 and needsDictionary() returns true indicating that a preset dictionary is required. The method getAdler() can be used to get the Adler-32 value of the dictionary needed.
- Parameters:
-
buffer | The Buffer to read in for decompression. |
offset | The position in the Buffer to start reading from. |
length | The number of bytes to read from the input buffer. |
- Exceptions:
-
IndexOutOfBoundsException | if the offset + length > size of the buffer. |
IllegalStateException | if in the end state. |
IllegalArgumentException | if the given dictionary doesn't match thre required dictionaries checksum value. |
void decaf::util::zip::Inflater::setDictionary |
( |
const unsigned char * |
buffer, |
|
|
int |
size, |
|
|
int |
offset, |
|
|
int |
length |
|
) |
| |
Sets the preset dictionary to the given array of bytes.
Should be called when inflate() returns 0 and needsDictionary() returns true indicating that a preset dictionary is required. The method getAdler() can be used to get the Adler-32 value of the dictionary needed.
- Parameters:
-
buffer | The Buffer to read in for decompression. |
size | The size of the buffer passed in. |
offset | The position in the Buffer to start reading from. |
length | The number of bytes to read from the input buffer. |
- Exceptions:
-
NullPointerException | if buffer is NULL. |
IndexOutOfBoundsException | if the offset + length > size of the buffer. |
IllegalStateException | if in the end state. |
IllegalArgumentException | if the given dictionary doesn't match thre required dictionaries checksum value. |
void decaf::util::zip::Inflater::setDictionary |
( |
const std::vector< unsigned char > & |
buffer | ) |
|
Sets the preset dictionary to the given array of bytes.
Should be called when inflate() returns 0 and needsDictionary() returns true indicating that a preset dictionary is required. The method getAdler() can be used to get the Adler-32 value of the dictionary needed.
- Parameters:
-
buffer | The Buffer to read in for decompression. |
- Exceptions:
-
IllegalStateException | if in the end state. |
IllegalArgumentException | if the given dictionary doesn't match the required dictionaries checksum value. |
void decaf::util::zip::Inflater::setInput |
( |
const unsigned char * |
buffer, |
|
|
int |
size, |
|
|
int |
offset, |
|
|
int |
length |
|
) |
| |
Sets input data for decompression.
This should be called whenever needsInput() returns true indicating that more input data is required.
- Parameters:
-
buffer | The Buffer to read in for decompression. |
size | The size of the buffer passed in. |
offset | The position in the Buffer to start reading from. |
length | The number of bytes to read from the input buffer. |
- Exceptions:
-
NullPointerException | if buffer is NULL. |
IndexOutOfBoundsException | if the offset + length > size of the buffer. |
IllegalStateException | if in the end state. |
void decaf::util::zip::Inflater::setInput |
( |
const std::vector< unsigned char > & |
buffer, |
|
|
int |
offset, |
|
|
int |
length |
|
) |
| |
Sets input data for decompression.
This should be called whenever needsInput() returns true indicating that more input data is required.
- Parameters:
-
buffer | The Buffer to read in for decompression. |
offset | The position in the Buffer to start reading from. |
length | The number of bytes to read from the input buffer. |
- Exceptions:
-
IndexOutOfBoundsException | if the offset + length > size of the buffer. |
IllegalStateException | if in the end state. |
void decaf::util::zip::Inflater::setInput |
( |
const std::vector< unsigned char > & |
buffer | ) |
|
Sets input data for decompression.
This should be called whenever needsInput() returns true indicating that more input data is required.
- Parameters:
-
buffer | The Buffer to read in for decompression. |
- Exceptions:
-
IllegalStateException | if in the end state. |
The documentation for this class was generated from the following file: