diff options
author | zaaarf <me@zaaarf.foo> | 2024-01-07 23:47:39 +0100 |
---|---|---|
committer | zaaarf <me@zaaarf.foo> | 2024-01-07 23:47:39 +0100 |
commit | 6f07de81a6ca430c522527958e05440d67b04937 (patch) | |
tree | 6aae2959564bf93d85b2dc985cf5d4ea6c03fb78 /src/openvic-simulation/dataloader/NodeTools.hpp | |
parent | b06b25bd2910818029ebbf1cd3014ef20a64e25b (diff) |
feat: condition loading and parsing
Co-authored-by: Hop311 <Hop3114@gmail.com>
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); } |