ConstBufferView

A ConstBufferView references an immutable range of memory. It consists of a pointer bytes and an integer numBytes. It is used to . A ConstBufferView does not own the memory it points to, and no heap memory is freed when the ConstBufferView is destroyed.

ConstBufferView is similar to BufferView except that the memory referenced by ConstBufferView is const, so it's illegal to modify its contents. ConstBufferView is used as the sole argument to OutPipe::write() and OutStream::write().

BufferView is implicitly convertible to ConstBufferView and can be passed as an argument to any function that expects a ConstBufferView.

Header File

#include <ply-runtime/container/BufferView.h>

Also included from <ply-runtime/Base.h>.

Data Members

const u8* bytes [code]

The first byte in the immutable memory range.

u32 numBytes [code]

The number of bytes in the immutable memory range.

Member Functions

ConstBufferView() [code]

Constructs an empty ConstBufferView.

ConstBufferView(const void* bytes, u32 numBytes) [code]

Constructs a ConstBufferView from an explicit pointer and number of bytes.

template <u32 N>
ConstBufferView(const u8& bytes[]) [code]

FIXME: Make this show up Constructs a ConstBufferView from a string literal. (?)

static ConstBufferView fromRange(const u8* startByte, const u8* endByte) [code]

Returns a ConstBufferView referencing a range of memory between two pointers. The number of bytes in the memory range is given by endByte - startByte, and endByte is considered a pointer to the first byte after the memory range.

u8 operator[](u32 ofs) const [code]

Subscript operator that performs runtime bounds checking.

void offsetHead(u32 ofs) [code]

Advances the start of the memory range by ofs bytes while keeping the end of the memory range unchanged.

void offsetBack(s32 ofs) [code]

Advances the end of the memory range by ofs bytes while keeping the start of the memory range unchanged.

ConstBufferView subView(u32 start, u32 numBytes) const [code]

Returns a new, smaller ConstBufferView that references a subrange of this ConstBufferView, with runtime bounds checking. start is the offset of the new ConstBufferView relative to the start of this one, and numBytes is the number of bytes in the new ConstBufferView.

bool contains(const u8* curByte) const [code]

Returns true if curByte points to a byte inside the memory range.

bool operator==(ConstBufferView other) const [code]

Returns true if the contents of this ConstBufferView exactly match the contents of other.

bool operator!=(ConstBufferView other) [code]

Returns true if the contents of this ConstBufferView do not exactly match the contents of other.