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.cpp | |
parent | b06b25bd2910818029ebbf1cd3014ef20a64e25b (diff) |
feat: condition loading and parsing
Co-authored-by: Hop311 <Hop3114@gmail.com>
Diffstat (limited to 'src/openvic-simulation/dataloader/NodeTools.cpp')
-rw-r--r-- | src/openvic-simulation/dataloader/NodeTools.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/openvic-simulation/dataloader/NodeTools.cpp b/src/openvic-simulation/dataloader/NodeTools.cpp index e429ed9..4612f77 100644 --- a/src/openvic-simulation/dataloader/NodeTools.cpp +++ b/src/openvic-simulation/dataloader/NodeTools.cpp @@ -70,13 +70,17 @@ node_callback_t NodeTools::expect_identifier_or_string(callback_t<std::string_vi } node_callback_t NodeTools::expect_bool(callback_t<bool> callback) { - static const string_map_t<bool> bool_map = { { "yes", true }, { "no", false } }; + static const case_insensitive_string_map_t<bool> bool_map = { { "yes", true }, { "no", false } }; return expect_identifier(expect_mapped_string(bool_map, callback)); } node_callback_t NodeTools::expect_int_bool(callback_t<bool> callback) { - static const string_map_t<bool> bool_map = { { "1", true }, { "0", false } }; - return expect_identifier(expect_mapped_string(bool_map, callback)); + return expect_uint64([callback](uint64_t num) -> bool { + if (num > 1) { + Logger::warning("Found int bool with value >1: ", num); + } + return callback(num != 0); + }); } node_callback_t NodeTools::expect_int64(callback_t<int64_t> callback, int base) { |