CommandArchive class
Keeps the history of changes in a recovery copy of a level, so they can be undone after it's restored.
The commands are written as they are, with what they hold to be done and undone. Only the newest ones that fit MaxSize are kept, and none older than a command that can't be written. The history is written in the native byte order and layout of the records, a copy made by another build or on another machine is restored without it. The snapshots are kept as they are too, so the fingerprint includes DocumentSnapshot::
The chunk is u8 version (3), a fingerprint of the layout of the records, varuint number of commands, varuint number of those done, varuint number of those done in the saved state plus one (0 if it isn't among them), then the commands, each a varuint size and the command. A command is written once and kept with its entry of the history while it stays the same, so writing the history again costs only the commands that changed.
Public static variables
-
static std::
uint32_t Chunk constexpr - Editor-only chunk of a recovery copy with the history.
-
static std::
size_t MaxSize constexpr - Most bytes of the history written, the oldest commands are left out.
Public static functions
-
static void Write(const CommandHistory& history,
SmallVectorImpl<std::
uint8_t>& data) - Writes the history, no bytes if there's nothing to keep.
-
static auto Read(ArrayView<const std::
uint8_t> data, LevelDocument& document, CommandHistory& history) -> bool - Reads the history into a history just made for the document.
Constructors, destructors, conversion operators
- CommandArchive() deleted
Function documentation
static bool Jazz2:: Editor:: CommandArchive:: Read(ArrayView<const std:: uint8_t> data,
LevelDocument& document,
CommandHistory& history)
Reads the history into a history just made for the document.
The document has to be as it was when the history was written. Returns false if the history can't be read, the history stays empty then.