Represents a mutable view of a contiguous block of bytes.
An empty() Buf has no bytes (size() == 0). A null Buf has no bytes, and its base() and data() are nullptr. A Buf is null when default-constructed, moved-from, reset, or when allocation fails.
An empty Buf is not necessarily null (for example, if it has been sliced or truncated to length 0), in which case base() and data() return non-null pointers.
Nullness can be checked via comparison to nullptr (buf == nullptr, buf != nullptr). operator bool is not provided to prevent confusion between nullness and emptiness.
|
|
constexpr | Buf ()=default |
| | Constructs a null Buf.
|
| |
|
constexpr | Buf (std::nullptr_t) noexcept |
| | Constructs a null Buf.
|
| |
| constexpr | Buf (Buf &&other) noexcept |
| |
| | Buf (UniquePtr< std::byte[]> &&buffer) |
| |
| | Buf (UniquePtr< std::byte[]> &&buffer, size_t offset) |
| |
|
| Buf (UniquePtr< std::byte[]> &&buffer, size_t offset, size_t size) |
| | Constructs an owned Buf from a UniquePtr, offset, and size.
|
| |
|
constexpr | Buf (std::byte *allocation, size_t size, Deallocator &deallocator) |
| | Constructs an owned Buf from a raw buffer, size, and deallocator.
|
| |
| constexpr | Buf (std::byte *allocation, size_t offset, size_t size, Deallocator &deallocator) |
| |
|
| Buf (const Buf &)=delete |
| |
| Buf & | operator= (Buf &&other) noexcept |
| |
|
Buf & | operator= (const Buf &)=delete |
| |
| Buf & | operator= (std::nullptr_t) noexcept |
| |
| | operator bool () const =delete |
| |
| | operator const ConstBuf & () const & |
| |
|
| operator const ConstBuf && () const && |
| |
|
const_reference | operator[] (size_t index) const |
| | Accesses the byte at the specified index as read-only.
|
| |
|
reference | operator[] (size_t index) |
| | Accesses the byte at the specified index as mutable.
|
| |
| constexpr const_pointer | data () const |
| |
| constexpr pointer | data () |
| |
|
constexpr size_t | size () const |
| | Returns the size of the buffer.
|
| |
| constexpr bool | empty () const |
| |
| constexpr const std::byte * | base () const |
| |
| constexpr Deallocator * | deallocator () const |
| |
|
const_iterator | begin () const |
| | Returns a read-only iterator pointing to the beginning of the data.
|
| |
|
const_iterator | end () const |
| | Returns a read-only iterator pointing past the end of the data.
|
| |
|
const_iterator | cbegin () const |
| | Returns a read-only iterator pointing to the beginning of the data.
|
| |
|
const_iterator | cend () const |
| | Returns a read-only iterator pointing past the end of the data.
|
| |
|
iterator | begin () |
| | Returns a mutable iterator pointing to the beginning of the data.
|
| |
|
iterator | end () |
| | Returns a mutable iterator pointing past the end of the data.
|
| |
|
void | reset () |
| | Frees the owned memory (if any) and sets the buffer to null.
|
| |
|
|
static Buf | Unowned (ByteSpan span, size_t offset, size_t size) |
| | Creates an unowned Buf from a ByteSpan, offset, and size.
|
| |
| static Buf | Unowned (ByteSpan span, size_t offset=0) |
| |
|
static Buf | Unowned (std::byte *base, size_t offset, size_t size) |
| | Creates an unowned Buf from a pointer, offset, and size.
|
| |
|
static Buf | Unowned (std::byte *base, size_t size) |
| | Creates an unowned Buf from a pointer and size.
|
| |
| static Buf | Allocate (Allocator &allocator, size_t size) |
| |
| static Buf | Allocate (Allocator &allocator, size_t offset, size_t size) |
| |
| static Buf | TryAllocate (Allocator &allocator, size_t size) |
| |
| static Buf | TryAllocate (Allocator &allocator, size_t offset, size_t size) |
| |
|
|
class | ConstBuf |
| |
|
class | multibuf::v2::internal::GenericMultiBuf |
| |
|
constexpr bool | operator== (const Buf &lhs, std::nullptr_t) noexcept |
| |
|
constexpr bool | operator== (std::nullptr_t, const Buf &rhs) noexcept |
| |
|
constexpr bool | operator!= (const Buf &lhs, std::nullptr_t) noexcept |
| |
|
constexpr bool | operator!= (std::nullptr_t, const Buf &rhs) noexcept |
| |
|
Buf | Slice (Buf &&buf, size_t offset, size_t length) |
| | Slices a mutable Buf by shifting its start address and setting its size.
|
| |
| Buf | Reclaim (Buf &&buf, size_t prefix_count, size_t suffix_count) |
| |