#include <BitStream.h>
Public Member Functions | |
BitStream () | |
BitStream (int initialBytesToAllocate) | |
BitStream (const char *_data, unsigned int lengthInBytes, bool _copyData) | |
~BitStream () | |
void | Reset (void) |
void | Write (bool input) |
void | Write (unsigned char input) |
void | Write (char input) |
void | Write (unsigned short input) |
void | Write (short input) |
void | Write (unsigned int input) |
void | Write (int input) |
void | Write (unsigned long input) |
void | Write (long input) |
void | Write (float input) |
void | Write (double input) |
void | Write (char *input, int numberOfBytes) |
void | WriteCompressed (unsigned char input) |
void | WriteCompressed (char input) |
void | WriteCompressed (unsigned short input) |
void | WriteCompressed (short input) |
void | WriteCompressed (unsigned int input) |
void | WriteCompressed (int input) |
void | WriteCompressed (unsigned long input) |
void | WriteCompressed (long input) |
void | WriteCompressed (float input) |
void | WriteCompressed (double input) |
bool | Read (bool &output) |
bool | Read (unsigned char &output) |
bool | Read (char &output) |
bool | Read (unsigned short &output) |
bool | Read (short &output) |
bool | Read (unsigned int &output) |
bool | Read (int &output) |
bool | Read (unsigned long &output) |
bool | Read (long &output) |
bool | Read (float &output) |
bool | Read (double &output) |
bool | Read (char *output, int numberOfBytes) |
bool | ReadCompressed (unsigned char &output) |
bool | ReadCompressed (char &output) |
bool | ReadCompressed (unsigned short &output) |
bool | ReadCompressed (short &output) |
bool | ReadCompressed (unsigned int &output) |
bool | ReadCompressed (int &output) |
bool | ReadCompressed (unsigned long &output) |
bool | ReadCompressed (long &output) |
bool | ReadCompressed (float &output) |
bool | ReadCompressed (double &output) |
void | ResetReadPointer (void) |
void | AssertStreamEmpty (void) |
void | PrintBits (void) const |
void | IgnoreBits (int numberOfBits) |
void | SetWriteOffset (int offset) |
int | GetNumberOfBitsUsed (void) const |
int | GetNumberOfBytesUsed (void) const |
int | GetReadOffset (void) const |
int | GetNumberOfUnreadBits (void) const |
int | CopyData (unsigned char **_data) const |
void | SetData (const unsigned char *input, int numberOfBits) |
unsigned char * | GetData (void) const |
void | WriteBits (unsigned char *input, int numberOfBitsToWrite, bool rightAlignedBits=true) |
void | WriteAlignedBytes (unsigned char *input, int numberOfBytesToWrite) |
bool | ReadAlignedBytes (unsigned char *output, int numberOfBytesToRead) |
void | AlignWriteToByteBoundary (void) |
void | AlignReadToByteBoundary (void) |
bool | ReadBits (unsigned char *output, int numberOfBitsToRead, bool alignBitsToRight=true) |
void | Write0 (void) |
void | Write1 (void) |
bool | ReadBit (void) |
void | AssertCopyData (void) |
void | SetNumberOfBitsAllocated (unsigned int lengthInBits) |
Private Member Functions | |
void | WriteCompressed (unsigned char *input, int size, bool unsignedData) |
bool | ReadCompressed (unsigned char *output, int size, bool unsignedData) |
void | AddBitsAndReallocate (int numberOfBitsToWrite) |
Private Attributes | |
int | numberOfBitsUsed |
int | numberOfBitsAllocated |
int | readOffset |
unsigned char * | data |
bool | copyData |
Helper class to encode and decode packets.
|
Default Constructor |
|
Preallocate some memory for the construction of the packet
|
|
Initialize the BitStream object using data from the network. Set _copyData to true if you want to make an internal copy of the data you are passing. You can then Write and do all other operations Set it to false if you want to just use a pointer to the data you are passing, in order to save memory and speed. You should only then do read operations.
|
|
Destructor |
|
Reallocates (if necessary) in preparation of writing numberOfBitsToWrite |
|
Align the next write and/or read to a byte boundary. This can be used to 'waste' bits to byte align for efficiency reasons It can also be used to force coalesced bitstreams to start on byte boundaries so so WriteAlignedBits and ReadAlignedBits both calculate the same offset when aligning. |
|
Align the next write and/or read to a byte boundary. This can be used to 'waste' bits to byte align for efficiency reasons It can also be used to force coalesced bitstreams to start on byte boundaries so so WriteAlignedBits and ReadAlignedBits both calculate the same offset when aligning. |
|
If we used the constructor version with copy data off, this makes sure it is set to on and the data pointed to is copied. |
|
This is good to call when you are done with the stream to make sure you didn't leave any data left over void |
|
Makes a copy of the internal data for you Data will point to the stream. Returns the length in bits of the stream. Partial bytes are left aligned
|
|
Exposes the internal data. Partial bytes are left aligned.
|
|
Returns the length in bits of the stream |
|
Returns the length in bytes of the stream |
|
Returns the number of bits left in the stream that haven't been read |
|
Returns the number of bits into the stream that we have read |
|
Ignore data we don't intend to read
|
|
print to the standard output the state of the stream bit by bit |
|
Read an array or casted stream of byte. The array is raw data. There is no automatic conversion on big endian arch
|
|
Read the native types from the front of the buffer
|
|
Read the native types from the front of the buffer
|
|
Read the native types from the front of the buffer
|
|
Read the native types from the front of the buffer
|
|
Read the native types from the front of the buffer
|
|
Read the native types from the front of the buffer
|
|
Read the native types from the front of the buffer
|
|
Read the native types from the front of the buffer
|
|
Read the native types from the front of the buffer
|
|
Read the native types from the front of the buffer
|
|
Read the native types from the front of the buffer
|
|
Read bits, starting at the next aligned bits. Note that the modulus 8 starting offset of the sequence must be the same as was used with WriteBits. This will be a problem with packet coalescence unless you byte align the coalesced packets.
|
|
--- Low level functions --- These are for when you want to deal with bits and don't care about type checking Reads 1 bit and returns true if that bit is 1 and false if it is 0 |
|
Read numberOfBitsToRead bits to the output source alignBitsToRight should be set to true to convert internal bitstream data to userdata It should be false if you used WriteBits with rightAlignedBits false
|
|
Assume the input source points to a compressed native type. Decompress and read it. |
|
Read the types you wrote with WriteCompressed
|
|
Read the types you wrote with WriteCompressed
|
|
Read the types you wrote with WriteCompressed
|
|
Read the types you wrote with WriteCompressed
|
|
Read the types you wrote with WriteCompressed
|
|
Read the types you wrote with WriteCompressed
|
|
Read the types you wrote with WriteCompressed
|
|
Read the types you wrote with WriteCompressed
|
|
Read the types you wrote with WriteCompressed
|
|
Read the types you wrote with WriteCompressed
|
|
Reset the bitstream for reuse |
|
Sets the read pointer back to the beginning of your data. |
|
Set the stream to some initial data. For internal use Partial bytes are left aligned
|
|
Use this if you pass a pointer copy to the constructor (_copyData==false) and want to overallocate to prevent reallocation |
|
Move the write pointer to a position on the array.
|
|
Write an array or casted stream. It is supossed to be raw data. It is also not possible to deal with endian problem
|
|
Write the native types to the end of the buffer without any compression mecanism.
|
|
Write the native types to the end of the buffer without any compression mecanism.
|
|
Write the native types to the end of the buffer without any compression mecanism.
|
|
Write the native types to the end of the buffer without any compression mecanism.
|
|
Write the native types to the end of the buffer without any compression mecanism.
|
|
Write the native types to the end of the buffer without any compression mecanism.
|
|
Write the native types to the end of the buffer without any compression mecanism.
|
|
Write the native types to the end of the buffer without any compression mecanism.
|
|
Write the native types to the end of the buffer without any compression mecanism.
|
|
Write the native types to the end of the buffer without any compression mecanism.
|
|
Write the native types to the end of the buffer without any compression mecanism.
|
|
--- Low level functions --- These are for when you want to deal with bits and don't care about type checking Write a 0 |
|
--- Low level functions --- These are for when you want to deal with bits and don't care about type checking Write a 1 |
|
Align the bitstream to the byte boundary and then write the specified number of bits. This is faster than WriteBits but wastes the bits to do the alignment and requires you to call ReadAlignedBits at the corresponding read position.
|
|
Write numberToWrite bits from the input source Right aligned data means in the case of a partial byte, the bits are aligned from the right (bit 0) rather than the left (as in the normal internal representation) You would set this to true when writing user data, and false when copying bitstream data, such as writing one bitstream to another
|
|
Assume the input source points to a native type, compress and write it. |
|
Write the native types with simple compression. Best used with negatives and positives close to 0
|
|
Write the native types with simple compression. Best used with negatives and positives close to 0
|
|
Write the native types with simple compression. Best used with negatives and positives close to 0
|
|
Write the native types with simple compression. Best used with negatives and positives close to 0
|
|
Write the native types with simple compression. Best used with negatives and positives close to 0
|
|
Write the native types with simple compression. Best used with negatives and positives close to 0
|
|
Write the native types with simple compression. Best used with negatives and positives close to 0
|
|
Write the native types with simple compression. Best used with negatives and positives close to 0
|
|
Write the native types with simple compression. Best used with negatives and positives close to 0
|
|
Write the native types with simple compression. Best used with negatives and positives close to 0
|
|
true if the internal buffer is copy of the data passed to the constructor |
|
array of byte storing the data |
|
Number of bits currently allocated |
|
Number of bits currently used |
|
Current readOffset |