From c467671ae8b6ec161c17e86f3383fd0625f755b8 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Fri, 19 Aug 2022 19:48:10 -0400 Subject: remove sol2 (will re-add as submodule) --- lib/sol2/examples/source/tables.cpp | 65 ------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 lib/sol2/examples/source/tables.cpp (limited to 'lib/sol2/examples/source/tables.cpp') diff --git a/lib/sol2/examples/source/tables.cpp b/lib/sol2/examples/source/tables.cpp deleted file mode 100644 index 5aab030..0000000 --- a/lib/sol2/examples/source/tables.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#define SOL_ALL_SAFETIES_ON 1 -#include - -#include -#include - -// this example shows how to read data in from a lua table - -int main() { - std::cout << "=== tables ===" << std::endl; - - sol::state lua; - // table used as an array - lua.script(R"(table1 = {"hello", "table"})"); - // table with a nested table and the key value syntax - lua.script(R"( - table2 = { - ["nestedTable"] = { - ["key1"] = "value1", - ["key2"]= "value2", - }, - ["name"] = "table2", - } - )"); - - - /* Shorter Syntax: */ - // using the values stored in table1 - /*std::cout << (std::string)lua["table1"][1] << " " - << (std::string)lua["table1"][2] << '\n'; - */ - // some retrieval of values from the nested table - // the cleaner way of doing things - // chain off the the get<>() / [] results - auto t2 = lua.get("table2"); - auto nestedTable = t2.get("nestedTable"); - // Alternatively: - //sol::table t2 = lua["table2"]; - //sol::table nestedTable = t2["nestedTable"]; - - std::string x = lua["table2"]["nestedTable"]["key2"]; - std::cout << "nested table: key1 : " << nestedTable.get("key1") << ", key2: " - << x - << '\n'; - std::cout << "name of t2: " << t2.get("name") << '\n'; - std::string t2name = t2["name"]; - std::cout << "name of t2: " << t2name << '\n'; - - /* Longer Syntax: */ - // using the values stored in table1 - std::cout << lua.get("table1").get(1) << " " - << lua.get("table1").get(2) << '\n'; - - // some retrieval of values from the nested table - // the cleaner way of doing things - std::cout << "nested table: key1 : " << nestedTable.get("key1") << ", key2: " - // yes you can chain the get<>() results - << lua.get("table2").get("nestedTable").get("key2") - << '\n'; - std::cout << "name of t2: " << t2.get("name") << '\n'; - - std::cout << std::endl; - - return 0; -} -- cgit v1.2.3