diff options
author | Hop311 <Hop3114@gmail.com> | 2023-09-26 18:15:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-26 18:15:43 +0200 |
commit | ca3996510ed6e26a81c781992d33c335ca250a16 (patch) | |
tree | e456ce0a8355ae2936d78a99b6c77ef785a8e5d5 /src/openvic-simulation/dataloader/NodeTools.hpp | |
parent | 63e462fceff981f79bcbae53e8d90fc59733e8c2 (diff) | |
parent | 1c7b3239ab4e9f75d0605e5da852daf5afaa8c4a (diff) |
Merge pull request #35 from OpenVicProject/expect-modifier-keys
Expect modifier value + keys function
Diffstat (limited to 'src/openvic-simulation/dataloader/NodeTools.hpp')
-rw-r--r-- | src/openvic-simulation/dataloader/NodeTools.hpp | 10 |
1 files changed, 5 insertions, 5 deletions
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<std::string, dictionary_entry_t, std::less<void>>; + 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...); } |