Torque2D Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
BitStream Class Reference

`#include <bitStream.h>`

Inheritance diagram for BitStream:

## Public Member Functions
void | setBuffer (void *bufPtr, S32 bufSize, S32 maxSize=0)
U8 * | getBuffer ()
U8 * | getBytePtr ()
U32 | getReadByteSize ()
S32 | getCurPos () const
void | setCurPos (const U32)
| BitStream (void *bufPtr, S32 bufSize, S32 maxWriteSize=-1)
void | clear ()
void | setStringBuffer (char buffer[256])
void | writeInt (S32 value, S32 bitCount)
S32 | readInt (S32 bitCount)
void | writeCussedU32 (U32 val)
U32 | readCussedU32 ()
void | writeSignedInt (S32 value, S32 bitCount)
S32 | readSignedInt (S32 bitCount)
void | writeRangedU32 (U32 value, U32 rangeStart, U32 rangeEnd)
U32 | readRangedU32 (U32 rangeStart, U32 rangeEnd)
void | writeRangedS32 (S32 value, S32 min, S32 max)
S32 | readRangedS32 (S32 min, S32 max)
| Reads a ranged signed integer written with writeRangedS32. More...
F32 | readFloat (S32 bitCount)
F32 | readSignedFloat (S32 bitCount)
void | writeFloat (F32 f, S32 bitCount)
void | writeSignedFloat (F32 f, S32 bitCount)
void | writeRangedF32 (F32 value, F32 min, F32 max, U32 numBits)
F32 | readRangedF32 (F32 min, F32 max, U32 numBits)
| Reads a ranged floating point value written with writeRangedF32. More...
void | writeClassId (U32 classId, U32 classType, U32 classGroup)
S32 | readClassId (U32 classType, U32 classGroup)
void | writeNormalVector (const Point3F &vec, S32 bitCount)
void | readNormalVector (Point3F *vec, S32 bitCount)
void | clearCompressionPoint ()
void | setCompressionPoint (const Point3F &p)
void | writeCompressedPoint (const Point3F &p, F32 scale=0.01f)
void | readCompressedPoint (Point3F *p, F32 scale=0.01f)
void | writeNormalVector (const Point3F &vec, S32 angleBitCount, S32 zBitCount)
void | readNormalVector (Point3F *vec, S32 angleBitCount, S32 zBitCount)
void | readVector (Point3F *vec, F32 minMag, F32 maxMag, S32 magBits, S32 angleBits, S32 zBits)
void | writeVector (Point3F vec, F32 minMag, F32 maxMag, S32 magBits, S32 angleBits, S32 zBits)
void | writeAffineTransform (const MatrixF &)
void | readAffineTransform (MatrixF *)
virtual void | writeBits (S32 bitCount, const void *bitPtr)
virtual void | readBits (S32 bitCount, void *bitPtr)
virtual bool | writeFlag (bool val)
virtual bool | readFlag ()
void | setBit (S32 bitCount, bool set)
bool | testBit (S32 bitCount)
bool | isFull ()
bool | isValid ()
bool | _read (const U32 size, void *d)
bool | _write (const U32 size, const void *d)
void | readString (char stringBuf[256])
| Reads a string of maximum 255 characters long. More...
void | writeString (const char *stringBuf, S32 maxLen=255)
| Writes a string to the stream. More...
bool | hasCapability (const Capability) const
| Checks to see if this stream has the capability of a given function. More...
U32 | getPosition () const
| Gets the position in the stream. More...
bool | setPosition (const U32 in_newPosition)
| Sets the position of the stream. Returns if the new position is valid or not. More...
U32 | getStreamSize ()
| Gets the size of the stream. More...
Public Member Functions inherited from Stream
| Stream ()
virtual | ~Stream ()
Stream::Status | getStatus () const
| Gets the status of the stream. More...
void | readLine (U8 *buffer, U32 bufferSize)
void | writeLine (U8 *buffer)
| writes a line to the stream More...
const char * | readSTString (bool casesens=false)
void | readLongString (U32 maxStringLen, char *stringBuf)
void | writeLongString (U32 maxStringLen, const char *string)
bool | Put (char character)
bool | writeFormattedBuffer (const char *format,...)
bool | writeStringBuffer (const char *buffer)
| Writes a NULL terminated string buffer. More...
bool | write (const ColorI &)
| Write an integral color to the stream. More...
bool | write (const ColorF &)
| Write a floating point color to the stream. More...
bool | read (ColorI *)
| Read an integral color from the stream. More...
bool | read (ColorF *)
| Read a floating point color from the stream. More...
bool | read (const U32 in_numBytes, void *out_pBuffer)
bool | write (const U32 in_numBytes, const void *in_pBuffer)
bool | read (bool *out_pRead)
bool | write (const bool &in_rWrite)
bool | copyFrom (Stream *other)
| Copy the contents of another stream into this one. More...
void | writeTabs (U32 count)
| Write a number of tabs to this stream. More...

