Fingerprint_Card

Loading...
Searching...
No Matches
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...

Collaboration diagram for ICSharpCode.SharpZipLib.Zip.Compression.Inflater:
[legend]

## 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 index, int count)
| 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[] buffer)
| Sets the input. This should only be called, if needsInput() returns true.
void | SetInput (byte[] buffer, int index, int count)
| Sets the input. This should only be called, if needsInput() returns true.
int | Inflate (byte[] buffer)
| Inflates the compressed stream to the output buffer. If this returns 0, you should check, whether IsNeedingDictionary(), IsNeedingInput() or IsFinished() returns true, to determine why no further output is produced.
int | Inflate (byte[] buffer, int offset, int count)
| 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`[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.
bool | IsNeedingDictionary`[get]`
| Returns true, if a preset dictionary is needed to inflate the input.
bool | IsFinished`[get]`
| Returns true, if the inflater has finished. This means, that no input is needed and no output can be produced.
int | 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.
long | TotalOut`[get]`
| Gets the total number of output bytes returned by Inflate().
long | TotalIn`[get]`
| Gets the total number of processed compressed input bytes.
int | 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.

## 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
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.
long | totalOut
| The total number of inflated bytes.
long | 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 readonly int[] | CPLENS
| Copy lengths for literal codes 257..285.
static readonly int[] | CPLEXT
| Extra bits for literal codes 257..285.
static readonly int[] | CPDIST
| Copy offsets for distance codes 0..29.
static readonly int[] | CPDEXT
| Extra bits for distance codes.
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

## 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)
ICSharpCode.SharpZipLib.Zip.Compression.Inflater.Inflater
Inflater()
Creates a new inflater or RFC1951 decompressor RFC1950/Zlib headers and footers will be expected in t...
Definition Inflater.cs:189
ICSharpCode.SharpZipLib.Zip.Compression.Inflater.noHeader
bool noHeader
This variable stores the noHeader flag that was given to the constructor. True means,...
Definition Inflater.cs:175

passing true if there is no Zlib header information

The usage is as following. First you have to set some input with

SetInput()
ICSharpCode.SharpZipLib.Zip.Compression.Inflater.SetInput
void SetInput(byte[] buffer)
Sets the input. This should only be called, if needsInput() returns true.
Definition Inflater.cs:631

, then Inflate() it. If inflate doesn't inflate any bytes there may be three reasons:

- IsNeedingInput() returns true because the input buffer is empty. You have to provide more input with
  SetInput()
  . NOTE: IsNeedingInput() also returns true when, the stream is finished.
- IsNeedingDictionary() returns true, you have to provide a preset dictionary with
  SetDictionary()
  ICSharpCode.SharpZipLib.Zip.Compression.Inflater.SetDictionary
  void SetDictionary(byte[] buffer)
  Sets the preset dictionary. This should only be called, if needsDictionary() returns true and it shou...
  Definition Inflater.cs:570
  .
- IsFinished returns true, the inflater has finished.

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

## Constructor & Destructor Documentation

## ◆ Inflater() [1/2]

ICSharpCode.SharpZipLib.Zip.Compression.Inflater.Inflater | ( |  | ) |

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

## ◆ Inflater() [2/2]

ICSharpCode.SharpZipLib.Zip.Compression.Inflater.Inflater | ( | bool | noHeader | ) |

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.

## Member Function Documentation

## ◆ Decode()

bool ICSharpCode.SharpZipLib.Zip.Compression.Inflater.Decode | ( |  | ) |
| private

Decodes the deflated stream.

Returns
  false if more input is needed, or if finished.

Exceptions

  SharpZipBaseException | if deflated stream is invalid.

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ DecodeChksum()

bool ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DecodeChksum | ( |  | ) |
| private

Decodes the adler checksum after the deflate stream.

Returns
  false if more input is needed.

Exceptions

  SharpZipBaseException | If checksum doesn't match.

Here is the caller graph for this function:

## ◆ DecodeDict()

bool ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DecodeDict | ( |  | ) |
| private

Decodes the dictionary checksum after the deflate header.

Returns
  False if more input is needed.

Here is the caller graph for this function:

## ◆ DecodeHeader()

bool ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DecodeHeader | ( |  | ) |
| private

Decodes a zlib/RFC1950 header.

Returns
  False if more input is needed.

Exceptions

  SharpZipBaseException | The header is invalid.

Here is the caller graph for this function:

## ◆ DecodeHuffman()

bool ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DecodeHuffman | ( |  | ) |
| 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.

Here is the caller graph for this function:

## ◆ Inflate() [1/2]

int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.Inflate | ( | byte[] | buffer | ) |

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

Parameters

  buffer | the output buffer.

Returns
  The number of bytes written to the buffer, 0 if no further output can be produced.

Exceptions

  System.ArgumentOutOfRangeException | if buffer has length 0.
  System.FormatException | if deflated stream is invalid.

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ Inflate() [2/2]

int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.Inflate | ( | byte[] | buffer,
|  | int | offset,
|  | int | count )

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

  buffer | the output buffer.
  offset | the offset in buffer where storing starts.
  count | the maximum number of bytes to output.

Returns
  the number of bytes written to the buffer, 0 if no further output can be produced.

Exceptions

  System.ArgumentOutOfRangeException | if count is less than 0.
  System.ArgumentOutOfRangeException | if the index and / or count are wrong.
  System.FormatException | if deflated stream is invalid.

Here is the call graph for this function:

## ◆ Reset()

void ICSharpCode.SharpZipLib.Zip.Compression.Inflater.Reset | ( |  | ) |

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

## ◆ SetDictionary() [1/2]

void ICSharpCode.SharpZipLib.Zip.Compression.Inflater.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.

Parameters

  buffer | The dictionary.

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ SetDictionary() [2/2]

void ICSharpCode.SharpZipLib.Zip.Compression.Inflater.SetDictionary | ( | byte[] | buffer,
|  | int | index,
|  | int | count )

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.
  index | The index into buffer where the dictionary starts.
  count | The number of bytes in the dictionary.

Exceptions

  System.InvalidOperationException | No dictionary is needed.
  SharpZipBaseException | The adler checksum for the buffer is invalid

## ◆ SetInput() [1/2]

void ICSharpCode.SharpZipLib.Zip.Compression.Inflater.SetInput | ( | byte[] | buffer | ) |

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

Parameters

  buffer | the input.

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ SetInput() [2/2]

void ICSharpCode.SharpZipLib.Zip.Compression.Inflater.SetInput | ( | byte[] | buffer,
|  | int | index,
|  | int | count )

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

Parameters

  buffer | The source of input data
  index | The index into buffer where the input starts.
  count | The number of bytes of input to use.

Exceptions

  System.InvalidOperationException | No input is needed.
  System.ArgumentOutOfRangeException | The index and/or count are wrong.

## Member Data Documentation

## ◆ adler

Adler32 ICSharpCode.SharpZipLib.Zip.Compression.Inflater.adler
| private

## ◆ CPDEXT

readonly 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.

## ◆ CPDIST

readonly 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.

## ◆ CPLENS

readonly 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.

## ◆ CPLEXT

readonly 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.

## ◆ DECODE_BLOCKS

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_BLOCKS = 2
| static private

## ◆ DECODE_CHKSUM

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_CHKSUM = 11
| static private

## ◆ DECODE_DICT

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_DICT = 1
| static private

## ◆ DECODE_DYN_HEADER

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_DYN_HEADER = 6
| static private

## ◆ DECODE_HEADER

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_HEADER = 0
| static private

These are the possible states for an inflater.

## ◆ DECODE_HUFFMAN

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_HUFFMAN = 7
| static private

## ◆ DECODE_HUFFMAN_DIST

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_HUFFMAN_DIST = 9
| static private

## ◆ DECODE_HUFFMAN_DISTBITS

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_HUFFMAN_DISTBITS = 10
| static private

## ◆ DECODE_HUFFMAN_LENBITS

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_HUFFMAN_LENBITS = 8
| static private

## ◆ DECODE_STORED

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_STORED = 5
| static private

## ◆ DECODE_STORED_LEN1

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_STORED_LEN1 = 3
| static private

## ◆ DECODE_STORED_LEN2

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_STORED_LEN2 = 4
| static private

## ◆ distTree

InflaterHuffmanTree ICSharpCode.SharpZipLib.Zip.Compression.Inflater.distTree
| private

## ◆ dynHeader

InflaterDynHeader ICSharpCode.SharpZipLib.Zip.Compression.Inflater.dynHeader
| private

## ◆ FINISHED

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.FINISHED = 12
| static private

## ◆ input

StreamManipulator ICSharpCode.SharpZipLib.Zip.Compression.Inflater.input
| private

## ◆ isLastBlock

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.

## ◆ litlenTree

InflaterHuffmanTree ICSharpCode.SharpZipLib.Zip.Compression.Inflater.litlenTree
| private

## ◆ mode

int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.mode
| private

This variable contains the current state.

## ◆ neededBits

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.

## ◆ noHeader

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.

## ◆ outputWindow

OutputWindow ICSharpCode.SharpZipLib.Zip.Compression.Inflater.outputWindow
| private

## ◆ readAdler

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.

## ◆ repDist

int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.repDist
| private

## ◆ repLength

int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.repLength
| private

## ◆ totalIn

long 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.

## ◆ totalOut

long ICSharpCode.SharpZipLib.Zip.Compression.Inflater.totalOut
| private

The total number of inflated bytes.

## ◆ uncomprLen

int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.uncomprLen
| private

## Property Documentation

## ◆ Adler

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.

## ◆ IsFinished

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.

## ◆ IsNeedingDictionary

bool ICSharpCode.SharpZipLib.Zip.Compression.Inflater.IsNeedingDictionary
| get

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

## ◆ IsNeedingInput

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.

## ◆ RemainingInput

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.

## ◆ TotalIn

long 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.

## ◆ TotalOut

long ICSharpCode.SharpZipLib.Zip.Compression.Inflater.TotalOut
| get

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

Returns
  the total number of output bytes.

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

- ICSharpCode.SharpZLib/Zip/Compression/Inflater.cs