Embedded Template Library 1.0
|
Writes bits streams. More...
#include <bit_stream.h>
Public Types | |
typedef char | value_type |
typedef value_type * | iterator |
typedef const value_type * | const_iterator |
typedef etl::span< value_type > | callback_parameter_type |
typedef etl::delegate< void(callback_parameter_type)> | callback_type |
Public Member Functions | |
template<size_t Length> | |
bit_stream_writer (const etl::span< char, Length > &span_, etl::endian stream_endianness_, callback_type callback_=callback_type()) | |
Construct from span. | |
template<size_t Length> | |
bit_stream_writer (const etl::span< unsigned char, Length > &span_, etl::endian stream_endianness_, callback_type callback_=callback_type()) | |
Construct from span. | |
bit_stream_writer (void *begin_, void *end_, etl::endian stream_endianness_, callback_type callback_=callback_type()) | |
Construct from range. | |
bit_stream_writer (void *begin_, size_t length_chars_, etl::endian stream_endianness_, callback_type callback_=callback_type()) | |
Construct from begin and length. | |
void | restart () |
Sets the indexes back to the beginning of the stream. | |
size_t | capacity_bytes () const |
Returns the maximum capacity in bits. | |
size_t | capacity_bits () const |
bool | empty () const |
Returns true if the bitsteam indexes have been reset. | |
bool | full () const |
Returns true if the bitsteam indexes have reached the end. | |
void | write_unchecked (bool value) |
Writes a boolean to the stream. | |
bool | write (bool value) |
Writes a boolean to the stream. | |
template<typename T > | |
etl::enable_if< etl::is_integral< T >::value, void >::type | write_unchecked (T value, uint_least8_t nbits=CHAR_BIT *sizeof(T)) |
For integral types. | |
template<typename T > | |
etl::enable_if< etl::is_integral< T >::value, bool >::type | write (T value, uint_least8_t nbits=CHAR_BIT *sizeof(T)) |
For integral types. | |
bool | skip (size_t nbits) |
size_t | size_bytes () const |
Returns the number of bytes used in the stream. | |
size_t | size_bits () const |
Returns the number of bits used in the stream. | |
template<size_t Nbits> | |
size_t | available () const |
template<typename T > | |
size_t | available () const |
size_t | available (size_t nbits) const |
size_t | available_bits () const |
The number of bits left in the stream. | |
iterator | begin () |
Returns start of the stream. | |
const_iterator | begin () const |
Returns start of the stream. | |
const_iterator | cbegin () const |
Returns start of the stream. | |
iterator | end () |
Returns end of the stream. | |
const_iterator | end () const |
Returns end of the stream. | |
const_iterator | cend () const |
Returns end of the stream. | |
etl::span< char > | used_data () |
Returns a span of the used portion of the stream. | |
etl::span< const char > | used_data () const |
Returns a span of the used portion of the stream. | |
etl::span< char > | data () |
Returns a span of whole the stream. | |
etl::span< const char > | data () const |
Returns a span of whole the stream. | |
void | flush () |
Flush the last byte, if partially filled, to the callback, if valid. | |
void | set_callback (callback_type callback_) |
Sets the function to call after every write. | |
callback_type | get_callback () const |
Gets the function to call after every write. | |
Writes bits streams.
The number of multiples of 'Nbits' available in the stream. Compile time.
The number of T available in the stream. Compile time.
The number of 'bit width' available in the stream. Run time.
Skip n bits, up to the maximum space available. Returns true if the skip was possible. Returns false if the full skip size was not possible.