1#ifndef BLUETOE_LINK_LAYER_BUFFER_HPP
2#define BLUETOE_LINK_LAYER_BUFFER_HPP
7#include <initializer_list>
44 void fill( std::initializer_list< std::uint8_t > data )
46 assert( data.size() <=
size );
47 std::copy( data.begin(), data.end(),
buffer );
60 template <
class Layout >
61 void fill(
const read_buffer& buffer, std::initializer_list< std::uint8_t > data )
63 if ( data.size() >= 1 )
65 std::uint16_t header = *data.begin();
67 if ( data.size() >= 2 )
68 header |= *std::next( data.begin() ) << 8;
70 Layout::header( buffer, header );
72 if ( data.size() >= 3 )
74 std::uint8_t* body = Layout::body( buffer ).first;
75 std::copy( std::next( data.begin(), 2 ), std::end( data ), body );
type suitable to store the location and size of a chunk of memory that can be used to receive from th...
Definition: buffer.hpp:18
std::uint8_t * buffer
Definition: buffer.hpp:24
bool empty() const
returns true, if the buffer is empty
Definition: buffer.hpp:35
std::size_t size
Definition: buffer.hpp:30
void fill(std::initializer_list< std::uint8_t > data)
copies the given data into the buffer
Definition: buffer.hpp:44
type suitable to store the location and size of a chunk of memory that can be used to transmit to the...
Definition: buffer.hpp:85
write_buffer(const read_buffer &rhs)
constructs a ready-only buffer from a writable buffer
Definition: buffer.hpp:103
bool empty() const
returns true, if the buffer is empty
Definition: buffer.hpp:95
write_buffer()
constructs an empty buffer
Definition: buffer.hpp:111
const std::uint8_t * buffer
Definition: buffer.hpp:87
write_buffer(const std::uint8_t *b, std::size_t s)
constructs a buffer pointing to the given location, with the given size
Definition: buffer.hpp:120
std::size_t size
Definition: buffer.hpp:90