VideoTools
|
A class for pulling integer values of various widths out of a bit stream. More...
#include <gbitstream.h>
Public Types | |
typedef T | bit_iterator_type |
typedef T::byte_iterator_type | static_assert_T_is_bit_iterator |
Public Member Functions | |
bit_stream (T begin, T end) | |
Constructor taking a G::bit_iterator<X> pair where the underlying byte source has a well-defined end. More... | |
bit_stream (T begin) | |
Constructor overload for an G::bit_iterator that has no well-defined end; typically bit iterators that are already based on a stream, such as G::bit_stream<std::istream_iterator<char>>. More... | |
bool | get_bool () |
Extracts a boolean. Sets the fail state on underflow. | |
unsigned char | get (int bits) |
Gets a number of bits, returned in a byte. More... | |
unsigned char | get () |
Gets a byte. More... | |
unsigned char | get_byte () |
Gets a byte. Sets the fail state on underflow. | |
g_uint16_t | get_word () |
Gets a word. Sets the fail state on underflow. | |
g_uint32_t | get_dword () |
Gets a dword. Sets the fail state on underflow. | |
int | get_signed_golomb () |
Gets an exp-golomb encoded signed value. Sets the fail state on underflow. | |
unsigned int | get_unsigned_golomb () |
Gets an exp-golomb encoded unsigned value. Sets the fail state on underflow. | |
bool | at_end (bool default_=false) const |
Returns true if the bit iterator is equal to the end iterator. More... | |
bool | fail () const |
Returns the fail state. | |
bool | good () const |
Returns !fail(). | |
void | check () |
Checks for a failed state and throws if failed. | |
size_t | tellg () const |
Returns the current bit offset. | |
A class for pulling integer values of various widths out of a bit stream.
Also supports exp-golomb encoding.
The template parameter must be G::bit_iterator<X>, for some underlying byte-wise forward iterator type X.
Eg:
Definition at line 55 of file gbitstream.h.
G::bit_stream< T >::bit_stream | ( | T | begin, |
T | end | ||
) |
Constructor taking a G::bit_iterator<X> pair where the underlying byte source has a well-defined end.
Prefer the other overload if the bit iterator is based on an underlying stream, because the underlying byte stream will be left at a poorly-defined read position after the bit_stream goes away.
Definition at line 128 of file gbitstream.h.
|
explicit |
Constructor overload for an G::bit_iterator that has no well-defined end; typically bit iterators that are already based on a stream, such as G::bit_stream<std::istream_iterator<char>>.
Definition at line 138 of file gbitstream.h.
bool G::bit_stream< T >::at_end | ( | bool | default_ = false | ) | const |
Returns true if the bit iterator is equal to the end iterator.
Returns the default if the end iterator was not supplied in the ctor.
Definition at line 214 of file gbitstream.h.
unsigned char G::bit_stream< T >::get | ( | int | bits | ) |
Gets a number of bits, returned in a byte.
Sets the fail state on underflow. Precondition: bits <= 8
Definition at line 177 of file gbitstream.h.
unsigned char G::bit_stream< T >::get | ( | ) |
Gets a byte.
Sets the fail state on underflow. This is matches std::istream::get().
Definition at line 171 of file gbitstream.h.