ICSharpCode::SharpZipLib::Zip::Compression::Inflater Class Reference

Inflater is used to decompress data that has been compressed according to the "deflate" standard described in rfc1951. More...

List of all members.

Public Member Functions

 Inflater ()
 Creates a new inflater or RFC1951 decompressor RFC1950/Zlib headers and footers will be expected in the input data.
 Inflater (bool noHeader)
 Creates a new inflater.
void Reset ()
 Resets the inflater so that a new stream can be decompressed. All pending input and output will be discarded.
void SetDictionary (byte[] buffer)
 Sets the preset dictionary. This should only be called, if needsDictionary() returns true and it should set the same dictionary, that was used for deflating. The getAdler() function returns the checksum of the dictionary needed.
void SetDictionary (byte[] buffer, int offset, int len)
 Sets the preset dictionary. This should only be called, if needsDictionary() returns true and it should set the same dictionary, that was used for deflating. The getAdler() function returns the checksum of the dictionary needed.
void SetInput (byte[] buf)
 Sets the input. This should only be called, if needsInput() returns true.
void SetInput (byte[] buffer, int offset, int length)
 Sets the input. This should only be called, if needsInput() returns true.
int Inflate (byte[] buf)
 Inflates the compressed stream to the output buffer. If this returns 0, you should check, whether needsDictionary(), needsInput() or finished() returns true, to determine why no further output is produced.
int Inflate (byte[] buf, int offset, int len)
 Inflates the compressed stream to the output buffer. If this returns 0, you should check, whether needsDictionary(), needsInput() or finished() returns true, to determine why no further output is produced.

Properties

bool IsNeedingInput
 Returns true, if the input buffer is empty. You should then call setInput(). NOTE: This method also returns true when the stream is finished.
bool IsNeedingDictionary
 Returns true, if a preset dictionary is needed to inflate the input.
bool IsFinished
 Returns true, if the inflater has finished. This means, that no input is needed and no output can be produced.
int Adler
 Gets the adler checksum. This is either the checksum of all uncompressed bytes returned by inflate(), or if needsDictionary() returns true (and thus no output was yet produced) this is the adler checksum of the expected dictionary.
int TotalOut
 Gets the total number of output bytes returned by inflate().
int TotalIn
 Gets the total number of processed compressed input bytes.
int UnseenInput
 -jr test hak trying to figure out a bug /summary>
int PlainTotalIn
 -jr test hak trying to figure out a bug /summary>
int RemainingInput
 Gets the number of unprocessed input bytes. Useful, if the end of the stream is reached and you want to further process the bytes after the deflate stream.

Private Member Functions

bool DecodeHeader ()
 Decodes a zlib/RFC1950 header.
bool DecodeDict ()
 Decodes the dictionary checksum after the deflate header.
bool DecodeHuffman ()
 Decodes the huffman encoded symbols in the input stream.
bool DecodeChksum ()
 Decodes the adler checksum after the deflate stream.
bool Decode ()
 Decodes the deflated stream.

Private Attributes

const int DECODE_HEADER = 0
 These are the possible states for an inflater.
const int DECODE_DICT = 1
const int DECODE_BLOCKS = 2
const int DECODE_STORED_LEN1 = 3
const int DECODE_STORED_LEN2 = 4
const int DECODE_STORED = 5
const int DECODE_DYN_HEADER = 6
const int DECODE_HUFFMAN = 7
const int DECODE_HUFFMAN_LENBITS = 8
const int DECODE_HUFFMAN_DIST = 9
const int DECODE_HUFFMAN_DISTBITS = 10
const int DECODE_CHKSUM = 11
const int FINISHED = 12
int mode
 This variable contains the current state.
int readAdler
 The adler checksum of the dictionary or of the decompressed stream, as it is written in the header resp. footer of the compressed stream. Only valid if mode is DECODE_DICT or DECODE_CHKSUM.
int neededBits
 The number of bits needed to complete the current state. This is valid, if mode is DECODE_DICT, DECODE_CHKSUM, DECODE_HUFFMAN_LENBITS or DECODE_HUFFMAN_DISTBITS.
int repLength
int repDist
int uncomprLen
bool isLastBlock
 True, if the last block flag was set in the last block of the inflated stream. This means that the stream ends after the current block.
int totalOut
 The total number of inflated bytes.
int totalIn
 The total number of bytes set with setInput(). This is not the value returned by the TotalIn property, since this also includes the unprocessed input.
bool noHeader
 This variable stores the noHeader flag that was given to the constructor. True means, that the inflated stream doesn't contain a Zlib header or footer.
StreamManipulator input
OutputWindow outputWindow
InflaterDynHeader dynHeader
InflaterHuffmanTree litlenTree
InflaterHuffmanTree distTree
Adler32 adler

