diff --git a/v4/ctx.h b/v4/ctx.h index 5cd47eb..a6f27cd 100644 --- a/v4/ctx.h +++ b/v4/ctx.h @@ -1,7 +1,6 @@ #include #include #include -#include "any.h" #ifndef ctx_HEADER #define ctx_HEADER diff --git a/v4/ctx_test2.cpp b/v4/ctx_test2.cpp index 58b360f..ca60a61 100644 --- a/v4/ctx_test2.cpp +++ b/v4/ctx_test2.cpp @@ -1,18 +1,18 @@ #include #include "ctx.h" #include "memory_Context.h" - #include +std::string s(const char *str) { + return std::string(str); +} + std::string ctx_test_Controller_executeFunctions_set() { auto c = memory_createContext(); ctx_Controller ctrl(c); // Disable automatic invocation of executeFunctions. ctrl.isProcessingQueue = true; - std::cout << "01\n"; - ctrl.set("input", "123"); - std::cout << "input: '" << ctrl.context.input << "'" << std::endl; - std::cout << "02\n"; + ctrl.set("input", s("123")); auto processInput = [](memory_Context c) -> memory_Context { if (c.recentField == "input") { @@ -29,7 +29,14 @@ std::string ctx_test_Controller_executeFunctions_set() { ctrl.executeFunctions(); // Apply 'outputHelp'. ctrl.executeFunctions(); - std::cout << "input: '" << ctrl.context.input << "'" << std::endl; + std::cout + << "input: '" + << ctrl.context.input + << "'" + << ((ctrl.context.input == "123") ? "1" : "0") + << " " + << ((ctrl.context.outputHelp == "Checked") ? "1" : "0") + << std::endl; if ( ctrl.context.input == "123" && ctrl.context.outputHelp == "Checked" diff --git a/v4/gen-C++ b/v4/gen-C++ index 23c8529..4502a20 100755 --- a/v4/gen-C++ +++ b/v4/gen-C++ @@ -1,4 +1,6 @@ -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_Context.cpp \ memory_test.cpp \ diff --git a/v4/memory_Context.cpp b/v4/memory_Context.cpp index 4b49cd9..c5b33a8 100644 --- a/v4/memory_Context.cpp +++ b/v4/memory_Context.cpp @@ -1,10 +1,9 @@ -#include -#include "any.h" +#include #include "memory_Context.h" #include -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(value); + didLaunch = std::any_cast(value); } else if (fieldName == "exit") { - exit = libany::any_cast(value); + exit = std::any_cast(value); } else if (fieldName == "hiddenItems") { - hiddenItems = libany::any_cast >(value); + hiddenItems = std::any_cast >(value); } else if (fieldName == "input") { - std::cout << "memory_Context-01\n"; - try { - input = libany::any_cast(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(value); } else if (fieldName == "mismatchedItems") { - mismatchedItems = libany::any_cast >(value); + mismatchedItems = std::any_cast >(value); } else if (fieldName == "outputGoOn") { - outputGoOn = libany::any_cast(value); + outputGoOn = std::any_cast(value); } else if (fieldName == "outputGreeting") { - outputGreeting = libany::any_cast(value); + outputGreeting = std::any_cast(value); } else if (fieldName == "outputHelp") { - outputHelp = libany::any_cast(value); + outputHelp = std::any_cast(value); } else if (fieldName == "outputMatchedItems") { - outputMatchedItems = libany::any_cast(value); + outputMatchedItems = std::any_cast(value); } else if (fieldName == "outputMismatchedItems") { - outputMismatchedItems = libany::any_cast(value); + outputMismatchedItems = std::any_cast(value); } else if (fieldName == "outputPromptSelection") { - outputPromptSelection = libany::any_cast(value); + outputPromptSelection = std::any_cast(value); } else if (fieldName == "outputVictory") { - outputVictory = libany::any_cast(value); + outputVictory = std::any_cast(value); } else if (fieldName == "playfieldItems") { - playfieldItems = libany::any_cast >(value); + playfieldItems = std::any_cast >(value); } else if (fieldName == "playfieldSize") { - playfieldSize = libany::any_cast(value); + playfieldSize = std::any_cast(value); } else if (fieldName == "selectedId") { - selectedId = libany::any_cast(value); + selectedId = std::any_cast(value); } else if (fieldName == "selectedItems") { - selectedItems = libany::any_cast >(value); + selectedItems = std::any_cast >(value); } else if (fieldName == "victory") { - victory = libany::any_cast(value); + victory = std::any_cast(value); } } diff --git a/v4/memory_Context.h b/v4/memory_Context.h index 78997fe..0a43ac8 100644 --- a/v4/memory_Context.h +++ b/v4/memory_Context.h @@ -1,3 +1,4 @@ +#include #include #include #include @@ -26,8 +27,8 @@ struct memory_Context { std::vector selectedItems; bool victory = false; - libany::any field(const std::string &fieldName); - void setField(const std::string &fieldName, libany::any value); + std::any field(const std::string &fieldName); + void setField(const std::string &fieldName, std::any value); }; memory_Context memory_createContext();