Embedded Template Library 1.0
etl::byte_stream_writer Class Reference

Encodes a byte stream. More...

#include <byte_stream.h>

Public Types

typedef char * iterator
 
typedef const char * const_iterator
 
typedef etl::span< char > callback_parameter_type
 
typedef etl::delegate< void(callback_parameter_type)> callback_type
 

Public Member Functions

 byte_stream_writer (etl::span< char > span_, etl::endian stream_endianness_, callback_type callback_=callback_type())
 Construct from span.
 
 byte_stream_writer (etl::span< unsigned char > span_, etl::endian stream_endianness_, callback_type callback_=callback_type())
 Construct from span.
 
 byte_stream_writer (void *begin_, void *end_, etl::endian stream_endianness_, callback_type callback_=callback_type())
 Construct from range.
 
 byte_stream_writer (void *begin_, size_t length_, etl::endian stream_endianness_, callback_type callback_=callback_type())
 Construct from begin and length.
 
template<typename T , size_t Size>
 byte_stream_writer (T(&begin_)[Size], etl::endian stream_endianness_, callback_type callback_=callback_type())
 Construct from array.
 
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||etl::is_floating_point< T >::value, void >::type write_unchecked (T value)
 Write a value to the stream.
 
template<typename T >
etl::enable_if< etl::is_integral< T >::value||etl::is_floating_point< T >::value, bool >::type write (T value)
 Write a value to the stream.
 
template<typename T >
etl::enable_if< etl::is_integral< T >::value||etl::is_floating_point< T >::value, void >::type write_unchecked (const etl::span< T > &range)
 Write a range of T to the stream.
 
template<typename T >
etl::enable_if< etl::is_integral< T >::value||etl::is_floating_point< T >::value, bool >::type write (const etl::span< T > &range)
 Write a range of T to the stream.
 
template<typename T >
etl::enable_if< etl::is_integral< T >::value||etl::is_floating_point< T >::value, void >::type write_unchecked (const T *start, size_t length)
 Write a range of T to the stream.
 
template<typename T >
etl::enable_if< etl::is_integral< T >::value||etl::is_floating_point< T >::value, bool >::type write (const T *start, size_t length)
 Write a range of T to the stream.
 
template<typename T >
bool skip (size_t n)
 
void restart (size_t n=0U)
 Sets the index back to the position in the stream. Default = 0.
 
iterator begin ()
 Returns start of the stream.
 
const_iterator begin () const
 Returns start of the stream.
 
iterator end ()
 Returns end of the stream.
 
const_iterator end () const
 Returns end of the stream.
 
const_iterator cbegin () const
 Returns start 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 > free_data ()
 Returns a span of the free portion of the stream.
 
etl::span< const char > free_data () const
 Returns a span of the free 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.
 
bool full () const
 Returns true if the byte stream index has reached the end.
 
bool empty () const
 Returns true if the byte stream is empty.
 
size_t size_bytes () const
 Returns the number of bytes used in the stream.
 
size_t capacity () const
 Returns the maximum number of bytes in the stream.
 
template<typename T >
size_t available () const
 The number of T left in the stream.
 
size_t available_bytes () const
 The number of bytes left in the stream.
 
void set_callback (callback_type callback_)
 Sets the function to call afer every write.
 
callback_type get_callback () const
 Gets the function to call afer every write.
 
etl::endian get_endianness () const
 Gets the endianness of the stream.
 

Detailed Description

Encodes a byte stream.

Member Function Documentation

◆ skip()

template<typename T >
bool etl::byte_stream_writer::skip ( size_t  n)
inline

Skip n items of T, if the total space is available. Returns true if the skip was possible. Returns false if the skip size was not possible.


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