ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB > Class Template Reference

A template implementing a bit stream for different data memory layouts. More...

#include <bitstream.h>

Inheritance diagram for Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >:

List of all members.

Public Member Functions

 BitStreamImpl (STREAM *stream, DisposeAfterUse::Flag disposeAfterUse=DisposeAfterUse::NO)
 Create a bit stream using this input data stream and optionally delete it on destruction.
 BitStreamImpl (STREAM &stream)
 Create a bit stream using this input data stream.
 ~BitStreamImpl ()
uint32 getBit ()
 Read a bit from the bit stream.
uint32 getBits (uint8 n)
 Read a multi-bit value from the bit stream.
uint32 peekBit ()
 Read a bit from the bit stream, without changing the stream's position.
uint32 peekBits (uint8 n)
 Read a multi-bit value from the bit stream, without changing the stream's position.
void addBit (uint32 &x, uint32 n)
 Add a bit to the value x, making it an n+1-bit value.
void rewind ()
 Rewind the bit stream back to the start.
void skip (uint32 n)
 Skip the specified amount of bits.
void align ()
 Skip the bits to closest data value border.
uint32 pos () const
 Return the stream position in bits.
uint32 size () const
 Return the stream size in bits.
bool eos () const

Private Member Functions

uint32 readData ()
 Read a data value.
void readValue ()
 Read the next data value.
uint32 getBit_internal ()

Private Attributes

STREAM * _stream
 The input stream.
DisposeAfterUse::Flag _disposeAfterUse
 Should we delete the stream on destruction?
uint32 _value
 Current value.
uint8 _inValue
 Position within the current value.
uint32 _size
 Total bitstream size (in bits).
uint32 _pos
 Current bitstream position (in bits).

Detailed Description

template<class STREAM, int valueBits, bool isLE, bool isMSB2LSB>
class Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >

A template implementing a bit stream for different data memory layouts.

Such a bit stream reads valueBits-wide values from the data stream and gives access to their bits, one at a time.

For example, a bit stream with the layout parameters 32, true, false for valueBits, isLE and isMSB2LSB, reads 32bit little-endian values from the data stream and hands out the bits in the order of LSB to MSB.

Definition at line 47 of file bitstream.h.


Constructor & Destructor Documentation

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::BitStreamImpl ( STREAM *  stream,
DisposeAfterUse::Flag  disposeAfterUse = DisposeAfterUse::NO 
) [inline]

Create a bit stream using this input data stream and optionally delete it on destruction.

Definition at line 95 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::BitStreamImpl ( STREAM &  stream  )  [inline]

Create a bit stream using this input data stream.

Definition at line 105 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::~BitStreamImpl (  )  [inline]

Definition at line 114 of file bitstream.h.


Member Function Documentation

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
void Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::addBit ( uint32 x,
uint32  n 
) [inline]

Add a bit to the value x, making it an n+1-bit value.

The current value is shifted and the bit is added to the appropriate place, dependant on the stream's bitorder.

For example: A bit y is added to the value 00001100 with size 4. If the stream's bitorder is MSB2LSB, the resulting value is 0001100y. If the stream's bitorder is LSB2MSB, the resulting value is 000y1100.

Definition at line 261 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
void Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::align (  )  [inline]

Skip the bits to closest data value border.

Definition at line 287 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
bool Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::eos (  )  const [inline]

Definition at line 302 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
uint32 Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::getBit (  )  [inline]

Read a bit from the bit stream.

Definition at line 139 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
uint32 Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::getBit_internal (  )  [inline, private]

Definition at line 120 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
uint32 Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::getBits ( uint8  n  )  [inline]

Read a multi-bit value from the bit stream.

The value is read as if just taken as a whole from the bitstream.

For example: Reading a 4-bit value from an 8-bit bitstream with the contents 01010011: If the bitstream is MSB2LSB, the 4-bit value would be 0101. If the bitstream is LSB2MSB, the 4-bit value would be 0011.

Definition at line 163 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
uint32 Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::peekBit (  )  [inline]

Read a bit from the bit stream, without changing the stream's position.

Definition at line 213 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
uint32 Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::peekBits ( uint8  n  )  [inline]

Read a multi-bit value from the bit stream, without changing the stream's position.

The bit order is the same as in getBits().

Definition at line 234 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
uint32 Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::pos (  )  const [inline]

Return the stream position in bits.

Definition at line 293 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
uint32 Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::readData (  )  [inline, private]

Read a data value.

Definition at line 58 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
void Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::readValue (  )  [inline, private]

Read the next data value.

Definition at line 80 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
void Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::rewind (  )  [inline]

Rewind the bit stream back to the start.

Definition at line 272 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
uint32 Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::size (  )  const [inline]

Return the stream size in bits.

Definition at line 298 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
void Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::skip ( uint32  n  )  [inline]

Skip the specified amount of bits.

Definition at line 281 of file bitstream.h.


Member Data Documentation

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
DisposeAfterUse::Flag Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::_disposeAfterUse [private]

Should we delete the stream on destruction?

Definition at line 50 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
uint8 Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::_inValue [private]

Position within the current value.

Definition at line 53 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
uint32 Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::_pos [private]

Current bitstream position (in bits).

Definition at line 55 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
uint32 Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::_size [private]

Total bitstream size (in bits).

Definition at line 54 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
STREAM* Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::_stream [private]

The input stream.

Definition at line 49 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool isMSB2LSB>
uint32 Common::BitStreamImpl< STREAM, valueBits, isLE, isMSB2LSB >::_value [private]

Current value.

Definition at line 52 of file bitstream.h.


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


Generated on Sat Jan 12 2019 05:04:00 for ResidualVM by doxygen 1.7.1
curved edge   curved edge