## Static Public Member Functions
static BitStream * | getPacketStream (U32 writeSize=0)
static void | sendPacketStream (const NetAddress *addr)
static Point3F | dumbDownNormal (const Point3F &vec, S32 bitCount)
Static Public Member Functions inherited from Stream
static const char * | getStatusString (const Status in_status)
| Gets a printable string form of the status. More...

## Protected Attributes
U8 * | dataPtr
S32 | bitNum
S32 | bufSize
bool | error
S32 | maxReadBitNum
S32 | maxWriteBitNum
char * | stringBuffer
bool | mCompressRelative
Point3F | mCompressPoint

## Friends
class | HuffmanProcessor

## Additional Inherited Members
Public Types inherited from Stream
enum | Status { Ok = 0, IOError, EOS, IllegalCall, Closed, UnknownError }
| Status constantants for the stream. More...
enum | Capability { StreamWrite = BIT(0), StreamRead = BIT(1), StreamPosition = BIT(2) }
Protected Member Functions inherited from Stream
void | setStatus (const Status in_newStatus)

## Constructor & Destructor Documentation

BitStream | ( | void * | bufPtr,
|  | S32 | bufSize,
|  | S32 | maxWriteSize = `-1`
| ) |  |
| inline

## Member Function Documentation

bool _read | ( | const U32 | size,
|  | void * | d
| ) |  |
| virtual

Implements Stream.

bool _write | ( | const U32 | size,
|  | const void * | d
| ) |  |
| virtual

Implements Stream.

void clear | ( |  | ) |

void clearCompressionPoint | ( |  | ) |

Point3F dumbDownNormal | ( | const Point3F & | vec,
|  | S32 | bitCount
| ) |  |
| static

U8* getBuffer | ( |  | ) |
| inline

U8 * getBytePtr | ( |  | ) |

S32 getCurPos | ( |  | ) | const
| inline

BitStream * getPacketStream | ( | U32 | writeSize = `0` | ) |
| static

U32 getPosition | ( |  | ) | const
| virtual

Gets the position in the stream.

Implements Stream.

U32 getReadByteSize | ( |  | ) |

U32 getStreamSize | ( |  | ) |
| virtual

Gets the size of the stream.

Implements Stream.

bool hasCapability | ( | const Capability |  | ) | const
| inline virtual

Checks to see if this stream has the capability of a given function.

Implements Stream.

bool isFull | ( |  | ) |
| inline

bool isValid | ( |  | ) |
| inline

void readAffineTransform | ( | MatrixF * | matrix | ) |

void readBits | ( | S32 | bitCount,
|  | void * | bitPtr
| ) |  |
| virtual

S32 readClassId | ( | U32 | classType,
|  | U32 | classGroup
| ) |  |

void readCompressedPoint | ( | Point3F * | p,
|  | F32 | scale = `0.01f`
| ) |  |

U32 readCussedU32 | ( |  | ) |
| inline

bool readFlag | ( |  | ) |
| inline virtual

F32 readFloat | ( | S32 | bitCount | ) |

S32 readInt | ( | S32 | bitCount | ) |

void readNormalVector | ( | Point3F * | vec,
|  | S32 | bitCount
| ) |  |

void readNormalVector | ( | Point3F * | vec,
|  | S32 | angleBitCount,
|  | S32 | zBitCount
| ) |  |

F32 readRangedF32 | ( | F32 | min,
|  | F32 | max,
|  | U32 | numBits
| ) |  |
| inline

Reads a ranged floating point value written with writeRangedF32.

S32 readRangedS32 | ( | S32 | min,
|  | S32 | max
| ) |  |
| inline

Reads a ranged signed integer written with writeRangedS32.

