#include #include #include #include "ctx.h" #ifndef memory_Context_HEADER #define memory_Context_HEADER struct memory_Context { bool didLaunch = false; bool exit = false; std::string input = ""; std::vector hiddenItems; std::vector mismatchedItems; std::string recentField = "none"; std::string outputGoOn = ""; std::string outputGreeting = ""; std::string outputHelp = ""; std::string outputMatchedItems = ""; std::string outputMismatchedItems = ""; std::string outputPromptSelection = ""; std::string outputVictory = ""; std::map playfieldItems; int playfieldSize = 0; int selectedId = -1; std::vector selectedItems; bool victory = false; template T field(const std::string &fieldName) { if (fieldName == "didLaunch") { return *reinterpret_cast(&didLaunch); } else if (fieldName == "exit") { return *reinterpret_cast(&exit); } else if (fieldName == "input") { return *reinterpret_cast(&input); } else if (fieldName == "hiddenItems") { return *reinterpret_cast(&hiddenItems); } else if (fieldName == "mismatchedItems") { return *reinterpret_cast(&mismatchedItems); } else if (fieldName == "outputGoOn") { return *reinterpret_cast(&outputGoOn); } else if (fieldName == "outputGreeting") { return *reinterpret_cast(&outputGreeting); } else if (fieldName == "outputHelp") { return *reinterpret_cast(&outputHelp); } else if (fieldName == "outputMatchedItems") { return *reinterpret_cast(&outputMatchedItems); } else if (fieldName == "outputMismatchedItems") { return *reinterpret_cast(&outputMismatchedItems); } else if (fieldName == "outputPromptSelection") { return *reinterpret_cast(&outputPromptSelection); } else if (fieldName == "outputVictory") { return *reinterpret_cast(&outputVictory); } else if (fieldName == "playfieldItems") { return *reinterpret_cast(&playfieldItems); } else if (fieldName == "playfieldSize") { return *reinterpret_cast(&playfieldSize); } else if (fieldName == "selectedId") { return *reinterpret_cast(&selectedId); } else if (fieldName == "selectedItems") { return *reinterpret_cast(&selectedItems); } // victory return *reinterpret_cast(&victory); } void setField(const std::string &fieldName, bool value) { if (fieldName == "didLaunch") { didLaunch = value; } else if (fieldName == "exit") { exit = value; } else if (fieldName == "victory") { victory = value; } } void setField(const std::string &fieldName, const std::string &value) { if (fieldName == "input") { input = value; } else if (fieldName == "outputGoOn") { outputGoOn = value; } else if (fieldName == "outputGreeting") { outputGreeting = value; } else if (fieldName == "outputHelp") { outputHelp = value; } else if (fieldName == "outputMatchedItems") { outputMatchedItems = value; } else if (fieldName == "outputMismatchedItems") { outputMismatchedItems = value; } else if (fieldName == "outputPromptSelection") { outputPromptSelection = value; } else if (fieldName == "outputVictory") { outputVictory = value; } } void setField(const std::string &fieldName, const std::vector &value) { if (fieldName == "hiddenItems") { hiddenItems = value; } else if (fieldName == "mismatchedItems") { mismatchedItems = value; } else if (fieldName == "selectedItems") { selectedItems = value; } } void setField(const std::string &fieldName, const std::map &value) { if (fieldName == "playfieldItems") { playfieldItems = value; } } void setField(const std::string &fieldName, int value) { if (fieldName == "playfieldSize") { playfieldSize = value; } else if (fieldName == "selectedId") { selectedId = value; } } }; memory_Context memory_createContext(); #endif // memory_Context_HEADER