From 7f9a9a8241ba81be9213e6606b8be4a48f1cbaab Mon Sep 17 00:00:00 2001 From: Hop311 Date: Fri, 8 Sep 2023 00:34:47 +0100 Subject: Remove return_t, use & instead of if(x != SUCCESS) --- src/openvic/dataloader/NodeTools.hpp | 47 ++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 24 deletions(-) (limited to 'src/openvic/dataloader/NodeTools.hpp') diff --git a/src/openvic/dataloader/NodeTools.hpp b/src/openvic/dataloader/NodeTools.hpp index 6dbaa1c..daea8ce 100644 --- a/src/openvic/dataloader/NodeTools.hpp +++ b/src/openvic/dataloader/NodeTools.hpp @@ -4,7 +4,6 @@ #include "openvic/types/Colour.hpp" #include "openvic/types/Date.hpp" -#include "openvic/types/Return.hpp" #include "openvic/types/fixed_point/FP.hpp" #include @@ -14,20 +13,20 @@ namespace OpenVic { namespace NodeTools { - using node_callback_t = std::function; - constexpr return_t success_callback(ast::NodeCPtr) { return SUCCESS; } + using node_callback_t = std::function; + constexpr bool success_callback(ast::NodeCPtr) { return true; } - using key_value_callback_t = std::function; + using key_value_callback_t = std::function; - node_callback_t expect_identifier(std::function callback); - node_callback_t expect_string(std::function callback); - node_callback_t expect_identifier_or_string(std::function callback); - node_callback_t expect_bool(std::function callback); - node_callback_t expect_int(std::function callback); - node_callback_t expect_uint(std::function callback); - node_callback_t expect_fixed_point(std::function callback); - node_callback_t expect_colour(std::function callback); - node_callback_t expect_date(std::function callback); + node_callback_t expect_identifier(std::function callback); + node_callback_t expect_string(std::function callback); + node_callback_t expect_identifier_or_string(std::function callback); + node_callback_t expect_bool(std::function callback); + node_callback_t expect_int(std::function callback); + node_callback_t expect_uint(std::function callback); + node_callback_t expect_fixed_point(std::function callback); + node_callback_t expect_colour(std::function callback); + node_callback_t expect_date(std::function callback); node_callback_t expect_assign(key_value_callback_t callback); using length_callback_t = std::function; @@ -124,38 +123,38 @@ namespace OpenVic { node_callback_t name_list_callback(std::vector& list); template - std::function assign_variable_callback(T& var) { - return [&var](T val) -> return_t { + std::function assign_variable_callback(T& var) { + return [&var](T val) -> bool { var = val; - return SUCCESS; + return true; }; } template requires(std::integral) - std::function assign_variable_callback_uint(const std::string_view name, T& var) { - return [&var, name](uint64_t val) -> return_t { + std::function assign_variable_callback_uint(const std::string_view name, T& var) { + return [&var, name](uint64_t val) -> bool { if (val <= std::numeric_limits::max()) { var = val; - return SUCCESS; + return true; } Logger::error("Invalid ", name, ": ", val, " (valid range: [0, ", static_cast(std::numeric_limits::max()), "])"); - return FAILURE; + return false; }; } template requires(std::integral) - std::function assign_variable_callback_int(const std::string_view name, T& var) { - return [&var, name](int64_t val) -> return_t { + std::function assign_variable_callback_int(const std::string_view name, T& var) { + return [&var, name](int64_t val) -> bool { if (std::numeric_limits::lowest() <= val && val <= std::numeric_limits::max()) { var = val; - return SUCCESS; + return true; } Logger::error("Invalid ", name, ": ", val, " (valid range: [", static_cast(std::numeric_limits::lowest()), ", ", static_cast(std::numeric_limits::max()), "])"); - return FAILURE; + return false; }; } } -- cgit v1.2.3-56-ga3b1