From f19c9fbbb8983371ebf79affadfcc45c44a28a43 Mon Sep 17 00:00:00 2001 From: Hop311 Date: Tue, 26 Sep 2023 15:19:27 +0100 Subject: Expect modifier value + keys function --- src/openvic-simulation/dataloader/NodeTools.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/openvic-simulation/dataloader/NodeTools.hpp') diff --git a/src/openvic-simulation/dataloader/NodeTools.hpp b/src/openvic-simulation/dataloader/NodeTools.hpp index e49cab6..2dae05c 100644 --- a/src/openvic-simulation/dataloader/NodeTools.hpp +++ b/src/openvic-simulation/dataloader/NodeTools.hpp @@ -72,6 +72,10 @@ namespace OpenVic { using enum dictionary_entry_t::expected_count_t; using key_map_t = std::map>; + void add_key_map_entry(key_map_t& key_map, const std::string_view key, dictionary_entry_t::expected_count_t expected_count, node_callback_t callback); + key_value_callback_t dictionary_keys_callback(key_map_t& key_map, bool allow_other_keys); + bool check_key_map_counts(key_map_t const& key_map); + constexpr struct allow_other_keys_t {} ALLOW_OTHER_KEYS; node_callback_t _expect_dictionary_keys_and_length(length_callback_t length_callback, bool allow_other_keys, key_map_t&& key_map); @@ -81,11 +85,7 @@ namespace OpenVic { bool allow_other_keys, key_map_t&& key_map, const std::string_view key, dictionary_entry_t::expected_count_t expected_count, node_callback_t callback, Args... args) { - if (key_map.find(key) == key_map.end()) { - key_map.emplace(key, dictionary_entry_t { expected_count, callback }); - } else { - Logger::error("Duplicate expected dictionary key: ", key); - } + add_key_map_entry(key_map, key, expected_count, callback); return _expect_dictionary_keys_and_length(length_callback, allow_other_keys, std::move(key_map), args...); } -- cgit v1.2.3-56-ga3b1