C/C++ API Reference
Loading...
Searching...
No Matches
pw_buf

Overview

Contiguous buffer views with optional memory ownership.

Main docs: Home

Classes

class  pw::ConstBuf
 
class  pw::Buf
 Represents a mutable view of a contiguous block of bytes. More...
 

Functions

ConstBuf pw::Slice (ConstBuf &&const_buf, size_t offset, size_t length)
 
ConstBuf pw::Slice (ConstBuf &&const_buf, size_t offset)
 
ConstBuf pw::Truncate (ConstBuf &&const_buf, size_t length)
 Truncates a read-only ConstBuf to a smaller size.
 
Buf pw::Slice (Buf &&buf, size_t offset, size_t length)
 Slices a mutable Buf by shifting its start address and setting its size.
 
Buf pw::Slice (Buf &&buf, size_t offset)
 
Buf pw::Truncate (Buf &&buf, size_t length)
 Truncates a mutable Buf to a smaller size.
 
Buf pw::Reclaim (Buf &&buf, size_t prefix_count, size_t suffix_count)
 
Buf pw::ReclaimPrefix (Buf &&buf, size_t count)
 Reclaims up to count prefix bytes at the beginning of the buffer.
 
Buf pw::ReclaimSuffix (Buf &&buf, size_t count)
 Reclaims up to count suffix bytes at the end of the buffer.
 
constexpr pw::ConstBuf::ConstBuf (Buf &&other) noexcept
 Move-constructs a ConstBuf from a mutable Buf (move conversion).
 
 pw::Buf::Buf (UniquePtr< std::byte[]> &&buffer, size_t offset)
 
 pw::Buf::Buf (UniquePtr< std::byte[]> &&buffer, size_t offset, size_t size)
 Constructs an owned Buf from a UniquePtr, offset, and size.
 
static Buf pw::Buf::Unowned (ByteSpan span, size_t offset, size_t size)
 Creates an unowned Buf from a ByteSpan, offset, and size.
 
static Buf pw::Buf::Unowned (ByteSpan span, size_t offset=0)
 

Function Documentation

◆ Buf()

pw::Buf::Buf ( UniquePtr< std::byte[]> &&  buffer,
size_t  offset 
)
inlineexplicit

Constructs an owned Buf using the remaining length starting from offset.

◆ Reclaim()

Buf pw::Reclaim ( Buf &&  buf,
size_t  prefix_count,
size_t  suffix_count 
)
inline

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

◆ Slice() [1/3]

Buf pw::Slice ( Buf &&  buf,
size_t  offset 
)
inline

Slices a mutable Buf by shifting its start address to the end.

Note: if offset exceeds size, the subtraction wraps and fails the bounds check in the delegating Slice function.

◆ Slice() [2/3]

ConstBuf pw::Slice ( ConstBuf &&  const_buf,
size_t  offset 
)
inline

Slices a read-only ConstBuf by shifting its start address to the end.

Note: if offset exceeds size, the subtraction wraps and fails the bounds check in the delegating Slice function.

◆ Slice() [3/3]

ConstBuf pw::Slice ( ConstBuf &&  const_buf,
size_t  offset,
size_t  length 
)
inline

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

◆ Unowned()

Buf pw::Buf::Unowned ( ByteSpan  span,
size_t  offset = 0 
)
inlinestatic

Creates an unowned Buf using the remaining length starting from offset.