Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. C/C++
  4. Comms
  5. pw_cobs
  6. pw::cobs::EncodeBuffer< kMaxPayloadSize > Class Template Reference
Loading...
Searching...
No Matches
pw::cobs::EncodeBuffer< kMaxPayloadSize > Class Template Reference

Overview

template<size_t kMaxPayloadSize>
class pw::cobs::EncodeBuffer< kMaxPayloadSize >

Fixed-capacity container that builds an unencoded payload and COBS-encodes it in-place without a second buffer.

Example:

buffer.append(header);
buffer.append(payload);
pw::ConstByteSpan encoded = buffer.Encode();
Definition: cobs.h:107
ConstByteSpan Encode()
Definition: cobs.h:191
void append(ConstByteSpan bytes)
Definition: cobs.h:177

Public Types

using value_type = std::byte
 
using size_type = size_t
 
using difference_type = ptrdiff_t
 
using reference = std::byte &
 
using const_reference = const std::byte &
 
using pointer = std::byte *
 
using const_pointer = const std::byte *
 
using iterator = containers::PtrIterator< EncodeBuffer >
 
using const_iterator = containers::ConstPtrIterator< EncodeBuffer >
 

Public Member Functions

 EncodeBuffer (ConstByteSpan initial)
 
constexpr std::byte * data ()
 
constexpr const std::byte * data () const
 
constexpr size_t size () const
 Current unencoded payload length in bytes.
 
constexpr bool empty () const
 
constexpr iterator begin ()
 
constexpr const_iterator begin () const
 
constexpr const_iterator cbegin () const
 
constexpr iterator end ()
 
constexpr const_iterator end () const
 
constexpr const_iterator cend () const
 
constexpr std::byte & operator[] (size_t index)
 
constexpr const std::byte & operator[] (size_t index) const
 
constexpr void clear ()
 Resets the unencoded payload length to 0 so a new payload can be built.
 
void resize (size_t new_size)
 
void push_back (std::byte b)
 
void append (ConstByteSpan bytes)
 
ConstByteSpan Encode ()
 
ConstByteSpan Encode (size_t payload_size)
 

Static Public Member Functions

static constexpr size_t max_size ()
 Maximum unencoded payload capacity in bytes.
 
static constexpr size_t capacity ()
 

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