Static Private Attributes

static int[] CPLENS
 Copy lengths for literal codes 257..285.
static int[] CPLEXT
 Extra bits for literal codes 257..285.
static int[] CPDIST
 Copy offsets for distance codes 0..29.
static int[] CPDEXT
 Extra bits for distance codes.


Detailed Description

Inflater is used to decompress data that has been compressed according to the "deflate" standard described in rfc1951.

By default Zlib (rfc1950) headers and footers are expected in the input. You can use constructor

 public Inflater(bool noHeader)</code> passing true
            if there is no Zlib header information
           
            The usage is as following.  First you have to set some input with
            <code>setInput()</code>, then inflate() it.  If inflate doesn't
            inflate any bytes there may be three reasons:
<ul>
            <li>needsInput() returns true because the input buffer is empty.
            You have to provide more input with <code>setInput()</code>.
            NOTE: needsInput() also returns true when, the stream is finished.
            </li>
            <li>needsDictionary() returns true, you have to provide a preset
               dictionary with <code>setDictionary()</code>.</li>
            <li>finished() returns true, the inflater has finished.</li>
            </ul>
            Once the first output byte is produced, a dictionary will not be
            needed at a later stage.
           
            author of the original java version : John Leuner, Jochen Hoenicke

Definition at line 73 of file Inflater.cs.


Constructor & Destructor Documentation

ICSharpCode::SharpZipLib::Zip::Compression::Inflater::Inflater  )  [inline]
 

Creates a new inflater or RFC1951 decompressor RFC1950/Zlib headers and footers will be expected in the input data.

Definition at line 185 of file Inflater.cs.

ICSharpCode::SharpZipLib::Zip::Compression::Inflater::Inflater bool  noHeader  )  [inline]
 

Creates a new inflater.

Parameters:
noHeader True if no RFC1950/Zlib header and footer fields are expected in the input data
This is used for GZIPed/Zipped input.

For compatibility with Sun JDK you should provide one byte of input more than needed in this case.

Definition at line 201 of file Inflater.cs.


Member Function Documentation

bool ICSharpCode::SharpZipLib::Zip::Compression::Inflater::Decode  )  [inline, private]
 

Decodes the deflated stream.

Returns:
false if more input is needed, or if finished.
Exceptions:
SharpZipBaseException if deflated stream is invalid.

Definition at line 422 of file Inflater.cs.

bool ICSharpCode::SharpZipLib::Zip::Compression::Inflater::DecodeChksum  )  [inline, private]
 

Decodes the adler checksum after the deflate stream.

Returns:
false if more input is needed.
Exceptions:
SharpZipBaseException If checksum doesn't match.

Definition at line 395 of file Inflater.cs.

bool ICSharpCode::SharpZipLib::Zip::Compression::Inflater::DecodeDict  )  [inline, private]
 

Decodes the dictionary checksum after the deflate header.

Returns:
False if more input is needed.

Definition at line 276 of file Inflater.cs.

bool ICSharpCode::SharpZipLib::Zip::Compression::Inflater::DecodeHeader  )  [inline, private]
 

Decodes a zlib/RFC1950 header.

Returns:
False if more input is needed.
Exceptions:
SharpZipBaseException The header is invalid.

Definition at line 236 of file Inflater.cs.

bool ICSharpCode::SharpZipLib::Zip::Compression::Inflater::DecodeHuffman  )  [inline, private]
 

Decodes the huffman encoded symbols in the input stream.

Returns:
false if more input is needed, true if output window is full or the current block ends.
Exceptions:
SharpZipBaseException if deflated stream is invalid.

Definition at line 300 of file Inflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::Inflate byte[]  buf,
int  offset,
int  len
[inline]
 

Inflates the compressed stream to the output buffer. If this returns 0, you should check, whether needsDictionary(), needsInput() or finished() returns true, to determine why no further output is produced.

Parameters:
buf the output buffer.
offset the offset into buffer where the output should start.
len the maximum length of the output.
Returns:
the number of bytes written to the buffer, 0 if no further output can be produced.
Exceptions:
System.ArgumentOutOfRangeException if len is <= 0.
System.ArgumentOutOfRangeException if the offset and/or len are wrong.
System.FormatException if deflated stream is invalid.

Definition at line 670 of file Inflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::Inflate byte[]  buf  )  [inline]
 

Inflates the compressed stream to the output buffer. If this returns 0, you should check, whether needsDictionary(), needsInput() or finished() returns true, to determine why no further output is produced.

Parameters:
buf the output buffer.
Returns:
the number of bytes written to the buffer, 0 if no further output can be produced.
Exceptions:
System.ArgumentOutOfRangeException if buf has length 0.
System.FormatException if deflated stream is invalid.

