diff options
author | Hop311 <Hop3114@gmail.com> | 2023-11-13 13:42:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-13 13:42:37 +0100 |
commit | f572664cbe1aa5ec2cb6907de3083f058c20af7e (patch) | |
tree | c9a61c5dd15fb1eae1555f47119423dbba315e76 /src/openvic-simulation/dataloader/NodeTools.cpp | |
parent | ba7bfc52803781c970d6e8afc84c7d3d3e843726 (diff) | |
parent | ce84886cb931975f622134d6c8d32a69c675d975 (diff) |
Merge pull request #71 from OpenVicProject/gui-loading
GUI and GFX file loading
Diffstat (limited to 'src/openvic-simulation/dataloader/NodeTools.cpp')
-rw-r--r-- | src/openvic-simulation/dataloader/NodeTools.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/openvic-simulation/dataloader/NodeTools.cpp b/src/openvic-simulation/dataloader/NodeTools.cpp index 27d0f95..c412f33 100644 --- a/src/openvic-simulation/dataloader/NodeTools.cpp +++ b/src/openvic-simulation/dataloader/NodeTools.cpp @@ -76,10 +76,10 @@ node_callback_t NodeTools::expect_int_bool(callback_t<bool> callback) { return expect_identifier(expect_mapped_string(bool_map, callback)); } -node_callback_t NodeTools::expect_int64(callback_t<int64_t> callback) { - return expect_identifier([callback](std::string_view identifier) -> bool { +node_callback_t NodeTools::expect_int64(callback_t<int64_t> callback, int base) { + return expect_identifier([callback, base](std::string_view identifier) -> bool { bool successful = false; - const int64_t val = StringUtils::string_to_int64(identifier, &successful, 10); + const int64_t val = StringUtils::string_to_int64(identifier, &successful, base); if (successful) { return callback(val); } @@ -88,10 +88,10 @@ node_callback_t NodeTools::expect_int64(callback_t<int64_t> callback) { }); } -node_callback_t NodeTools::expect_uint64(callback_t<uint64_t> callback) { - return expect_identifier([callback](std::string_view identifier) -> bool { +node_callback_t NodeTools::expect_uint64(callback_t<uint64_t> callback, int base) { + return expect_identifier([callback, base](std::string_view identifier) -> bool { bool successful = false; - const uint64_t val = StringUtils::string_to_uint64(identifier, &successful, 10); + const uint64_t val = StringUtils::string_to_uint64(identifier, &successful, base); if (successful) { return callback(val); } @@ -141,6 +141,10 @@ node_callback_t NodeTools::expect_colour(callback_t<colour_t> callback) { }; } +node_callback_t NodeTools::expect_colour_hex(callback_t<colour_t> callback) { + return expect_uint(callback, 16); +} + callback_t<std::string_view> NodeTools::expect_date_str(callback_t<Date> callback) { return [callback](std::string_view identifier) -> bool { bool successful = false; @@ -188,8 +192,12 @@ NodeCallback auto _expect_vec2(Callback<vec2_t<T>> auto callback) { }; } +static node_callback_t _expect_int(callback_t<ivec2_t::type> callback) { + return expect_int(callback); +} + node_callback_t NodeTools::expect_ivec2(callback_t<ivec2_t> callback) { - return _expect_vec2<int32_t, expect_int>(callback); + return _expect_vec2<ivec2_t::type, _expect_int>(callback); } node_callback_t NodeTools::expect_fvec2(callback_t<fvec2_t> callback) { |