xoreos  0.0.5
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Common::BitStreamWriterImpl< valueBits, isLE, isMSB2LSB > Class Template Reference

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

#include <bitstreamwriter.h>

Inheritance diagram for Common::BitStreamWriterImpl< valueBits, isLE, isMSB2LSB >:
Inheritance graph
[legend]
Collaboration diagram for Common::BitStreamWriterImpl< valueBits, isLE, isMSB2LSB >:
Collaboration graph
[legend]

Public Member Functions

 BitStreamWriterImpl (WriteStream *stream, bool disposeAfterUse=false)
 Create a bit stream using this input data stream and optionally delete it on destruction. More...
 
 BitStreamWriterImpl (WriteStream &stream)
 Create a bit stream using this input data stream. More...
 
 ~BitStreamWriterImpl ()
 
void putBit (bool bit)
 Write a bit to the bit stream. More...
 
void putBits (uint32 bits, size_t n)
 Write a multi-bit value to the bit stream. More...
 
void flush ()
 Flush the stream, forcing all cached bits to the written. More...
 
- Public Member Functions inherited from Common::BitStreamWriter
virtual ~BitStreamWriter ()
 

Private Member Functions

void writeData (uint64 data)
 Write a data value. More...
 
void writeValue ()
 Write the full data value. More...
 

Private Attributes

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

Additional Inherited Members

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

Detailed Description

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

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

Such a bit stream writer accepts bits one at a time, and writes them in chunks of valueBits bits to the data stream.

For example, a bit stream writer with the layout parameters 32, true, false for valueBits, isLE and isMSB2LSB, writes 32bit little-endian values to the data stream, ordering the bits LSB to MSB.

Definition at line 70 of file bitstreamwriter.h.

Constructor & Destructor Documentation

◆ BitStreamWriterImpl() [1/2]

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

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

Definition at line 113 of file bitstreamwriter.h.

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

◆ BitStreamWriterImpl() [2/2]

template<int valueBits, bool isLE, bool isMSB2LSB>
Common::BitStreamWriterImpl< valueBits, isLE, isMSB2LSB >::BitStreamWriterImpl ( WriteStream stream)
inline

Create a bit stream using this input data stream.

Definition at line 123 of file bitstreamwriter.h.

◆ ~BitStreamWriterImpl()

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

Definition at line 130 of file bitstreamwriter.h.

Member Function Documentation

◆ flush()

template<int valueBits, bool isLE, bool isMSB2LSB>
void Common::BitStreamWriterImpl< valueBits, isLE, isMSB2LSB >::flush ( )
inlinevirtual

Flush the stream, forcing all cached bits to the written.

This will resync the stream back to valueBits boundaries, padding with 0 bits

Implements Common::BitStreamWriter.

Definition at line 175 of file bitstreamwriter.h.

References Common::BitStreamWriterImpl< valueBits, isLE, isMSB2LSB >::_inValue, Common::BitStreamWriterImpl< valueBits, isLE, isMSB2LSB >::_stream, Common::BitStreamWriterImpl< valueBits, isLE, isMSB2LSB >::_value, and Common::BitStreamWriterImpl< valueBits, isLE, isMSB2LSB >::writeValue().

Referenced by Sound::WwRIFFVorbisStream::generateHeaderComment(), Sound::WwRIFFVorbisStream::generateHeaderIdentification(), and Sound::WwRIFFVorbisStream::generateHeaderSetup().

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

◆ putBit()

template<int valueBits, bool isLE, bool isMSB2LSB>
void Common::BitStreamWriterImpl< valueBits, isLE, isMSB2LSB >::putBit ( bool  bit)
inlinevirtual

◆ putBits()

template<int valueBits, bool isLE, bool isMSB2LSB>
void Common::BitStreamWriterImpl< valueBits, isLE, isMSB2LSB >::putBits ( uint32  bits,
size_t  n 
)
inlinevirtual

Write a multi-bit value to the bit stream.

Implements Common::BitStreamWriter.

Definition at line 150 of file bitstreamwriter.h.

References Common::BitStreamWriterImpl< valueBits, isLE, isMSB2LSB >::putBit().

Referenced by Sound::WwRIFFVorbisStream::generateHeaderComment(), Sound::WwRIFFVorbisStream::generateHeaderIdentification(), and Sound::WwRIFFVorbisStream::generateHeaderSetup().

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

◆ writeData()

template<int valueBits, bool isLE, bool isMSB2LSB>
void Common::BitStreamWriterImpl< valueBits, isLE, isMSB2LSB >::writeData ( uint64  data)
inlineprivate

Write a data value.

Definition at line 78 of file bitstreamwriter.h.

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

Referenced by Common::BitStreamWriterImpl< valueBits, isLE, isMSB2LSB >::writeValue().

Here is the caller graph for this function:

◆ writeValue()

template<int valueBits, bool isLE, bool isMSB2LSB>
void Common::BitStreamWriterImpl< valueBits, isLE, isMSB2LSB >::writeValue ( )
inlineprivate

Member Data Documentation

◆ _inValue

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

◆ _stream

template<int valueBits, bool isLE, bool isMSB2LSB>
DisposablePtr<WriteStream> Common::BitStreamWriterImpl< valueBits, isLE, isMSB2LSB >::_stream
private

◆ _value

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

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