U32 readRangedU32 | ( | U32 | rangeStart,
|  | U32 | rangeEnd
| ) |  |
| inline

F32 readSignedFloat | ( | S32 | bitCount | ) |

S32 readSignedInt | ( | S32 | bitCount | ) |

void readString | ( | char | stringBuf[256] | ) |
| virtual

Reads a string of maximum 255 characters long.

Reimplemented from Stream.

void readVector | ( | Point3F * | vec,
|  | F32 | minMag,
|  | F32 | maxMag,
|  | S32 | magBits,
|  | S32 | angleBits,
|  | S32 | zBits
| ) |  |

void sendPacketStream | ( | const NetAddress * | addr | ) |
| static

void setBit | ( | S32 | bitCount,
|  | bool | set
| ) |  |

void setBuffer | ( | void * | bufPtr,
|  | S32 | bufSize,
|  | S32 | maxSize = `0`
| ) |  |

void setCompressionPoint | ( | const Point3F & | p | ) |

void setCurPos | ( | const U32 | in_position | ) |
| inline

bool setPosition | ( | const U32 | in_newPosition | ) |
| virtual

Sets the position of the stream. Returns if the new position is valid or not.

Implements Stream.

void setStringBuffer | ( | char | buffer[256] | ) |

bool testBit | ( | S32 | bitCount | ) |

void writeAffineTransform | ( | const MatrixF & | matrix | ) |

void writeBits | ( | S32 | bitCount,
|  | const void * | bitPtr
| ) |  |
| virtual

Reimplemented in InfiniteBitStream.

void writeClassId | ( | U32 | classId,
|  | U32 | classType,
|  | U32 | classGroup
| ) |  |

void writeCompressedPoint | ( | const Point3F & | p,
|  | F32 | scale = `0.01f`
| ) |  |

void writeCussedU32 | ( | U32 | val | ) |
| inline

Use this method to write out values in a concise but ass backwards way... Good for values you expect to be frequently zero, often small. Worst case this will bloat values by nearly 20% (5 extra bits!) Best case you'll get one bit (if it's zero).

This is not so much for efficiency's sake, as to make life painful for people that want to reverse engineer our network or file formats.

bool writeFlag | ( | bool | val | ) |
| virtual

Reimplemented in InfiniteBitStream.

void writeFloat | ( | F32 | f,
|  | S32 | bitCount
| ) |  |

void writeInt | ( | S32 | value,
|  | S32 | bitCount
| ) |  |

void writeNormalVector | ( | const Point3F & | vec,
|  | S32 | bitCount
| ) |  |

void writeNormalVector | ( | const Point3F & | vec,
|  | S32 | angleBitCount,
|  | S32 | zBitCount
| ) |  |

void writeRangedF32 | ( | F32 | value,
|  | F32 | min,
|  | F32 | max,
|  | U32 | numBits
| ) |  |
| inline

Writes a clamped floating point value to the stream with the desired bits of precision.

void writeRangedS32 | ( | S32 | value,
|  | S32 | min,
|  | S32 | max
| ) |  |
| inline

Writes a clamped signed integer to the stream using an optimal amount of bits for the range.

void writeRangedU32 | ( | U32 | value,
|  | U32 | rangeStart,
|  | U32 | rangeEnd
| ) |  |
| inline

void writeSignedFloat | ( | F32 | f,
|  | S32 | bitCount
| ) |  |

void writeSignedInt | ( | S32 | value,
|  | S32 | bitCount
| ) |  |

void writeString | ( | const char * | stringBuf,
|  | S32 | maxLen = `255`
| ) |  |
| virtual

Writes a string to the stream.

Reimplemented from Stream.

void writeVector | ( | Point3F | vec,
|  | F32 | minMag,
|  | F32 | maxMag,
|  | S32 | magBits,
|  | S32 | angleBits,
|  | S32 | zBits
| ) |  |

## Friends And Related Function Documentation

friend class HuffmanProcessor
| friend

## Member Data Documentation

S32 bitNum
| protected

S32 bufSize
| protected

U8* dataPtr
| protected

bool error
| protected

S32 maxReadBitNum
| protected

S32 maxWriteBitNum
| protected

Point3F mCompressPoint
| protected

bool mCompressRelative
| protected

char* stringBuffer
| protected

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

- io/bitStream.h
- io/bitStream.cc