Definition at line 638 of file Inflater.cs.

void ICSharpCode::SharpZipLib::Zip::Compression::Inflater::Reset  )  [inline]
 

Resets the inflater so that a new stream can be decompressed. All pending input and output will be discarded.

Definition at line 214 of file Inflater.cs.

void ICSharpCode::SharpZipLib::Zip::Compression::Inflater::SetDictionary byte[]  buffer,
int  offset,
int  len
[inline]
 

Sets the preset dictionary. This should only be called, if needsDictionary() returns true and it should set the same dictionary, that was used for deflating. The getAdler() function returns the checksum of the dictionary needed.

Parameters:
buffer The dictionary.
offset The offset into buffer where the dictionary starts.
len The length of the dictionary.
Exceptions:
System.InvalidOperationException No dictionary is needed.
SharpZipBaseException The adler checksum for the buffer is invalid

Definition at line 567 of file Inflater.cs.

void ICSharpCode::SharpZipLib::Zip::Compression::Inflater::SetDictionary byte[]  buffer  )  [inline]
 

Sets the preset dictionary. This should only be called, if needsDictionary() returns true and it should set the same dictionary, that was used for deflating. The getAdler() function returns the checksum of the dictionary needed.

Parameters:
buffer The dictionary.

Definition at line 541 of file Inflater.cs.

void ICSharpCode::SharpZipLib::Zip::Compression::Inflater::SetInput byte[]  buffer,
int  offset,
int  length
[inline]
 

Sets the input. This should only be called, if needsInput() returns true.

Parameters:
buffer The source of input data
offset The offset into buffer where the input starts.
length The number of bytes of input to use.
Exceptions:
System.InvalidOperationException No input is needed.
System.ArgumentOutOfRangeException The off and/or len are wrong.

Definition at line 613 of file Inflater.cs.

void ICSharpCode::SharpZipLib::Zip::Compression::Inflater::SetInput byte[]  buf  )  [inline]
 

Sets the input. This should only be called, if needsInput() returns true.

Parameters:
buf the input.

Definition at line 589 of file Inflater.cs.

Referenced by ICSharpCode::SharpZipLib::Zip::Compression::Streams::InflaterInputBuffer::SetInflaterInput().


Member Data Documentation

Adler32 ICSharpCode::SharpZipLib::Zip::Compression::Inflater::adler [private]
 

Definition at line 179 of file Inflater.cs.

int [] ICSharpCode::SharpZipLib::Zip::Compression::Inflater::CPDEXT [static, private]
 

Initial value:

 {
                                                                0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
                                                                7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
                                                                12, 12, 13, 13
                                                          }
Extra bits for distance codes.

Definition at line 103 of file Inflater.cs.

int [] ICSharpCode::SharpZipLib::Zip::Compression::Inflater::CPDIST [static, private]
 

Initial value:

 {
                                                                1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
                                                                257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
                                                                8193, 12289, 16385, 24577
                                                          }
Copy offsets for distance codes 0..29.

Definition at line 94 of file Inflater.cs.

int [] ICSharpCode::SharpZipLib::Zip::Compression::Inflater::CPLENS [static, private]
 

Initial value:

 {
                                                                 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
                                                                 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258
                                                          }
Copy lengths for literal codes 257..285.

Definition at line 78 of file Inflater.cs.

int [] ICSharpCode::SharpZipLib::Zip::Compression::Inflater::CPLEXT [static, private]
 

Initial value:

 {
                                                                 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
                                                                 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0
                                                          }
Extra bits for literal codes 257..285.

Definition at line 86 of file Inflater.cs.

const int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::DECODE_BLOCKS = 2 [private]
 

Definition at line 114 of file Inflater.cs.

const int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::DECODE_CHKSUM = 11 [private]
 

Definition at line 123 of file Inflater.cs.

const int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::DECODE_DICT = 1 [private]
 

Definition at line 113 of file Inflater.cs.

const int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::DECODE_DYN_HEADER = 6 [private]
 

Definition at line 118 of file Inflater.cs.

const int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::DECODE_HEADER = 0 [private]
 

These are the possible states for an inflater.

Definition at line 112 of file Inflater.cs.

const int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::DECODE_HUFFMAN = 7 [private]
 

Definition at line 119 of file Inflater.cs.

const int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::DECODE_HUFFMAN_DIST = 9 [private]
 

Definition at line 121 of file Inflater.cs.

const int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::DECODE_HUFFMAN_DISTBITS = 10 [private]
 

Definition at line 122 of file Inflater.cs.

const int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::DECODE_HUFFMAN_LENBITS = 8 [private]
 

Definition at line 120 of file Inflater.cs.

const int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::DECODE_STORED = 5 [private]
 

Definition at line 117 of file Inflater.cs.

