29#include <flow/error/error.hpp>
41 (seg.size() / sizeof(::
capnp::word)) * sizeof(::
capnp::word)),
48 assert(
m_seg.size() != 0);
49 assert(((
reinterpret_cast<uintptr_t
>(
m_seg.data()) %
alignof(::capnp::word)) == 0)
50 &&
"capnp requires word-aligned segments; beware, e.g., a stack byte-array sans alignas.");
56 using flow::error::Runtime_error;
57 using Word = capnp::word;
58 using Capnp_word_buf = kj::ArrayPtr<Word>;
64 "Capped_sz_capnp_message_builder::allocateSegment()[bad size cap]"};
68 assert(((min_sz_words *
sizeof(Word)) <=
m_seg.size())
69 &&
"Should not be possible: First allocateSegment() always takes `1`; second would have thrown above.");
71 return Capnp_word_buf{
reinterpret_cast<Word*
>(
m_seg.data()),
72 reinterpret_cast<Word*
>(
static_cast<uint8_t*
>(
m_seg.data()) +
m_seg.size())};
78 seg.size() / sizeof(::
capnp::word)),
83 assert(((
reinterpret_cast<uintptr_t
>(seg.data()) %
alignof(::capnp::word)) == 0)
84 &&
"capnp requires word-aligned segments; beware, e.g., a stack byte-array sans alignas.");
kj::ArrayPtr<::capnp::word > allocateSegment(unsigned int min_sz_words) override
Implements MessageBuilder API.
util::Blob_mutable m_seg
Copy of seg (the buffer description... not the actual buffer!) given to ctor.
Capped_sz_capnp_message_builder(const util::Blob_mutable &seg, bool zero_it_please)
Constructor that remembers the given memory area.
bool m_returned_seg
true if and only if allocateSegment() has been called.
kj::ArrayPtr< const ::capnp::word > Word_array_ptr_base
Convenience alias for capnp equivalent of util::Blob_const but in words as opposed to bytes.
Capped_sz_capnp_message_reader(const util::Blob_const &seg)
Constructs MessageReader based on an existing contiguous memory area; is equivalent to the simple Seg...
::capnp::SegmentArrayMessageReader Seg_array_msg_reader_base
Convenient alias for capnp SegmentArrayMessageReader.
Small group of miscellaneous utilities to ease work with capnp (Cap'n Proto), joining its capnp names...
@ S_INVALID_ARGUMENT
User called an API with 1 or more arguments against the API spec.
Sub-module of Flow-IPC module ipc::transport providing transmission of structured messages specifical...
boost::asio::mutable_buffer Blob_mutable
Short-hand for a mutable blob somewhere in memory, stored as exactly a void* and a size_t.
boost::asio::const_buffer Blob_const
Short-hand for an immutable blob somewhere in memory, stored as exactly a void const * and a size_t.