Gnash  0.8.10
Public Types | Public Member Functions
gnash::BitsReader Class Reference

BitsReader is used to encapsulate bit-packed buffer reads. More...

#include <BitsReader.h>

List of all members.

Public Types

typedef unsigned char byte

Public Member Functions

 BitsReader (const byte *input, size_t len)
 Ownership of buffer left to caller.
 BitsReader (const BitsReader &from, size_t len)
 Create a BitsReader reading a subset of another.
 ~BitsReader ()
size_t size () const
void setBuffer (byte *input, size_t len)
 Set a new buffer to work with.
unsigned read_uint (unsigned short bitcount)
 Reads a bit-packed unsigned integer from the stream and returns it. The given bitcount determines the number of bits to read.
bool read_bit ()
 Reads a single bit off the stream and returns it.
boost::int32_t read_sint (unsigned short bitcount)
 Reads a bit-packed little-endian signed integer from the stream. The given bitcount determines the number of bits to read.
boost::uint8_t read_u8 ()
 Read a byte as an unsigned int (aligned)
boost::int8_t read_s8 ()
 Read one bytes as a signed int (aligned)
boost::uint16_t read_u16 ()
 Read two bytes as an unsigned int (aligned)
boost::int16_t read_s16 ()
 Read two bytes as a signed int (aligned)
boost::uint32_t read_u32 ()
 Read four bytes as an unsigned int (aligned)
boost::int32_t read_s32 ()
 Read four bytes as an signed int (aligned)
void align ()
 Discard any unused bit in the current byte and advance to next.
bool gotBits (boost::uint32_t nbits)
 Checks if the stream contains X bits.

Detailed Description

BitsReader is used to encapsulate bit-packed buffer reads.

TODO: implement boundary checking, maybe by throwing an exception when attempts are made to read past end of buffer


Member Typedef Documentation

typedef unsigned char gnash::BitsReader::byte

Constructor & Destructor Documentation

gnash::BitsReader::BitsReader ( const byte input,
size_t  len 
) [inline]

Ownership of buffer left to caller.

gnash::BitsReader::BitsReader ( const BitsReader from,
size_t  len 
) [inline]

Create a BitsReader reading a subset of another.

The starting pointer will be taken from the parent reader cursor, including used bits, use align() if need to discard the left over ones.

length will be given explicitly.

gnash::BitsReader::~BitsReader ( ) [inline]

Member Function Documentation

void gnash::BitsReader::align ( ) [inline]

Discard any unused bit in the current byte and advance to next.

bool gnash::BitsReader::gotBits ( boost::uint32_t  nbits) [inline]

Checks if the stream contains X bits.

References gnash::image::end().

bool gnash::BitsReader::read_bit ( )

Reads a single bit off the stream and returns it.

boost::int16_t gnash::BitsReader::read_s16 ( ) [inline]

Read two bytes as a signed int (aligned)

boost::int32_t gnash::BitsReader::read_s32 ( ) [inline]

Read four bytes as an signed int (aligned)

boost::int8_t gnash::BitsReader::read_s8 ( ) [inline]

Read one bytes as a signed int (aligned)

boost::int32_t gnash::BitsReader::read_sint ( unsigned short  bitcount)

Reads a bit-packed little-endian signed integer from the stream. The given bitcount determines the number of bits to read.

References read_uint().

boost::uint16_t gnash::BitsReader::read_u16 ( ) [inline]

Read two bytes as an unsigned int (aligned)

References assert, and gnash::image::end().

boost::uint32_t gnash::BitsReader::read_u32 ( ) [inline]

Read four bytes as an unsigned int (aligned)

References assert, and gnash::image::end().

boost::uint8_t gnash::BitsReader::read_u8 ( ) [inline]

Read a byte as an unsigned int (aligned)

unsigned gnash::BitsReader::read_uint ( unsigned short  bitcount)

Reads a bit-packed unsigned integer from the stream and returns it. The given bitcount determines the number of bits to read.

References assert.

Referenced by read_sint().

void gnash::BitsReader::setBuffer ( byte input,
size_t  len 
) [inline]

Set a new buffer to work with.

References start, and gnash::image::end().

size_t gnash::BitsReader::size ( ) const [inline]

References gnash::image::end(), and start.


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