Class BinarySerializer

Inheritance Relationships

Base Type

Class Documentation

class BinarySerializer : public portal::Serializer

Concrete binary serialization implementation using a compact stream format.

BinarySerializer writes data sequentially to an std::ostream in a custom binary format optimized for compactness and speed.

Public Functions

explicit BinarySerializer(std::ostream &output)
BinarySerializer(std::ostream &output, BinarySerializationParams params)

Protected Functions

virtual void add_property(reflection::Property property) override
virtual size_t reserve_slot(reflection::Property property) override

Reserve space for a value and return the position where the value data will be written.

Implementations should write placeholder metadata and value bytes based on the property, then return the position where the actual value data starts (after any metadata).

Parameters:

property – The property describing the reserved value (buffer will be empty/null)

Returns:

The byte position where the value data starts

virtual void write_at(size_t position, const void *data, size_t size) override

Write data at a specific position without changing the current write position.

Used by ReservedSlot to fill in reserved values after subsequent data has been written.

Parameters:
  • position – The byte position to write at

  • data – Pointer to the data to write

  • size – Number of bytes to write