NPRPC docs

class OwnedDirect

C++

template <typename TD> class OwnedDirect

Generic zero-copy buffer owner for any flat Direct accessor type. Used for 'out direct struct/array/string/optional' RPC arguments. Stores the shared_ptr that keeps the receive buffer alive, plus the absolute byte offset at which the Direct object lives. The Direct accessor TD is reconstructed cheaply on every call to get().

include/nprpc/flat.hpp:702

Constructors

OwnedDirect<TD>() = default

An empty owner; valid() is false.

include/nprpc/flat.hpp:709

OwnedDirect<TD>(std::shared_ptr< ::nprpc::flat_buffer> buf, uint32_t offset) noexcept

Owns buf, with the accessor's data at offset.

include/nprpc/flat.hpp:712

Methods

std::shared_ptr< ::nprpc::flat_buffer> buffer() const noexcept

The owned buffer, to share its lifetime.

include/nprpc/flat.hpp:726

TD get() noexcept

Creates a Direct accessor view into the owned buffer. Very cheap (returns by value — TD only holds a buffer& and a uint32_t).

include/nprpc/flat.hpp:720

bool valid() const noexcept

Whether a buffer is held.

include/nprpc/flat.hpp:723