title: llarp_buffer_t summary: TODO: replace usage of these with std::span (via a backport until we move to C++20).
llarp_buffer_t
TODO: replace usage of these with std::span (via a backport until we move to C++20). More...
#include <buffer.hpp>
Public Functions
| Name | |
|---|---|
| byte_t | operator[](size_t x) |
| llarp_buffer_t() =default | |
| llarp_buffer_t(byte_t * b, byte_t * c, size_t s) | |
| llarp_buffer_t(const ManagedBuffer & ) =delete | |
| llarp_buffer_t(ManagedBuffer && ) =delete | |
| template <typename Byte ,typename =std::enable_if_t |
llarp_buffer_t(Byte * buf, size_t sz) Construct referencing some 1-byte, trivially copyable (e.g. |
| template <typename Byte ,typename =std::enable_if_t |
llarp_buffer_t(std::vector< Byte > & b) initialize llarp_buffer_t from vector or array of byte-like values |
| template <typename Byte ,size_t N,typename =std::enable_if_t |
llarp_buffer_t(std::array< Byte, N > & b) |
| template <typename Byte ,typename =std::enable_if_t |
llarp_buffer_t(const Byte * buf, size_t sz) |
| template <typename Byte ,typename =std::enable_if_t |
llarp_buffer_t(const std::vector< Byte > & b) |
| template <typename Byte ,size_t N,typename =std::enable_if_t |
llarp_buffer_t(const std::array< Byte, N > & b) |
| template <typename T ,typename =std::void_t |
llarp_buffer_t(T && t) Explicitly construct a llarp_buffer_t from anything with a .data() and a .size(). Cursed. |
| byte_t * | begin() |
| const byte_t * | begin() const |
| byte_t * | end() |
| const byte_t * | end() const |
| size_t | size_left() const |
| template <typename OutputIt > bool |
read_into(OutputIt begin, OutputIt end) |
| template <typename InputIt > bool |
write(InputIt begin, InputIt end) |
| bool | writef(const char * fmt, ... ) |
| bool bool | put_uint16(uint16_t i) |
| bool | put_uint32(uint32_t i) |
| bool | put_uint64(uint64_t i) |
| bool | read_uint16(uint16_t & i) |
| bool | read_uint32(uint32_t & i) |
| bool | read_uint64(uint64_t & i) |
| size_t | read_until(char delim, byte_t * result, size_t resultlen) |
| std::vector< byte_t > | copy() const make a copy of this buffer |
| llarp::byte_view_t | view_all() const get a read-only view over the entire region |
| llarp::byte_view_t | view_remaining() const get a read-only view over the remaining/unused region |
| bool | startswith(std::string_view prefix_str) const Part of the curse. |
Public Attributes
| Name | |
|---|---|
| byte_t * | base starting memory address |
| byte_t * | cur memory address of stream position |
| size_t | sz max size of buffer |
| constexpr bool | is_basic_byte |
Friends
| Name | |
|---|---|
| struct | ManagedBuffer |
Detailed Description
struct llarp_buffer_t;
TODO: replace usage of these with std::span (via a backport until we move to C++20).
That's a fairly big job, though, as llarp_buffer_t is currently used a bit differently (i.e. maintains both start and current position, plus has some value reading/writing methods).
Public Functions Documentation
function operator[]
inline byte_t operator[](
size_t x
)
function llarp_buffer_t
llarp_buffer_t() =default
function llarp_buffer_t
inline llarp_buffer_t(
byte_t * b,
byte_t * c,
size_t s
)
function llarp_buffer_t
llarp_buffer_t(
const ManagedBuffer &
) =delete
function llarp_buffer_t
llarp_buffer_t(
ManagedBuffer &&
) =delete
function llarp_buffer_t
template <typename Byte ,
typename =std::enable_if_t<not std::is_const_v<Byte> && is_basic_byte<Byte>>>
inline llarp_buffer_t(
Byte * buf,
size_t sz
)
Construct referencing some 1-byte, trivially copyable (e.g.
char, unsigned char, byte_t) pointer type and a buffer size.
function llarp_buffer_t
template <typename Byte ,
typename =std::enable_if_t<not std::is_const_v<Byte> && is_basic_byte<Byte>>>
inline llarp_buffer_t(
std::vector< Byte > & b
)
initialize llarp_buffer_t from vector or array of byte-like values
function llarp_buffer_t
template <typename Byte ,
size_t N,
typename =std::enable_if_t<not std::is_const_v<Byte> && is_basic_byte<Byte>>>
inline llarp_buffer_t(
std::array< Byte, N > & b
)
function llarp_buffer_t
template <typename Byte ,
typename =std::enable_if_t<is_basic_byte<Byte>>>
inline llarp_buffer_t(
const Byte * buf,
size_t sz
)
function llarp_buffer_t
template <typename Byte ,
typename =std::enable_if_t<is_basic_byte<Byte>>>
inline llarp_buffer_t(
const std::vector< Byte > & b
)
function llarp_buffer_t
template <typename Byte ,
size_t N,
typename =std::enable_if_t<is_basic_byte<Byte>>>
inline llarp_buffer_t(
const std::array< Byte, N > & b
)
function llarp_buffer_t
template <typename T ,
typename =std::void_t<decltype(std::declval<T>().data() + std::declval<T>().size())>>
inline explicit llarp_buffer_t(
T && t
)
Explicitly construct a llarp_buffer_t from anything with a .data() and a .size(). Cursed.
function begin
inline byte_t * begin()
function begin
inline const byte_t * begin() const
function end
inline byte_t * end()
function end
inline const byte_t * end() const
function size_left
inline size_t size_left() const
function read_into
template <typename OutputIt >
bool read_into(
OutputIt begin,
OutputIt end
)
function write
template <typename InputIt >
bool write(
InputIt begin,
InputIt end
)
function writef
bool writef(
const char * fmt,
...
)
function put_uint16
bool bool put_uint16(
uint16_t i
)
function put_uint32
bool put_uint32(
uint32_t i
)
function put_uint64
bool put_uint64(
uint64_t i
)
function read_uint16
bool read_uint16(
uint16_t & i
)
function read_uint32
bool read_uint32(
uint32_t & i
)
function read_uint64
bool read_uint64(
uint64_t & i
)
function read_until
size_t read_until(
char delim,
byte_t * result,
size_t resultlen
)
function copy
std::vector< byte_t > copy() const
make a copy of this buffer
function view_all
inline llarp::byte_view_t view_all() const
get a read-only view over the entire region
function view_remaining
inline llarp::byte_view_t view_remaining() const
get a read-only view over the remaining/unused region
function startswith
inline bool startswith(
std::string_view prefix_str
) const
Part of the curse.
Returns true if the remaining buffer space starts with the given string view.
Public Attributes Documentation
variable base
byte_t * base {nullptr};
starting memory address
variable cur
byte_t * cur {nullptr};
memory address of stream position
variable sz
size_t sz {0};
max size of buffer
variable is_basic_byte
static constexpr bool is_basic_byte = sizeof(Byte) == 1 and std::is_trivially_copyable_v<Byte>;
Friends
friend ManagedBuffer
friend struct ManagedBuffer(
ManagedBuffer
);
Updated on 2026-01-10 at 22:49:44 +0000