d
This commit is contained in:
@@ -1,6 +1,4 @@
|
|||||||
#c++ -o test_memory_C++ -std=c++11 -I. \
|
c++ -o test_memory_C++ -std=c++11 -I. \
|
||||||
#c++ -o test_memory_C++ -std=c++17 -I. \
|
|
||||||
c++ -o test_memory_C++ -std=c++20 -I. \
|
|
||||||
memory.cpp \
|
memory.cpp \
|
||||||
memory_Context.cpp \
|
memory_Context.cpp \
|
||||||
memory_test.cpp \
|
memory_test.cpp \
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include <any>
|
#include "any.h"
|
||||||
#include "memory_Context.h"
|
#include "memory_Context.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
std::any memory_Context::field(const std::string &fieldName) {
|
libany::any memory_Context::field(const std::string &fieldName) {
|
||||||
if (fieldName == "didLaunch") {
|
if (fieldName == "didLaunch") {
|
||||||
return didLaunch;
|
return didLaunch;
|
||||||
} else if (fieldName == "exit") {
|
} else if (fieldName == "exit") {
|
||||||
@@ -41,41 +41,41 @@ std::any memory_Context::field(const std::string &fieldName) {
|
|||||||
return victory;
|
return victory;
|
||||||
}
|
}
|
||||||
|
|
||||||
void memory_Context::setField(const std::string &fieldName, std::any value) {
|
void memory_Context::setField(const std::string &fieldName, libany::any value) {
|
||||||
if (fieldName == "didLaunch") {
|
if (fieldName == "didLaunch") {
|
||||||
didLaunch = std::any_cast<bool>(value);
|
didLaunch = libany::any_cast<bool>(value);
|
||||||
} else if (fieldName == "exit") {
|
} else if (fieldName == "exit") {
|
||||||
exit = std::any_cast<bool>(value);
|
exit = libany::any_cast<bool>(value);
|
||||||
} else if (fieldName == "hiddenItems") {
|
} else if (fieldName == "hiddenItems") {
|
||||||
hiddenItems = std::any_cast<std::vector<int> >(value);
|
hiddenItems = libany::any_cast<std::vector<int> >(value);
|
||||||
} else if (fieldName == "input") {
|
} else if (fieldName == "input") {
|
||||||
input = std::any_cast<std::string>(value);
|
input = libany::any_cast<std::string>(value);
|
||||||
} else if (fieldName == "mismatchedItems") {
|
} else if (fieldName == "mismatchedItems") {
|
||||||
mismatchedItems = std::any_cast<std::vector<int> >(value);
|
mismatchedItems = libany::any_cast<std::vector<int> >(value);
|
||||||
} else if (fieldName == "outputGoOn") {
|
} else if (fieldName == "outputGoOn") {
|
||||||
outputGoOn = std::any_cast<std::string>(value);
|
outputGoOn = libany::any_cast<std::string>(value);
|
||||||
} else if (fieldName == "outputGreeting") {
|
} else if (fieldName == "outputGreeting") {
|
||||||
outputGreeting = std::any_cast<std::string>(value);
|
outputGreeting = libany::any_cast<std::string>(value);
|
||||||
} else if (fieldName == "outputHelp") {
|
} else if (fieldName == "outputHelp") {
|
||||||
outputHelp = std::any_cast<std::string>(value);
|
outputHelp = libany::any_cast<std::string>(value);
|
||||||
} else if (fieldName == "outputMatchedItems") {
|
} else if (fieldName == "outputMatchedItems") {
|
||||||
outputMatchedItems = std::any_cast<std::string>(value);
|
outputMatchedItems = libany::any_cast<std::string>(value);
|
||||||
} else if (fieldName == "outputMismatchedItems") {
|
} else if (fieldName == "outputMismatchedItems") {
|
||||||
outputMismatchedItems = std::any_cast<std::string>(value);
|
outputMismatchedItems = libany::any_cast<std::string>(value);
|
||||||
} else if (fieldName == "outputPromptSelection") {
|
} else if (fieldName == "outputPromptSelection") {
|
||||||
outputPromptSelection = std::any_cast<std::string>(value);
|
outputPromptSelection = libany::any_cast<std::string>(value);
|
||||||
} else if (fieldName == "outputVictory") {
|
} else if (fieldName == "outputVictory") {
|
||||||
outputVictory = std::any_cast<std::string>(value);
|
outputVictory = libany::any_cast<std::string>(value);
|
||||||
} else if (fieldName == "playfieldItems") {
|
} else if (fieldName == "playfieldItems") {
|
||||||
playfieldItems = std::any_cast<std::map<int, int> >(value);
|
playfieldItems = libany::any_cast<std::map<int, int> >(value);
|
||||||
} else if (fieldName == "playfieldSize") {
|
} else if (fieldName == "playfieldSize") {
|
||||||
playfieldSize = std::any_cast<int>(value);
|
playfieldSize = libany::any_cast<int>(value);
|
||||||
} else if (fieldName == "selectedId") {
|
} else if (fieldName == "selectedId") {
|
||||||
selectedId = std::any_cast<int>(value);
|
selectedId = libany::any_cast<int>(value);
|
||||||
} else if (fieldName == "selectedItems") {
|
} else if (fieldName == "selectedItems") {
|
||||||
selectedItems = std::any_cast<std::vector<int> >(value);
|
selectedItems = libany::any_cast<std::vector<int> >(value);
|
||||||
} else if (fieldName == "victory") {
|
} else if (fieldName == "victory") {
|
||||||
victory = std::any_cast<bool>(value);
|
victory = libany::any_cast<bool>(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <any>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "any.h"
|
||||||
#include "ctx.h"
|
#include "ctx.h"
|
||||||
|
|
||||||
#ifndef memory_Context_HEADER
|
#ifndef memory_Context_HEADER
|
||||||
@@ -27,8 +27,8 @@ struct memory_Context {
|
|||||||
std::vector<int> selectedItems;
|
std::vector<int> selectedItems;
|
||||||
bool victory = false;
|
bool victory = false;
|
||||||
|
|
||||||
std::any field(const std::string &fieldName);
|
libany::any field(const std::string &fieldName);
|
||||||
void setField(const std::string &fieldName, std::any value);
|
void setField(const std::string &fieldName, libany::any value);
|
||||||
};
|
};
|
||||||
|
|
||||||
memory_Context memory_createContext();
|
memory_Context memory_createContext();
|
||||||
|
|||||||
Reference in New Issue
Block a user