const int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::DECODE_STORED_LEN1 = 3 [private]
 

Definition at line 115 of file Inflater.cs.

const int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::DECODE_STORED_LEN2 = 4 [private]
 

Definition at line 116 of file Inflater.cs.

InflaterHuffmanTree ICSharpCode::SharpZipLib::Zip::Compression::Inflater::distTree [private]
 

Definition at line 178 of file Inflater.cs.

InflaterDynHeader ICSharpCode::SharpZipLib::Zip::Compression::Inflater::dynHeader [private]
 

Definition at line 177 of file Inflater.cs.

const int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::FINISHED = 12 [private]
 

Definition at line 124 of file Inflater.cs.

StreamManipulator ICSharpCode::SharpZipLib::Zip::Compression::Inflater::input [private]
 

Definition at line 175 of file Inflater.cs.

bool ICSharpCode::SharpZipLib::Zip::Compression::Inflater::isLastBlock [private]
 

True, if the last block flag was set in the last block of the inflated stream. This means that the stream ends after the current block.

Definition at line 154 of file Inflater.cs.

InflaterHuffmanTree ICSharpCode::SharpZipLib::Zip::Compression::Inflater::litlenTree [private]
 

Definition at line 178 of file Inflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::mode [private]
 

This variable contains the current state.

Definition at line 129 of file Inflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::neededBits [private]
 

The number of bits needed to complete the current state. This is valid, if mode is DECODE_DICT, DECODE_CHKSUM, DECODE_HUFFMAN_LENBITS or DECODE_HUFFMAN_DISTBITS.

Definition at line 144 of file Inflater.cs.

bool ICSharpCode::SharpZipLib::Zip::Compression::Inflater::noHeader [private]
 

This variable stores the noHeader flag that was given to the constructor. True means, that the inflated stream doesn't contain a Zlib header or footer.

Definition at line 173 of file Inflater.cs.

OutputWindow ICSharpCode::SharpZipLib::Zip::Compression::Inflater::outputWindow [private]
 

Definition at line 176 of file Inflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::readAdler [private]
 

The adler checksum of the dictionary or of the decompressed stream, as it is written in the header resp. footer of the compressed stream. Only valid if mode is DECODE_DICT or DECODE_CHKSUM.

Definition at line 137 of file Inflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::repDist [private]
 

Definition at line 146 of file Inflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::repLength [private]
 

Definition at line 145 of file Inflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::totalIn [private]
 

The total number of bytes set with setInput(). This is not the value returned by the TotalIn property, since this also includes the unprocessed input.

Definition at line 166 of file Inflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::totalOut [private]
 

The total number of inflated bytes.

Definition at line 159 of file Inflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::uncomprLen [private]
 

Definition at line 147 of file Inflater.cs.


Property Documentation

int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::Adler [get]
 

Gets the adler checksum. This is either the checksum of all uncompressed bytes returned by inflate(), or if needsDictionary() returns true (and thus no output was yet produced) this is the adler checksum of the expected dictionary.

Returns:
the adler checksum.

Definition at line 753 of file Inflater.cs.

bool ICSharpCode::SharpZipLib::Zip::Compression::Inflater::IsFinished [get]
 

Returns true, if the inflater has finished. This means, that no input is needed and no output can be produced.

Definition at line 738 of file Inflater.cs.

bool ICSharpCode::SharpZipLib::Zip::Compression::Inflater::IsNeedingDictionary [get]
 

Returns true, if a preset dictionary is needed to inflate the input.

Definition at line 728 of file Inflater.cs.

bool ICSharpCode::SharpZipLib::Zip::Compression::Inflater::IsNeedingInput [get]
 

Returns true, if the input buffer is empty. You should then call setInput(). NOTE: This method also returns true when the stream is finished.

Definition at line 719 of file Inflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::PlainTotalIn [get]
 

-jr test hak trying to figure out a bug /summary>

Definition at line 796 of file Inflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::RemainingInput [get]
 

Gets the number of unprocessed input bytes. Useful, if the end of the stream is reached and you want to further process the bytes after the deflate stream.

Returns:
The number of bytes of the input which have not been processed.

Definition at line 811 of file Inflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::TotalIn [get]
 

Gets the total number of processed compressed input bytes.

Returns:
The total number of bytes of processed input bytes.

Definition at line 777 of file Inflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::TotalOut [get]
 

Gets the total number of output bytes returned by inflate().

Returns:
the total number of output bytes.

Definition at line 765 of file Inflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Inflater::UnseenInput [get]
 

-jr test hak trying to figure out a bug /summary>

Definition at line 787 of file Inflater.cs.


The documentation for this class was generated from the following file:
Generated on Fri Jun 23 21:50:08 2006 for OblivionModTranslator by  doxygen 1.4.6-NO