|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #include <any>
- #include "memory_Context.h"
-
- #include <iostream>
-
- std::any memory_Context::field(const std::string &fieldName) {
- if (fieldName == "didLaunch") {
- return didLaunch;
- } else if (fieldName == "exit") {
- return exit;
- } else if (fieldName == "hiddenItems") {
- return hiddenItems;
- } else if (fieldName == "input") {
- return input;
- } else if (fieldName == "mismatchedItems") {
- return mismatchedItems;
- } else if (fieldName == "outputGoOn") {
- return outputGoOn;
- } else if (fieldName == "outputGreeting") {
- return outputGreeting;
- } else if (fieldName == "outputHelp") {
- return outputHelp;
- } else if (fieldName == "outputMatchedItems") {
- return outputMatchedItems;
- } else if (fieldName == "outputMismatchedItems") {
- return outputMismatchedItems;
- } else if (fieldName == "outputPromptSelection") {
- return outputPromptSelection;
- } else if (fieldName == "outputVictory") {
- return outputVictory;
- } else if (fieldName == "playfieldItems") {
- return playfieldItems;
- } else if (fieldName == "playfieldSize") {
- return playfieldSize;
- } else if (fieldName == "selectedId") {
- return selectedId;
- } else if (fieldName == "selectedItems") {
- return selectedItems;
- }
- // victory
- return victory;
- }
-
- void memory_Context::setField(const std::string &fieldName, std::any value) {
- if (fieldName == "didLaunch") {
- didLaunch = std::any_cast<bool>(value);
- } else if (fieldName == "exit") {
- exit = std::any_cast<bool>(value);
- } else if (fieldName == "hiddenItems") {
- hiddenItems = std::any_cast<std::vector<int> >(value);
- } else if (fieldName == "input") {
- input = std::any_cast<std::string>(value);
- } else if (fieldName == "mismatchedItems") {
- mismatchedItems = std::any_cast<std::vector<int> >(value);
- } else if (fieldName == "outputGoOn") {
- outputGoOn = std::any_cast<std::string>(value);
- } else if (fieldName == "outputGreeting") {
- outputGreeting = std::any_cast<std::string>(value);
- } else if (fieldName == "outputHelp") {
- outputHelp = std::any_cast<std::string>(value);
- } else if (fieldName == "outputMatchedItems") {
- outputMatchedItems = std::any_cast<std::string>(value);
- } else if (fieldName == "outputMismatchedItems") {
- outputMismatchedItems = std::any_cast<std::string>(value);
- } else if (fieldName == "outputPromptSelection") {
- outputPromptSelection = std::any_cast<std::string>(value);
- } else if (fieldName == "outputVictory") {
- outputVictory = std::any_cast<std::string>(value);
- } else if (fieldName == "playfieldItems") {
- playfieldItems = std::any_cast<std::map<int, int> >(value);
- } else if (fieldName == "playfieldSize") {
- playfieldSize = std::any_cast<int>(value);
- } else if (fieldName == "selectedId") {
- selectedId = std::any_cast<int>(value);
- } else if (fieldName == "selectedItems") {
- selectedItems = std::any_cast<std::vector<int> >(value);
- } else if (fieldName == "victory") {
- victory = std::any_cast<bool>(value);
- }
- }
-
- memory_Context memory_createContext() {
- return memory_Context();
- }
|