ICSharpCode::SharpZipLib::Zip::Compression::Streams::StreamManipulator Class Reference

This class allows us to retrieve a specified number of bits from the input buffer, as well as copy big byte blocks. More...

List of all members.

Public Member Functions

</returns > *int PeekBits (int n)
 Get the next n bits but don't increase input pointer. n must be less or equal 16 and if this call succeeds, you must drop at least n - 8 bits in the next call.
void DropBits (int n)
 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.
int GetBits (int n)
 Gets the next n bits and increases input pointer. This is equivalent to PeekBits followed by dropBits, except for correct error handling.
void SkipToByteBoundary ()
 Skips to the next byte boundary.
int CopyBytes (byte[] output, int offset, int length)
 Copies length 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.
 StreamManipulator ()
 Constructs a default StreamManipulator with all buffers empty.
void Reset ()
 resets state and empties internal buffers
void SetInput (byte[] buf, int off, int len)
 Add more input for consumption. Only call when IsNeedingInput returns true.

Properties

int AvailableBits
 Gets the number of bits available in the bit buffer. This must be only called when a previous PeekBits() returned -1.
int AvailableBytes
 Gets the number of bytes available.
bool IsNeedingInput
 Returns true when SetInput can be called.

Private Attributes

byte[] window
int window_start = 0
int window_end = 0
uint buffer = 0
int bits_in_buffer = 0


Detailed Description

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

Definition at line 59 of file StreamManipulator.cs.


Constructor & Destructor Documentation

ICSharpCode::SharpZipLib::Zip::Compression::Streams::StreamManipulator::StreamManipulator  )  [inline]
 

Constructs a default StreamManipulator with all buffers empty.

Definition at line 224 of file StreamManipulator.cs.


Member Function Documentation

int ICSharpCode::SharpZipLib::Zip::Compression::Streams::StreamManipulator::CopyBytes byte[]  output,
int  offset,
int  length
[inline]
 

Copies length 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.

Parameters:
output The buffer to copy bytes to.
offset The offset in the buffer at which copying starts
length The length to copy, 0 is allowed.
Returns:
The number of bytes copied, 0 if no bytes were available.
Exceptions:
ArgumentOutOfRangeException Length is less than zero
InvalidOperationException Bit buffer isnt byte aligned

Definition at line 183 of file StreamManipulator.cs.

Referenced by ICSharpCode::SharpZipLib::Zip::Compression::Streams::OutputWindow::CopyStored().

void ICSharpCode::SharpZipLib::Zip::Compression::Streams::StreamManipulator::DropBits int  n  )  [inline]
 

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.

Definition at line 94 of file StreamManipulator.cs.

Referenced by ICSharpCode::SharpZipLib::Zip::Compression::InflaterDynHeader::Decode(), and ICSharpCode::SharpZipLib::Zip::Compression::InflaterHuffmanTree::GetSymbol().

int ICSharpCode::SharpZipLib::Zip::Compression::Streams::StreamManipulator::GetBits int  n  )  [inline]
 

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

Returns:
the value of the bits, or -1 if not enough bits available.

Definition at line 107 of file StreamManipulator.cs.

</returns> * int ICSharpCode::SharpZipLib::Zip::Compression::Streams::StreamManipulator::PeekBits int  n  )  [inline]
 

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

Returns:
the value of the bits, or -1 if not enough bits available.

Definition at line 76 of file StreamManipulator.cs.

Referenced by ICSharpCode::SharpZipLib::Zip::Compression::InflaterDynHeader::Decode(), and ICSharpCode::SharpZipLib::Zip::Compression::InflaterHuffmanTree::GetSymbol().

void ICSharpCode::SharpZipLib::Zip::Compression::Streams::StreamManipulator::Reset  )  [inline]
 

resets state and empties internal buffers

Definition at line 232 of file StreamManipulator.cs.

void ICSharpCode::SharpZipLib::Zip::Compression::Streams::StreamManipulator::SetInput byte[]  buf,
int  off,
int  len
[inline]
 

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

Parameters:
buf data to be input
off offset of first byte of input
len length of input

Definition at line 244 of file StreamManipulator.cs.

void ICSharpCode::SharpZipLib::Zip::Compression::Streams::StreamManipulator::SkipToByteBoundary  )  [inline]
 

Skips to the next byte boundary.

Definition at line 144 of file StreamManipulator.cs.


Member Data Documentation

int ICSharpCode::SharpZipLib::Zip::Compression::Streams::StreamManipulator::bits_in_buffer = 0 [private]
 

Definition at line 66 of file StreamManipulator.cs.

uint ICSharpCode::SharpZipLib::Zip::Compression::Streams::StreamManipulator::buffer = 0 [private]
 

Definition at line 65 of file StreamManipulator.cs.

byte [] ICSharpCode::SharpZipLib::Zip::Compression::Streams::StreamManipulator::window [private]
 

Definition at line 61 of file StreamManipulator.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Streams::StreamManipulator::window_end = 0 [private]
 

Definition at line 63 of file StreamManipulator.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Streams::StreamManipulator::window_start = 0 [private]
 

Definition at line 62 of file StreamManipulator.cs.


Property Documentation

int ICSharpCode::SharpZipLib::Zip::Compression::Streams::StreamManipulator::AvailableBits [get]
 

Gets the number of bits available in the bit buffer. This must be only called when a previous PeekBits() returned -1.

Returns:
the number of bits available.

Definition at line 123 of file StreamManipulator.cs.

Referenced by ICSharpCode::SharpZipLib::Zip::Compression::InflaterHuffmanTree::GetSymbol().

int ICSharpCode::SharpZipLib::Zip::Compression::Streams::StreamManipulator::AvailableBytes [get]
 

Gets the number of bytes available.

Returns:
The number of bytes available.

Definition at line 135 of file StreamManipulator.cs.

Referenced by ICSharpCode::SharpZipLib::Zip::Compression::Streams::OutputWindow::CopyStored().

bool ICSharpCode::SharpZipLib::Zip::Compression::Streams::StreamManipulator::IsNeedingInput [get]
 

Returns true when SetInput can be called.

Definition at line 153 of file StreamManipulator.cs.


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