diff options
author | zaaarf <80046572+zaaarf@users.noreply.github.com> | 2024-01-07 23:51:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-07 23:51:06 +0100 |
commit | 79b8b73304753fedab822e6aa859fa15673f52cc (patch) | |
tree | cb25cfb89f8b06fc34f5c906e658a1b322120089 /src/openvic-simulation/dataloader/NodeTools.hpp | |
parent | 400469f08f10ffd044d9948c3f0db340c8a60db0 (diff) | |
parent | 6f07de81a6ca430c522527958e05440d67b04937 (diff) |
Merge pull request #111 from OpenVicProject/conditions-checking
Condition definition checking/loading
Diffstat (limited to 'src/openvic-simulation/dataloader/NodeTools.hpp')
-rw-r--r-- | src/openvic-simulation/dataloader/NodeTools.hpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/openvic-simulation/dataloader/NodeTools.hpp b/src/openvic-simulation/dataloader/NodeTools.hpp index 8ad731b..00ba02d 100644 --- a/src/openvic-simulation/dataloader/NodeTools.hpp +++ b/src/openvic-simulation/dataloader/NodeTools.hpp @@ -21,9 +21,12 @@ namespace OpenVic { * searched for without needing to be copied into a string */ template<typename T, class Hash = container_hash<std::string>, class KeyEqual = std::equal_to<>> using string_map_t = ordered_map<std::string, T, Hash, KeyEqual>; + template<typename T> + using case_insensitive_string_map_t = string_map_t<T, case_insensitive_string_hash, case_insensitive_string_equal>; /* String set type supporting heterogeneous key lookup */ using string_set_t = ordered_set<std::string>; + using case_insensitive_string_set_t = case_insensitive_ordered_set<std::string>; namespace NodeTools { @@ -247,10 +250,12 @@ namespace OpenVic { node_callback_t name_list_callback(callback_t<std::vector<std::string>&&> callback); - template<typename T> - Callback<std::string_view> auto expect_mapped_string(string_map_t<T> const& map, Callback<T> auto callback) { + template<typename T, class Hash, class KeyEqual> + Callback<std::string_view> auto expect_mapped_string( + string_map_t<T, Hash, KeyEqual> const& map, Callback<T> auto callback + ) { return [&map, callback](std::string_view string) -> bool { - const typename string_map_t<T>::const_iterator it = map.find(string); + const typename string_map_t<T, Hash, KeyEqual>::const_iterator it = map.find(string); if (it != map.end()) { return callback(it->second); } |