From efa88c722fcb6c8fea7a86e1b3b8a83f1f59eb31 Mon Sep 17 00:00:00 2001 From: Hop311 Date: Thu, 24 Aug 2023 00:32:23 +0100 Subject: Big Dataloader Commit (openvic-simulation) --- src/openvic/dataloader/NodeTools.hpp | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/openvic/dataloader/NodeTools.hpp (limited to 'src/openvic/dataloader/NodeTools.hpp') diff --git a/src/openvic/dataloader/NodeTools.hpp b/src/openvic/dataloader/NodeTools.hpp new file mode 100644 index 0000000..ca7130c --- /dev/null +++ b/src/openvic/dataloader/NodeTools.hpp @@ -0,0 +1,42 @@ +#pragma once + +#include + +#include + +#include "openvic/types/Colour.hpp" +#include "openvic/types/Return.hpp" +#include "openvic/types/Date.hpp" +#include "openvic/types/fixed_point/FP.hpp" + +namespace OpenVic { + namespace ast = ovdl::v2script::ast; + + namespace NodeTools { + + template + return_t expect_type(ast::NodeCPtr node, std::function callback); + + return_t expect_identifier(ast::NodeCPtr node, std::function callback); + return_t expect_string(ast::NodeCPtr node, std::function callback); + return_t expect_identifier_or_string(ast::NodeCPtr node, std::function callback); + return_t expect_bool(ast::NodeCPtr node, std::function callback); + return_t expect_int(ast::NodeCPtr node, std::function callback); + return_t expect_uint(ast::NodeCPtr node, std::function callback); + return_t expect_fixed_point(ast::NodeCPtr node, std::function callback); + return_t expect_colour(ast::NodeCPtr node, std::function callback); + return_t expect_date(ast::NodeCPtr node, std::function callback); + return_t expect_assign(ast::NodeCPtr node, std::function callback); + return_t expect_list(ast::NodeCPtr node, std::function callback, size_t length = 0, bool file_node = false); + return_t expect_dictionary(ast::NodeCPtr node, std::function callback, bool file_node = false); + + static const std::function success_callback = [](ast::NodeCPtr) -> return_t { return SUCCESS; }; + + struct dictionary_entry_t { + bool must_appear, can_repeat; + std::function callback; + }; + using dictionary_key_map_t = std::map>; + return_t expect_dictionary_keys(ast::NodeCPtr node, dictionary_key_map_t const& keys, bool allow_other_keys = false, bool file_node = false); + } +} -- cgit v1.2.3-56-ga3b1