23 std::ostringstream ss;
25 for (
size_t i = 0, e =
data.size(); i != e; ++i) {
27 if (i % 8 == 0 && i != 0)
30 if (i % 64 == 0 && i != 0)
32 ss << static_cast<unsigned>(
data[i]);
38 return toHex(
reinterpret_cast<uint64_t
>(val));
42 std::ostringstream ss;
43 ss << std::hex << val;
64 std::vector<uint8_t> buf;
86 return {seg.
data + off, seg.
size - off};
94 while (n > 0 && !
done()) {
A logical chunk of data representing serialized data.
std::string toHex() const
Convert the data to a hex string.
std::vector< uint8_t > data
const SegmentedMessageData & msg
void reset()
Reset to the beginning.
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.
MessageData toMessageData() const
Flatten all segments into a standard MessageData.
bool empty() const
True if totalSize() == 0.
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.