xoreos  0.0.5
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Common::BitStreamImpl< 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< valueBits, isLE, isMSB2LSB >:
Inheritance graph
[legend]
Collaboration diagram for Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >:
Collaboration graph
[legend]

Public Member Functions

 BitStreamImpl (SeekableReadStream *stream, bool disposeAfterUse=false)
 Create a bit stream using this input data stream and optionally delete it on destruction. More...
 
 BitStreamImpl (SeekableReadStream &stream)
 Create a bit stream using this input data stream. More...
 
 ~BitStreamImpl ()
 
uint32 getBit ()
 Read a bit from the bit stream. More...
 
uint32 getBits (size_t n)
 Read a multi-bit value from the bit stream. More...
 
void addBit (uint32 &x, size_t n)
 Add a bit to the n-bit value x, making it an (n+1)-bit value. More...
 
void rewind ()
 Rewind the bit stream back to the start. More...
 
void skip (size_t n)
 Skip the specified amount of bits. More...
 
size_t pos () const
 Return the stream position in bits. More...
 
size_t size () const
 Return the stream size in bits. More...
 
bool eos () const
 Has the end of the stream been reached? More...
 
- Public Member Functions inherited from Common::BitStream
virtual ~BitStream ()
 

Private Member Functions

uint64 readData ()
 Read a data value. More...
 
void readValue ()
 Read the next data value. More...
 

Private Attributes

DisposablePtr< SeekableReadStream_stream
 The input stream. More...
 
uint64 _value
 Current value. More...
 
uint8 _inValue
 Position within the current value. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Common::BitStream
 BitStream ()
 

Detailed Description

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

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

Such a bit stream reads a 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 85 of file bitstream.h.

Constructor & Destructor Documentation

◆ BitStreamImpl() [1/2]

template<int valueBits, bool isLE, bool isMSB2LSB>
Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::BitStreamImpl ( SeekableReadStream stream,
bool  disposeAfterUse = false 
)
inline

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

Definition at line 132 of file bitstream.h.

References Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::_stream.

◆ BitStreamImpl() [2/2]

template<int valueBits, bool isLE, bool isMSB2LSB>
Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::BitStreamImpl ( SeekableReadStream stream)
inline

Create a bit stream using this input data stream.

Definition at line 142 of file bitstream.h.

◆ ~BitStreamImpl()

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

Definition at line 149 of file bitstream.h.

Member Function Documentation

◆ addBit()

template<int valueBits, bool isLE, bool isMSB2LSB>
void Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::addBit ( uint32 x,
size_t  n 
)
inlinevirtual

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

Implements Common::BitStream.

Definition at line 202 of file bitstream.h.

References Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::getBit().

Here is the call graph for this function:

◆ eos()

template<int valueBits, bool isLE, bool isMSB2LSB>
bool Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::eos ( ) const
inlinevirtual

Has the end of the stream been reached?

Implements Common::BitStream.

Definition at line 240 of file bitstream.h.

References Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::_stream, Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::pos(), and Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::size().

Here is the call graph for this function:

◆ getBit()

template<int valueBits, bool isLE, bool isMSB2LSB>
uint32 Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::getBit ( )
inlinevirtual

◆ getBits()

template<int valueBits, bool isLE, bool isMSB2LSB>
uint32 Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::getBits ( size_t  n)
inlinevirtual

◆ pos()

template<int valueBits, bool isLE, bool isMSB2LSB>
size_t Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::pos ( ) const
inlinevirtual

◆ readData()

template<int valueBits, bool isLE, bool isMSB2LSB>
uint64 Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::readData ( )
inlineprivate

Read a data value.

Definition at line 93 of file bitstream.h.

References Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::_stream.

Referenced by Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::readValue().

Here is the caller graph for this function:

◆ readValue()

template<int valueBits, bool isLE, bool isMSB2LSB>
void Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::readValue ( )
inlineprivate

◆ rewind()

template<int valueBits, bool isLE, bool isMSB2LSB>
void Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::rewind ( )
inlinevirtual

◆ size()

template<int valueBits, bool isLE, bool isMSB2LSB>
size_t Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::size ( ) const
inlinevirtual

◆ skip()

template<int valueBits, bool isLE, bool isMSB2LSB>
void Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::skip ( size_t  n)
inlinevirtual

Skip the specified amount of bits.

Implements Common::BitStream.

Definition at line 221 of file bitstream.h.

References Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::getBit().

Referenced by Video::Bink::BinkAudioTrack::decodeAudio(), Sound::WMACodec::decodeSuperFrame(), and Aurora::GFXFile::readFileAttributes().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _inValue

template<int valueBits, bool isLE, bool isMSB2LSB>
uint8 Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::_inValue
private

◆ _stream

template<int valueBits, bool isLE, bool isMSB2LSB>
DisposablePtr<SeekableReadStream> Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::_stream
private

◆ _value

template<int valueBits, bool isLE, bool isMSB2LSB>
uint64 Common::BitStreamImpl< valueBits, isLE, isMSB2LSB >::_value
private

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