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 |
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.
|
Constructs a default StreamManipulator with all buffers empty.
Definition at line 224 of file StreamManipulator.cs. |
|
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.
Definition at line 183 of file StreamManipulator.cs. Referenced by ICSharpCode::SharpZipLib::Zip::Compression::Streams::OutputWindow::CopyStored(). |
|
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(). |
|
Gets the next n bits and increases input pointer. This is equivalent to PeekBits followed by dropBits, except for correct error handling.
Definition at line 107 of file StreamManipulator.cs. |
|
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.
Definition at line 76 of file StreamManipulator.cs. Referenced by ICSharpCode::SharpZipLib::Zip::Compression::InflaterDynHeader::Decode(), and ICSharpCode::SharpZipLib::Zip::Compression::InflaterHuffmanTree::GetSymbol(). |
|
resets state and empties internal buffers
Definition at line 232 of file StreamManipulator.cs. |
|
Add more input for consumption. Only call when IsNeedingInput returns true.
Definition at line 244 of file StreamManipulator.cs. |
|
Skips to the next byte boundary.
Definition at line 144 of file StreamManipulator.cs. |
|
Definition at line 66 of file StreamManipulator.cs. |
|
Definition at line 65 of file StreamManipulator.cs. |
|
Definition at line 61 of file StreamManipulator.cs. |
|
Definition at line 63 of file StreamManipulator.cs. |
|
Definition at line 62 of file StreamManipulator.cs. |
|
Gets the number of bits available in the bit buffer. This must be only called when a previous PeekBits() returned -1.
Definition at line 123 of file StreamManipulator.cs. Referenced by ICSharpCode::SharpZipLib::Zip::Compression::InflaterHuffmanTree::GetSymbol(). |
|
Gets the number of bytes available.
Definition at line 135 of file StreamManipulator.cs. Referenced by ICSharpCode::SharpZipLib::Zip::Compression::Streams::OutputWindow::CopyStored(). |
|
Returns true when SetInput can be called.
Definition at line 153 of file StreamManipulator.cs. |