Donner 0.5.1
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
donner::editor::sandbox::WireReader Class Reference

Read cursor into an immutable byte span. Every read that could overflow the buffer returns false and leaves failed_ set, so callers can do their work without interleaved error checking and verify success at the end. More...

#include "donner/editor/sandbox/Wire.h"

Public Member Functions

 WireReader (std::span< const uint8_t > bytes)
bool failed () const
std::size_t remaining () const
std::size_t position () const
void fail ()
 Manually mark the reader failed (e.g., when a higher-level invariant is violated like an unknown variant tag).
bool skip (std::size_t n)
 Seeks forward by n bytes, e.g. to skip over a payload the caller doesn't understand. Fails on overflow.
bool readMessageHeader (Opcode &outOpcode, uint32_t &outPayloadLength)
 Reads u32 opcode, u32 payload_length from the head of the buffer.
Primitive reads
bool readU8 (uint8_t &out)
bool readU32 (uint32_t &out)
bool readI32 (int32_t &out)
bool readU64 (uint64_t &out)
bool readF64 (double &out)
bool readBool (bool &out)
bool readString (std::string &out, uint32_t maxBytes=kMaxStringBytes)
bool readBytes (std::span< uint8_t > out)
bool readCount (uint32_t &out, uint32_t maxCount)
 Reads a u32 length field and validates it against a per-field cap before the caller allocates anything. Returns the length on success.

Detailed Description

Read cursor into an immutable byte span. Every read that could overflow the buffer returns false and leaves failed_ set, so callers can do their work without interleaved error checking and verify success at the end.


The documentation for this class was generated from the following file:
  • donner/editor/sandbox/Wire.h