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.cpp | |
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.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) { |