This adds an `into()` operator to the Node class modeled off the `get_to()` operator in the popular nlohmann::json library. (See: https://github.com/nlohmann/json#basic-usage) This operator assigns a casted value to an existing variable if that node has a defined value, and otherwise leaves the variable unchanged. It returns `true` if the variable was overwritten and `false` if the variable was unchanged. This operator is extremely useful in applications where YAML is being used as a configuration source that overrides default values coming from another source, e.g.: ```c++ struct MyConfig { int foo = 4; double bar = 5.0; std::string baz = "six"; }; MyConfig config; node["foo"].into(config.foo); node["bar"].into(config.bar); if (!node["baz"].into(config.baz)) std::cerr << "Using default value for .baz!" << std::endl; ``` |
||
|---|---|---|
| .. | ||
| gtest-1.10.0 | ||
| integration | ||
| node | ||
| binary_test.cpp | ||
| BUILD.bazel | ||
| CMakeLists.txt | ||
| create-emitter-tests.py | ||
| handler_test.h | ||
| main.cpp | ||
| mock_event_handler.h | ||
| ostream_wrapper_test.cpp | ||
| parser_test.cpp | ||
| regex_test.cpp | ||
| specexamples.h | ||