| 8 | namespace po = boost::program_options; |
| 9 | |
| 10 | void writeHeader(std::ofstream &out, const StateDefinition &state) |
| 11 | { |
| 12 | out << "// GENERATED HEADER - generated by GamestateSerializeGen - do not modify directly\n\n"; |
| 13 | out << "#pragma once\n\n"; |
| 14 | out << "#include \"game/state/gamestate.h\"\n\n"; |
| 15 | out << "#include \"game/state/gamestate_serialize.h\"\n\n"; |
| 16 | out << "namespace OpenApoc {\n\n"; |
| 17 | out << "static constexpr const char* const GAMESTATE_SERIALIZATION_VERSION = \"" |
| 18 | << state.hashString << "\";\n"; |
| 19 | out << "class SerializationNode;\n\n"; |
| 20 | for (auto &object : state.objects) |
| 21 | { |
| 22 | if (object.external == false) |
| 23 | continue; |
| 24 | out << "void serializeIn(const GameState *, SerializationNode* node, " << object.name |
| 25 | << " &obj);\n"; |
| 26 | out << "void serializeOut(SerializationNode* node, const " << object.name << " &obj, const " |
| 27 | << object.name << " &ref);\n"; |
| 28 | out << "bool operator==(const " << object.name << " &a, const " << object.name << " &b);\n"; |
| 29 | out << "bool operator!=(const " << object.name << " &a, const " << object.name |
| 30 | << " &b);\n\n"; |
| 31 | } |
| 32 | |
| 33 | for (auto &e : state.enums) |
| 34 | { |
| 35 | if (e.external == false) |
| 36 | continue; |
| 37 | out << "void serializeIn(const GameState *, SerializationNode* node, " << e.name |
| 38 | << " &val);\n"; |
| 39 | out << "void serializeOut(SerializationNode* node, const " << e.name << " &val, const " |
| 40 | << e.name << " &ref);\n"; |
| 41 | } |
| 42 | |
| 43 | out << "\n} // namespace OpenApoc\n"; |
| 44 | } |
| 45 | |
| 46 | void writeSource(std::ofstream &out, const StateDefinition &state) |
| 47 | { |