From 6edb54dc3f308c1e9b2ccb7bed21facb129ab963 Mon Sep 17 00:00:00 2001 From: Hop311 Date: Sat, 23 Sep 2023 00:35:21 +0100 Subject: Various fixes, refactors and general cleanup --- src/openvic-simulation/dataloader/NodeTools.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/openvic-simulation/dataloader/NodeTools.cpp') diff --git a/src/openvic-simulation/dataloader/NodeTools.cpp b/src/openvic-simulation/dataloader/NodeTools.cpp index 7dd6e16..2367f86 100644 --- a/src/openvic-simulation/dataloader/NodeTools.cpp +++ b/src/openvic-simulation/dataloader/NodeTools.cpp @@ -220,6 +220,20 @@ node_callback_t NodeTools::expect_list(node_callback_t callback) { return expect_list_and_length(default_length_callback, callback); } +node_callback_t NodeTools::expect_length(callback_t callback) { + return [callback](ast::NodeCPtr node) -> bool { + bool ret = true; + ret &= expect_list_and_length( + [callback, &ret](size_t size) -> size_t { + ret &= callback(size); + return 0; + }, + success_callback + )(node); + return ret; + }; +} + node_callback_t NodeTools::expect_dictionary_and_length(length_callback_t length_callback, key_value_callback_t callback) { return expect_list_and_length(length_callback, expect_assign(callback)); } -- cgit v1.2.3-56-ga3b1