C/C++ API Reference
Loading...
Searching...
No Matches
pw::ConstBuf Class Reference

Overview

Represents a read-only view of a contiguous block of bytes.

Users access a Buf through a ConstBuf reference to ensure the underlying data is not modified.

Public Types

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

Public Member Functions

constexpr ConstBuf ()=default
 Constructs an empty ConstBuf.
 
constexpr ConstBuf (ConstBuf &&other) noexcept
 Move constructor.
 
constexpr ConstBuf (Buf &&other) noexcept
 Move-constructs a ConstBuf from a mutable Buf (move conversion).
 
 ConstBuf (const ConstBuf &)=delete
 
 ~ConstBuf ()
 Destructor. Releases the owned memory back to the allocator.
 
ConstBufoperator= (ConstBuf &&other) noexcept
 Move assignment operator.
 
ConstBufoperator= (Buf &&other) noexcept
 Move conversion assignment operator from Buf.
 
ConstBufoperator= (const ConstBuf &)=delete
 
reference operator[] (size_t index) const
 Accesses the byte at the specified index.
 
pointer data () const
 Returns a pointer to the read-only data.
 
size_t size () const
 Returns the number of bytes in the buffer view.
 
bool empty () const
 Returns true if the buffer view is empty.
 
iterator begin () const
 Returns a read-only iterator pointing to the beginning of the data.
 
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.
 
Deallocatordeallocator () const
 
void reset ()
 Frees the owned memory, leaving the buffer empty.
 

Friends

class Buf
 
class multibuf::v2::internal::GenericMultiBuf
 
ConstBuf Slice (ConstBuf &&const_buf, size_t offset, size_t length)
 
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)
 

Member Function Documentation

◆ deallocator()

Deallocator * pw::ConstBuf::deallocator ( ) const
inline

Returns a pointer to the deallocator if this buffer owns the underlying memory allocation, or nullptr if the buffer is unowned.

Friends And Related Function Documentation

◆ Reclaim

Buf Reclaim ( Buf &&  buf,
size_t  prefix_count,
size_t  suffix_count 
)
friend

Reclaims up to prefix_count bytes at the beginning and suffix_count bytes at the end of the buffer.

◆ Slice

ConstBuf Slice ( ConstBuf &&  const_buf,
size_t  offset,
size_t  length 
)
friend

Slices a read-only ConstBuf by shifting its start address and setting its size.


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