nested allows serialization of maps with vectors inside, and vice-versa all from a nested structure of Lua tables it has less control over which pieces are considered tables in Lua, and which ones are considered userdata, but it covers a good 90% of cases where someone wants to handle a nested table
| 12 | // and which ones are considered userdata, but it covers a good |
| 13 | // 90% of cases where someone wants to handle a nested table |
| 14 | void demo( |
| 15 | sol::nested<std::map<std::string, std::vector<std::string>>> |
| 16 | src) { |
| 17 | std::cout << "demo, sol::nested<...>" << std::endl; |
| 18 | const auto& listmap = src.value(); |
| 19 | SOL_ASSERT(listmap.size() == 2); |
| 20 | for (const auto& kvp : listmap) { |
| 21 | const std::vector<std::string>& strings = kvp.second; |
| 22 | SOL_ASSERT(strings.size() == 3); |
| 23 | std::cout << "\t" << kvp.first << " = "; |
| 24 | for (const auto& s : strings) { |
| 25 | std::cout << "'" << s << "'" |
| 26 | << " "; |
| 27 | } |
| 28 | std::cout << std::endl; |
| 29 | } |
| 30 | std::cout << std::endl; |
| 31 | } |
| 32 | |
| 33 | // This second demo is equivalent to the first |
| 34 | // Nota bene the signature here |