aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/dataloader/NodeTools.cpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2023-11-07 23:18:08 +0100
committer hop311 <hop3114@gmail.com>2023-11-12 17:55:39 +0100
commitfd686eadf81e85bd4993a483adcefd6a153d259f (patch)
treee59e8a1531d96a37872373f6262eff8ed45da1ff /src/openvic-simulation/dataloader/NodeTools.cpp
parentc8983f5cda0b396b76c9d1491cf4c8ff5997d420 (diff)
GUI and GFX file loading
Diffstat (limited to 'src/openvic-simulation/dataloader/NodeTools.cpp')
-rw-r--r--src/openvic-simulation/dataloader/NodeTools.cpp22
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) {