BitStream Class Reference

#include <bitStream.h>

Inheritance diagram for BitStream:

Inheritance graph
[legend]
List of all members.

Public Member Functions

void setBuffer (void *bufPtr, S32 bufSize, S32 maxSize=0)
U8getBuffer ()
U8getBytePtr ()
U32 getReadByteSize ()
S32 getCurPos () const
void setCurPos (const U32)
S32 getBitPosition () const
void clearStringBuffer ()
 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)
 Use this method to write out values in a concise but ass backwards way.
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)
 Writes a clamped signed integer to the stream using an optimal amount of bits for the range.
S32 readRangedS32 (S32 min, S32 max)
 Reads a ranged signed integer written with writeRangedS32.
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)
 Writes a clamped floating point value to the stream with the desired bits of precision.
F32 readRangedF32 (F32 min, F32 max, U32 numBits)
 Reads a ranged floating point value written with writeRangedF32.
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)
bool writeFlag (U32 val)
bool writeFlag (void *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.
void writeString (const char *stringBuf, S32 maxLen=255)
 Writes a string to the stream.
bool hasCapability (const Capability) const
U32 getPosition () const
 Gets the position in the stream.
bool setPosition (const U32 in_newPosition)
 Sets the position of the stream. Returns if the new position is valid or not.
U32 getStreamSize ()
 Gets the size of the stream.

Static Public Member Functions

static BitStreamgetPacketStream (U32 writeSize=0)
static void sendPacketStream (const NetAddress *addr)
static Point3F dumbDownNormal (const Point3F &vec, S32 bitCount)

Protected Attributes

U8dataPtr
S32 bitNum
S32 bufSize
bool error
S32 maxReadBitNum
S32 maxWriteBitNum
char * stringBuffer
Point3F mCompressPoint

Friends

class HuffmanProcessor

Constructor & Destructor Documentation

BitStream::BitStream ( void bufPtr,
S32  bufSize,
S32  maxWriteSize = -1 
) [inline]


Member Function Documentation

static BitStream* BitStream::getPacketStream ( U32  writeSize = 0  )  [static]

static void BitStream::sendPacketStream ( const NetAddress addr  )  [static]

void BitStream::setBuffer ( void bufPtr,
S32  bufSize,
S32  maxSize = 0 
)

U8* BitStream::getBuffer (  )  [inline]

U8* BitStream::getBytePtr (  ) 

U32 BitStream::getReadByteSize (  ) 

S32 BitStream::getCurPos (  )  const [inline]

void BitStream::setCurPos ( const   U32  )  [inline]

S32 BitStream::getBitPosition (  )  const [inline]

void BitStream::clearStringBuffer (  ) 

void BitStream::clear (  ) 

void BitStream::setStringBuffer ( char  buffer[256]  ) 

void BitStream::writeInt ( S32  value,
S32  bitCount 
)

S32 BitStream::readInt ( S32  bitCount  ) 

void BitStream::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.

U32 BitStream::readCussedU32 (  )  [inline]

void BitStream::writeSignedInt ( S32  value,
S32  bitCount 
)

S32 BitStream::readSignedInt ( S32  bitCount  ) 

void BitStream::writeRangedU32 ( U32  value,
U32  rangeStart,
U32  rangeEnd 
) [inline]

U32 BitStream::readRangedU32 ( U32  rangeStart,
U32  rangeEnd 
) [inline]

void BitStream::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.

S32 BitStream::readRangedS32 ( S32  min,
S32  max 
) [inline]

Reads a ranged signed integer written with writeRangedS32.

F32 BitStream::readFloat ( S32  bitCount  ) 

F32 BitStream::readSignedFloat ( S32  bitCount  ) 

void BitStream::writeFloat ( F32  f,
S32  bitCount 
)

void BitStream::writeSignedFloat ( F32  f,
S32  bitCount 
)

void BitStream::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.

F32 BitStream::readRangedF32 ( F32  min,
F32  max,
U32  numBits 
) [inline]

Reads a ranged floating point value written with writeRangedF32.

void BitStream::writeClassId ( U32  classId,
U32  classType,
U32  classGroup 
)

S32 BitStream::readClassId ( U32  classType,
U32  classGroup 
)

void BitStream::writeNormalVector ( const Point3F vec,
S32  bitCount 
)

void BitStream::readNormalVector ( Point3F vec,
S32  bitCount 
)

void BitStream::clearCompressionPoint (  ) 

void BitStream::setCompressionPoint ( const Point3F p  ) 

void BitStream::writeCompressedPoint ( const Point3F p,
F32  scale = 0.01f 
)

void BitStream::readCompressedPoint ( Point3F p,
F32  scale = 0.01f 
)

static Point3F BitStream::dumbDownNormal ( const Point3F vec,
S32  bitCount 
) [static]

void BitStream::writeNormalVector ( const Point3F vec,
S32  angleBitCount,
S32  zBitCount 
)

void BitStream::readNormalVector ( Point3F vec,
S32  angleBitCount,
S32  zBitCount 
)

void BitStream::readVector ( Point3F vec,
F32  minMag,
F32  maxMag,
S32  magBits,
S32  angleBits,
S32  zBits 
)

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

void BitStream::writeAffineTransform ( const MatrixF  ) 

void BitStream::readAffineTransform ( MatrixF  ) 

virtual void BitStream::writeBits ( S32  bitCount,
const void bitPtr 
) [virtual]

Reimplemented in InfiniteBitStream.

virtual void BitStream::readBits ( S32  bitCount,
void bitPtr 
) [virtual]

virtual bool BitStream::writeFlag ( bool  val  )  [virtual]

Reimplemented in InfiniteBitStream.

bool BitStream::writeFlag ( U32  val  )  [inline]

bool BitStream::writeFlag ( void val  )  [inline]

bool BitStream::readFlag (  )  [inline, virtual]

void BitStream::setBit ( S32  bitCount,
bool  set 
)

bool BitStream::testBit ( S32  bitCount  ) 

bool BitStream::isFull (  )  [inline]

bool BitStream::isValid (  )  [inline]

bool BitStream::_read ( const U32  size,
void d 
) [virtual]

Implements Stream.

bool BitStream::_write ( const U32  size,
const void d 
) [virtual]

Implements Stream.

void BitStream::readString ( char  stringBuf[256]  )  [virtual]

Reads a string of maximum 255 characters long.

Reimplemented from Stream.

void BitStream::writeString ( const char *  stringBuf,
S32  maxLen = 255 
) [virtual]

Writes a string to the stream.

Reimplemented from Stream.

bool BitStream::hasCapability ( const   Capability  )  const [inline]

U32 BitStream::getPosition (  )  const [virtual]

Gets the position in the stream.

Implements Stream.

bool BitStream::setPosition ( const U32  in_newPosition  )  [virtual]

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

Implements Stream.

U32 BitStream::getStreamSize (  )  [virtual]

Gets the size of the stream.

Implements Stream.


Friends And Related Function Documentation

friend class HuffmanProcessor [friend]


Member Data Documentation

U8* BitStream::dataPtr [protected]

S32 BitStream::bitNum [protected]

S32 BitStream::bufSize [protected]

bool BitStream::error [protected]

char* BitStream::stringBuffer [protected]