#pragma once

#include <memory>
#include <string>

struct Command;

// Serializes a command to a single-line, space-delimited token sequence for the
// replay file (see docs/replay_design.md "File format: line-oriented ...").
// Config ids (building types, recipes, items, modules) are whitespace-free
// identifiers, so space delimiting is unambiguous; variable-length parts are
// length-prefixed so the matching parser (added in Phase 3) is unambiguous.
//
// Reset is a file boundary (it rolls the replay file), not a stream entry, so it
// is never serialized here.
std::string serializeCommand(const Command& command);

// Inverse of serializeCommand: parses the command token sequence (the part of a
// replay line after the leading tick) back into a Command. Returns nullptr if the
// tokens are malformed or reference an unknown building type.
std::shared_ptr<Command> parseCommand(const std::string& tokens);
