aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/dataloader/NodeTools.cpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-10-15 16:26:39 +0200
committer GitHub <noreply@github.com>2023-10-15 16:26:39 +0200
commit3249e21104bab6002676abe00450e7bd3f682303 (patch)
treec2a13a44d4c8553f6e87193f5f437052cf1d7067 /src/openvic-simulation/dataloader/NodeTools.cpp
parent17847e16e14ec52eb48a6fd0d9dc36ee93e457db (diff)
parentd26f9c2fb5a9666822a0f702d76b764600a390d7 (diff)
Merge pull request #52 from OpenVicProject/tgc-compat
TGC compatibility fixes + other cleanup
Diffstat (limited to 'src/openvic-simulation/dataloader/NodeTools.cpp')
-rw-r--r--src/openvic-simulation/dataloader/NodeTools.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/openvic-simulation/dataloader/NodeTools.cpp b/src/openvic-simulation/dataloader/NodeTools.cpp
index 391ffb6..c2edb18 100644
--- a/src/openvic-simulation/dataloader/NodeTools.cpp
+++ b/src/openvic-simulation/dataloader/NodeTools.cpp
@@ -360,20 +360,25 @@ node_callback_t NodeTools::expect_dictionary_key_map(key_map_t key_map) {
return expect_dictionary_key_map_and_length_and_default(std::move(key_map), default_length_callback, key_value_invalid_callback);
}
-node_callback_t NodeTools::name_list_callback(std::vector<std::string>& list) {
- return expect_list_reserve_length(
- list,
- expect_identifier_or_string(
- [&list](std::string_view str) -> bool {
- if (!str.empty()) {
- list.push_back(std::string { str });
- return true;
+node_callback_t NodeTools::name_list_callback(callback_t<std::vector<std::string>&&> callback) {
+ return [callback](ast::NodeCPtr node) -> bool {
+ std::vector<std::string> list;
+ bool ret = expect_list_reserve_length(
+ list,
+ expect_identifier_or_string(
+ [&list](std::string_view str) -> bool {
+ if (!str.empty()) {
+ list.push_back(std::string { str });
+ return true;
+ }
+ Logger::error("Empty identifier or string");
+ return false;
}
- Logger::error("Empty identifier or string");
- return false;
- }
- )
- );
+ )
+ )(node);
+ ret &= callback(std::move(list));
+ return ret;
+ };
}
callback_t<std::string_view> NodeTools::assign_variable_callback_string(std::string& var) {