Pigweed
 
Loading...
Searching...
No Matches
pw::ByteBuffer< kSizeBytes > Class Template Reference

ByteBuffers declare a buffer along with a ByteBuilder. More...

#include <byte_builder.h>

Inheritance diagram for pw::ByteBuffer< kSizeBytes >:
pw::ByteBuilder

Public Member Functions

 ByteBuffer (ByteBuffer &other)=delete
 
template<size_t kOtherSizeBytes>
ByteBufferoperator= (const ByteBuffer< kOtherSizeBytes > &other)
 
ByteBufferoperator= (const ByteBuffer &other)
 
template<size_t kOtherSizeBytes>
ByteBufferassign (const ByteBuffer< kOtherSizeBytes > &other)
 
 ByteBuffer (ByteBuffer &&other)=delete
 ByteBuffers are not movable: the underlying data must be copied.
 
ByteBufferoperator= (ByteBuffer &&other)=delete
 ByteBuffers are not movable: the underlying data must be copied.
 
template<typename... Args>
ByteBufferappend (Args &&... args)
 
- Public Member Functions inherited from pw::ByteBuilder
constexpr ByteBuilder (ByteSpan buffer)
 Creates an empty ByteBuilder.
 
 ByteBuilder (const ByteBuilder &)=delete
 
ByteBuilderoperator= (const ByteBuilder &)=delete
 
const std::byte * data () const
 Returns the contents of the bytes buffer.
 
Status status () const
 
StatusWithSize status_with_size () const
 Returns status() and size() as a StatusWithSize.
 
bool ok () const
 True if status() is OkStatus().
 
bool empty () const
 True if the bytes builder is empty.
 
size_t size () const
 Returns the current length of the bytes.
 
size_t max_size () const
 Returns the maximum length of the bytes.
 
void clear ()
 Clears the bytes and resets its error state.
 
void clear_status ()
 Sets the statuses to OkStatus();.
 
void push_back (std::byte b)
 
void pop_back ()
 
const_iterator begin () const
 Root of bytebuffer wrapped in iterator type.
 
const_iterator cbegin () const
 
const_iterator end () const
 End of bytebuffer wrapped in iterator type.
 
const_iterator cend () const
 
const std::byte & front () const
 Front and Back C++ container functions.
 
const std::byte & back () const
 
ByteBuilderappend (size_t count, std::byte b)
 Appends the provided byte count times.
 
ByteBuilderappend (const void *bytes, size_t count)
 
ByteBuilderappend (ConstByteSpan bytes)
 Appends bytes from a byte span that calls the pointer/length version.
 
void resize (size_t new_size)
 
ByteBuilderPutUint8 (uint8_t val)
 Put methods for inserting different 8-bit ints.
 
ByteBuilderPutInt8 (int8_t val)
 
ByteBuilderPutUint16 (uint16_t value, endian order=endian::little)
 Put methods for inserting different 16-bit ints.
 
ByteBuilderPutInt16 (int16_t value, endian order=endian::little)
 
ByteBuilderPutUint32 (uint32_t value, endian order=endian::little)
 Put methods for inserting different 32-bit ints.
 
ByteBuilderPutInt32 (int32_t value, endian order=endian::little)
 
ByteBuilderPutUint64 (uint64_t value, endian order=endian::little)
 Put methods for inserting different 64-bit ints.
 
ByteBuilderPutInt64 (int64_t value, endian order=endian::little)
 

Static Public Member Functions

static constexpr size_t max_size ()
 

Additional Inherited Members

- Public Types inherited from pw::ByteBuilder
using element_type = const std::byte
 
using value_type = std::byte
 
using pointer = std::byte *
 
using reference = std::byte &
 
using iterator = iterator
 
using const_iterator = iterator
 
- Protected Member Functions inherited from pw::ByteBuilder
constexpr ByteBuilder (const ByteSpan &buffer, const ByteBuilder &other)
 Functions to support ByteBuffer copies.
 
void CopySizeAndStatus (const ByteBuilder &other)
 

Detailed Description

template<size_t kSizeBytes>
class pw::ByteBuffer< kSizeBytes >

ByteBuffers declare a buffer along with a ByteBuilder.

Member Function Documentation

◆ append()

template<size_t kSizeBytes>
template<typename... Args>
ByteBuffer & pw::ByteBuffer< kSizeBytes >::append ( Args &&...  args)
inline

Returns a ByteBuffer<kSizeBytes>& instead of a generic ByteBuilder& for append calls.

◆ max_size()

template<size_t kSizeBytes>
static constexpr size_t pw::ByteBuffer< kSizeBytes >::max_size ( )
inlinestaticconstexpr

Returns the maximum length of the bytes that can be inserted in the bytes buffer.


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