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

Append-only byte buffer writer. Cheap by design — a std::vector<uint8_t> owner with a few typed helpers. No growth policy beyond the vector's. More...

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

Classes

struct  MessageToken
 Reserves a payload-length slot before the payload is encoded, returning a token the caller hands back to finishMessage() once the payload is complete. This avoids having to buffer the payload twice. More...

Public Member Functions

std::size_t size () const
 Total bytes written so far.
std::span< const uint8_t > data () const
 Returns a view of the accumulated bytes.
std::vector< uint8_t > take () &&
 Releases ownership of the accumulated bytes.
void writeMessageHeader (Opcode opcode, uint32_t payloadLength)
 Writes a raw message header: u32 opcode, u32 payload_length. The caller is responsible for appending payload_length bytes immediately after.
MessageToken beginMessage (Opcode opcode)
void finishMessage (MessageToken token)
Primitives

All writes are little-endian.

void writeU8 (uint8_t v)
void writeU32 (uint32_t v)
void writeI32 (int32_t v)
void writeU64 (uint64_t v)
void writeF64 (double v)
void writeBool (bool v)
void writeBytes (std::span< const uint8_t > bytes)
void writeString (std::string_view s)

Detailed Description

Append-only byte buffer writer. Cheap by design — a std::vector<uint8_t> owner with a few typed helpers. No growth policy beyond the vector's.


Class Documentation

◆ donner::editor::sandbox::WireWriter::MessageToken

struct donner::editor::sandbox::WireWriter::MessageToken

Reserves a payload-length slot before the payload is encoded, returning a token the caller hands back to finishMessage() once the payload is complete. This avoids having to buffer the payload twice.

Class Members
size_t lengthOffset
size_t payloadStart

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