Skip to content

Advanced Serialization

Andrew Gresyk edited this page Apr 2, 2022 · 2 revisions

Serialization

  1. FSM instance can be stored to char buffer and restored from it.

  2. Serialization can be used for saving FSM to file or network replication.

Tests

  1. Enable serialization support

    #define HFSM2_ENABLE_SERIALIZATION
    #include <hfsm2/machine.hpp>
Method Description
void Instance::save(SerialBuffer& buffer) const; Store instance state
void Instance::load(const SerialBuffer& buffer); Restore instance state

SerialBuffer

Method Description
void SerialBuffer::clear(); Clear buffer
Data& SerialBuffer::data();
const Data& SerialBuffer::data() const;
Data access