24 std::ostringstream ss;
26 for (
size_t i = 0, e =
data.size(); i != e; ++i) {
28 if (i % 8 == 0 && i != 0)
31 if (i % 64 == 0 && i != 0)
33 ss << static_cast<unsigned>(
data[i]);
39 return toHex(
reinterpret_cast<uint64_t
>(val));
43 std::ostringstream ss;
44 ss << std::hex << val;
65 std::vector<uint8_t> buf;
86std::unique_ptr<services::HostMemRegion>
103 while (idx <
msg.numSegments()) {
114 while (n > 0 && !
done()) {
A concrete flat message backed by a single vector of bytes.
std::string toHex() const
Convert the data to a hex string.
std::vector< uint8_t > data
Segment remainingSegment() const
The unconsumed part of the current segment, with its region.
const SegmentedMessageData & msg
void advance(size_t n)
Advance by n bytes, crossing segment boundaries as needed.
bool done() const
True when all segments have been consumed.
std::span< const uint8_t > remaining() const
Contiguous span from current position to end of current segment.
virtual Segment segment(size_t idx) const =0
Get a segment by index. Throws if the segment has been take()n.
virtual MessageData toMessageData() const
Flatten all segments into a standard MessageData.
bool empty() const
True if totalSize() == 0.
virtual std::unique_ptr< services::HostMemRegion > take(size_t segIdx)
Optionally called by a backend once it has transmitted segment segIdx, to obtain ownership of the Hos...
size_t totalSize() const
Total size across all segments.
virtual size_t numSegments() const =0
Number of segments in the message.
std::string toHex(void *val)
A contiguous, non-owning view of bytes within a SegmentedMessageData.
std::span< const uint8_t > span() const
std::optional< uint64_t > getDeviceAddress() const
Device address of this segment's bytes, if region is set and contains them; std::nullopt otherwise.
services::HostMemRegion * region
The HostMem region (from services::HostMem::allocate()) which holds [data, data + size),...