|
|
@@ -1,10 +1,9 @@ |
|
|
|
#include <utility> |
|
|
|
#include "any.h" |
|
|
|
#include <any> |
|
|
|
#include "memory_Context.h" |
|
|
|
|
|
|
|
#include <iostream> |
|
|
|
|
|
|
|
libany::any memory_Context::field(const std::string &fieldName) { |
|
|
|
std::any memory_Context::field(const std::string &fieldName) { |
|
|
|
if (fieldName == "didLaunch") { |
|
|
|
return didLaunch; |
|
|
|
} else if (fieldName == "exit") { |
|
|
@@ -42,47 +41,41 @@ libany::any memory_Context::field(const std::string &fieldName) { |
|
|
|
return victory; |
|
|
|
} |
|
|
|
|
|
|
|
void memory_Context::setField(const std::string &fieldName, libany::any value) { |
|
|
|
void memory_Context::setField(const std::string &fieldName, std::any value) { |
|
|
|
if (fieldName == "didLaunch") { |
|
|
|
didLaunch = libany::any_cast<bool>(value); |
|
|
|
didLaunch = std::any_cast<bool>(value); |
|
|
|
} else if (fieldName == "exit") { |
|
|
|
exit = libany::any_cast<bool>(value); |
|
|
|
exit = std::any_cast<bool>(value); |
|
|
|
} else if (fieldName == "hiddenItems") { |
|
|
|
hiddenItems = libany::any_cast<std::vector<int> >(value); |
|
|
|
hiddenItems = std::any_cast<std::vector<int> >(value); |
|
|
|
} else if (fieldName == "input") { |
|
|
|
std::cout << "memory_Context-01\n"; |
|
|
|
try { |
|
|
|
input = libany::any_cast<std::string>(value); |
|
|
|
} catch (libany::bad_any_cast &e) { |
|
|
|
std::cout << "memory_Context-01 exception/type: " << e.what() << ", " << value.type().name() << std::endl; |
|
|
|
} |
|
|
|
std::cout << "memory_Context-02\n"; |
|
|
|
input = std::any_cast<std::string>(value); |
|
|
|
} else if (fieldName == "mismatchedItems") { |
|
|
|
mismatchedItems = libany::any_cast<std::vector<int> >(value); |
|
|
|
mismatchedItems = std::any_cast<std::vector<int> >(value); |
|
|
|
} else if (fieldName == "outputGoOn") { |
|
|
|
outputGoOn = libany::any_cast<std::string>(value); |
|
|
|
outputGoOn = std::any_cast<std::string>(value); |
|
|
|
} else if (fieldName == "outputGreeting") { |
|
|
|
outputGreeting = libany::any_cast<std::string>(value); |
|
|
|
outputGreeting = std::any_cast<std::string>(value); |
|
|
|
} else if (fieldName == "outputHelp") { |
|
|
|
outputHelp = libany::any_cast<std::string>(value); |
|
|
|
outputHelp = std::any_cast<std::string>(value); |
|
|
|
} else if (fieldName == "outputMatchedItems") { |
|
|
|
outputMatchedItems = libany::any_cast<std::string>(value); |
|
|
|
outputMatchedItems = std::any_cast<std::string>(value); |
|
|
|
} else if (fieldName == "outputMismatchedItems") { |
|
|
|
outputMismatchedItems = libany::any_cast<std::string>(value); |
|
|
|
outputMismatchedItems = std::any_cast<std::string>(value); |
|
|
|
} else if (fieldName == "outputPromptSelection") { |
|
|
|
outputPromptSelection = libany::any_cast<std::string>(value); |
|
|
|
outputPromptSelection = std::any_cast<std::string>(value); |
|
|
|
} else if (fieldName == "outputVictory") { |
|
|
|
outputVictory = libany::any_cast<std::string>(value); |
|
|
|
outputVictory = std::any_cast<std::string>(value); |
|
|
|
} else if (fieldName == "playfieldItems") { |
|
|
|
playfieldItems = libany::any_cast<std::map<int, int> >(value); |
|
|
|
playfieldItems = std::any_cast<std::map<int, int> >(value); |
|
|
|
} else if (fieldName == "playfieldSize") { |
|
|
|
playfieldSize = libany::any_cast<int>(value); |
|
|
|
playfieldSize = std::any_cast<int>(value); |
|
|
|
} else if (fieldName == "selectedId") { |
|
|
|
selectedId = libany::any_cast<int>(value); |
|
|
|
selectedId = std::any_cast<int>(value); |
|
|
|
} else if (fieldName == "selectedItems") { |
|
|
|
selectedItems = libany::any_cast<std::vector<int> >(value); |
|
|
|
selectedItems = std::any_cast<std::vector<int> >(value); |
|
|
|
} else if (fieldName == "victory") { |
|
|
|
victory = libany::any_cast<bool>(value); |
|
|
|
victory = std::any_cast<bool>(value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|