![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
#include <BitStream.hpp>
Public Member Functions | |
| bool | aligned () |
| BitStream (u32 bytes=0, void *vbuffer=0) | |
| u8 * | get () |
| BitStream & | operator<< (const char *data) |
| template<class T > | |
| BitStream & | operator<< (T data) |
| template<u32 N_BITS> | |
| BitStream & | operator<< (const bs_bit::set< N_BITS > &n) |
| template<> | |
| BitStream & | operator<< (const bs_bit::set< 1 > &n) |
| template<> | |
| BitStream & | operator<< (const bs_bit::set< 8 > &n) |
| template<> | |
| BitStream & | operator<< (const bs_bit::set< 16 > &n) |
| template<> | |
| BitStream & | operator<< (const bs_bit::set< 32 > &n) |
| BitStream & | operator<< (const bs_byte::set &n) |
| template<class T > | |
| BitStream & | operator>> (T &data) |
| template<u32 N_BITS> | |
| BitStream & | operator>> (const bs_bit::get< N_BITS > &n) |
| template<> | |
| BitStream & | operator>> (const bs_bit::get< 1 > &n) |
| template<> | |
| BitStream & | operator>> (const bs_bit::get< 8 > &n) |
| template<> | |
| BitStream & | operator>> (const bs_bit::get< 16 > &n) |
| template<> | |
| BitStream & | operator>> (const bs_bit::get< 32 > &n) |
| BitStream & | operator>> (const bs_byte::get &n) |
| u8 * | peek () |
| template<class T > | |
| T | read () |
| template<> | |
| void | read (double &data) |
| template<class T > | |
| void | read (T &data) |
| template<> | |
| void | read (float &data) |
| u8 | read1 () |
| u32 | readBits (u32 count) |
| void | readBytes (void *data, u32 byte_count) |
| void | shrink () |
| void | skip (u32 bits) |
| bool | underrun () |
| int | unread () |
| bool | valid () |
| template<class T > | |
| void | write (T data) |
| template<> | |
| void | write (double data) |
| template<> | |
| void | write (s8 data) |
| template<> | |
| void | write (s64 data) |
| template<> | |
| void | write (float data) |
| template<> | |
| void | write (s16 data) |
| template<> | |
| void | write (s32 data) |
| void | write1 (u8 data) |
| void | writeBits (u32 data, int count) |
| void | writeBytes (const void *data, u32 byte_count) |
| ~BitStream () | |
Public Attributes | |
| u32 | read_offset |
| u32 | write_offset |
Private Member Functions | |
| void | grow (u32 bits) |
Private Attributes | |
| u8 * | buffer |
| u32 | buffer_bytes |
| bool | fixed_buffer |
| bool | read_underrun |
Definition at line 81 of file BitStream.hpp.
| cat::BitStream::BitStream | ( | u32 | bytes = 0, |
| void * | vbuffer = 0 |
||
| ) |
| cat::BitStream::~BitStream | ( | ) |
| bool cat::BitStream::aligned | ( | ) | [inline] |
Definition at line 104 of file BitStream.hpp.
References read_offset.
{ return read_offset % 8 == 0; }
| u8* cat::BitStream::get | ( | ) | [inline] |
| BitStream& cat::BitStream::operator<< | ( | const char * | data | ) | [inline] |
Definition at line 154 of file BitStream.hpp.
References writeBytes().
{ writeBytes(data, (u32)strlen(data)); return *this; }
| BitStream& cat::BitStream::operator<< | ( | const bs_bit::set< N_BITS > & | n | ) | [inline] |
Definition at line 158 of file BitStream.hpp.
References writeBits().
{ writeBits(n.bits, N_BITS); return *this; }
| BitStream& cat::BitStream::operator<< | ( | const bs_bit::set< 1 > & | n | ) | [inline] |
Definition at line 159 of file BitStream.hpp.
References write1().
| BitStream& cat::BitStream::operator<< | ( | const bs_bit::set< 8 > & | n | ) | [inline] |
Definition at line 160 of file BitStream.hpp.
References write().
| BitStream& cat::BitStream::operator<< | ( | const bs_bit::set< 16 > & | n | ) | [inline] |
Definition at line 161 of file BitStream.hpp.
References write().
| BitStream& cat::BitStream::operator<< | ( | const bs_bit::set< 32 > & | n | ) | [inline] |
Definition at line 162 of file BitStream.hpp.
References write().
| BitStream& cat::BitStream::operator<< | ( | const bs_byte::set & | n | ) | [inline] |
Definition at line 164 of file BitStream.hpp.
References cat::bs_byte::set::bytes, cat::bs_byte::set::ref, and writeBytes().
{ writeBytes(n.ref, n.bytes); return *this; }
| BitStream& cat::BitStream::operator>> | ( | const bs_bit::get< N_BITS > & | n | ) | [inline] |
Definition at line 201 of file BitStream.hpp.
References readBits(), and cat::bs_bit::get< N_BITS >::ref.
{ n.ref = readBits(N_BITS); return *this; }
| BitStream& cat::BitStream::operator>> | ( | const bs_bit::get< 1 > & | n | ) | [inline] |
Definition at line 202 of file BitStream.hpp.
References read1(), and cat::bs_bit::get< N_BITS >::ref.
{ n.ref = read1(); return *this; }
| BitStream& cat::BitStream::operator>> | ( | const bs_bit::get< 8 > & | n | ) | [inline] |
Definition at line 203 of file BitStream.hpp.
References cat::bs_bit::get< N_BITS >::ref.
{ n.ref = read<u8>(); return *this; }
| BitStream& cat::BitStream::operator>> | ( | const bs_byte::get & | n | ) | [inline] |
Definition at line 207 of file BitStream.hpp.
References cat::bs_byte::get::bytes, readBytes(), and cat::bs_byte::get::ref.
{ readBytes(n.ref, n.bytes); return *this; }
| BitStream& cat::BitStream::operator>> | ( | const bs_bit::get< 32 > & | n | ) | [inline] |
Definition at line 205 of file BitStream.hpp.
References read(), and cat::bs_bit::get< N_BITS >::ref.
{ read(n.ref); return *this; }
| BitStream& cat::BitStream::operator>> | ( | const bs_bit::get< 16 > & | n | ) | [inline] |
Definition at line 204 of file BitStream.hpp.
References cat::bs_bit::get< N_BITS >::ref.
{ n.ref = read<u16>(); return *this; }
| u8* cat::BitStream::peek | ( | ) | [inline] |
Definition at line 105 of file BitStream.hpp.
References buffer, and read_offset.
{ return buffer + read_offset / 8; }
| T cat::BitStream::read | ( | ) | [inline] |
Definition at line 192 of file BitStream.hpp.
Referenced by operator>>(), and read().
| void cat::BitStream::read | ( | T & | data | ) | [inline] |
Definition at line 170 of file BitStream.hpp.
References buffer, read_offset, read_underrun, T, and write_offset.
{
const u32 bits = sizeof(T) * 8;
if (read_offset + bits > write_offset)
{
read_underrun = true;
return;
}
u32 byte_offset = read_offset / 8;
u32 shift = read_offset % 8;
if (shift)
data = (*(T*)(buffer + byte_offset + 1) << (8 - shift)) | (buffer[byte_offset] >> shift);
else
data = *(T*)(buffer + byte_offset);
read_offset += bits;
}
| void cat::BitStream::read | ( | float & | data | ) | [inline] |
| void cat::BitStream::read | ( | double & | data | ) | [inline] |
| u8 cat::BitStream::read1 | ( | ) |
Referenced by operator>>().
Referenced by operator>>().
| void cat::BitStream::readBytes | ( | void * | data, |
| u32 | byte_count | ||
| ) |
Referenced by operator>>().
| void cat::BitStream::shrink | ( | ) |
| void cat::BitStream::skip | ( | u32 | bits | ) |
| bool cat::BitStream::underrun | ( | ) |
| int cat::BitStream::unread | ( | ) | [inline] |
Definition at line 112 of file BitStream.hpp.
References read_offset, and write_offset.
{ return write_offset - read_offset; }
| bool cat::BitStream::valid | ( | ) | [inline] |
| void cat::BitStream::write | ( | double | data | ) | [inline] |
| void cat::BitStream::write | ( | T | data | ) | [inline] |
Definition at line 124 of file BitStream.hpp.
References buffer, grow(), T, and write_offset.
Referenced by operator<<(), and read().
{
grow(sizeof(T) * 8);
u32 byte_offset = write_offset / 8;
u32 shift = write_offset % 8;
if (shift)
{
buffer[byte_offset] |= (u8)(data << shift);
data = data >> (8 - shift);
++byte_offset;
}
*(T*)(buffer + byte_offset) = data;
write_offset += sizeof(T) * 8;
}
| void cat::BitStream::write | ( | s8 | data | ) | [inline] |
| void cat::BitStream::write | ( | s64 | data | ) | [inline] |
| void cat::BitStream::write | ( | s32 | data | ) | [inline] |
| void cat::BitStream::write | ( | s16 | data | ) | [inline] |
| void cat::BitStream::write | ( | float | data | ) | [inline] |
| void cat::BitStream::write1 | ( | u8 | data | ) |
Referenced by operator<<().
| void cat::BitStream::writeBits | ( | u32 | data, |
| int | count | ||
| ) |
Referenced by operator<<().
| void cat::BitStream::writeBytes | ( | const void * | data, |
| u32 | byte_count | ||
| ) |
Referenced by operator<<().
u8* cat::BitStream::buffer [private] |
u32 cat::BitStream::buffer_bytes [private] |
Definition at line 85 of file BitStream.hpp.
bool cat::BitStream::fixed_buffer [private] |
Definition at line 83 of file BitStream.hpp.
bool cat::BitStream::read_underrun [private] |
Definition at line 86 of file BitStream.hpp.
Referenced by read().
Definition at line 92 of file BitStream.hpp.
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.