C# Class ICSharpCode.SharpZipLib.Zip.Compression.Streams.StreamManipulator

This class allows us to retrieve a specified number of bits from the input buffer, as well as copy big byte blocks. It uses an int buffer to store up to 31 bits for direct manipulation. This guarantees that we can get at least 16 bits, but we only need at most 15, so this is all safe. There are some optimizations in this class, for example, you must never peek more than 8 bits more than needed, and you must first peek bits before you may drop them. This is not a general purpose class but optimized for the behaviour of the Inflater. authors of the original java version : John Leuner, Jochen Hoenicke
Show file Open project: icsharpcode/SharpZipLib Class Usage Examples

Public Methods

Method Description
CopyBytes ( byte output, int offset, int length ) : int

Copies bytes from input buffer to output buffer starting at output[offset]. You have to make sure, that the buffer is byte aligned. If not enough bytes are available, copies fewer bytes.

DropBits ( int bitCount ) : void

Drops the next n bits from the input. You should have called PeekBits with a bigger or equal n before, to make sure that enough bits are in the bit buffer.

GetBits ( int bitCount ) : int

Gets the next n bits and increases input pointer. This is equivalent to PeekBits followed by DropBits, except for correct error handling.

PeekBits ( int bitCount ) : int

Get the next sequence of bits but don't increase input pointer. bitCount must be less or equal 16 and if this call succeeds, you must drop at least n - 8 bits in the next call.

Reset ( ) : void

Resets state and empties internal buffers

SetInput ( byte buffer, int offset, int count ) : void

Add more input for consumption. Only call when IsNeedingInput returns true

SkipToByteBoundary ( ) : void

Skips to the next byte boundary.

Method Details

CopyBytes() public method

Copies bytes from input buffer to output buffer starting at output[offset]. You have to make sure, that the buffer is byte aligned. If not enough bytes are available, copies fewer bytes.
/// Length is less than zero /// /// Bit buffer isnt byte aligned ///
public CopyBytes ( byte output, int offset, int length ) : int
output byte /// The buffer to copy bytes to. ///
offset int /// The offset in the buffer at which copying starts ///
length int /// The length to copy, 0 is allowed. ///
return int

DropBits() public method

Drops the next n bits from the input. You should have called PeekBits with a bigger or equal n before, to make sure that enough bits are in the bit buffer.
public DropBits ( int bitCount ) : void
bitCount int The number of bits to drop.
return void

GetBits() public method

Gets the next n bits and increases input pointer. This is equivalent to PeekBits followed by DropBits, except for correct error handling.
public GetBits ( int bitCount ) : int
bitCount int The number of bits to retrieve.
return int

PeekBits() public method

Get the next sequence of bits but don't increase input pointer. bitCount must be less or equal 16 and if this call succeeds, you must drop at least n - 8 bits in the next call.
public PeekBits ( int bitCount ) : int
bitCount int The number of bits to peek.
return int

Reset() public method

Resets state and empties internal buffers
public Reset ( ) : void
return void

SetInput() public method

Add more input for consumption. Only call when IsNeedingInput returns true
public SetInput ( byte buffer, int offset, int count ) : void
buffer byte data to be input
offset int offset of first byte of input
count int number of bytes of input to add.
return void

SkipToByteBoundary() public method

Skips to the next byte boundary.
public SkipToByteBoundary ( ) : void
return void