aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/dataloader/NodeTools.hpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2023-10-28 11:39:08 +0200
committer hop311 <hop3114@gmail.com>2023-10-29 20:42:47 +0100
commit164264b047921dbe1567d2af183e1cffb200a8cb (patch)
tree21c3c81f65ac3259db4808ebe9fd32a94ca993af /src/openvic-simulation/dataloader/NodeTools.hpp
parentd8ec90f07342876e9331819bd3cc372050f78248 (diff)
Astyle formatting (with manual cleanup)
Diffstat (limited to 'src/openvic-simulation/dataloader/NodeTools.hpp')
-rw-r--r--src/openvic-simulation/dataloader/NodeTools.hpp50
1 files changed, 36 insertions, 14 deletions
diff --git a/src/openvic-simulation/dataloader/NodeTools.hpp b/src/openvic-simulation/dataloader/NodeTools.hpp
index 6469100..7ad5412 100644
--- a/src/openvic-simulation/dataloader/NodeTools.hpp
+++ b/src/openvic-simulation/dataloader/NodeTools.hpp
@@ -27,13 +27,19 @@ namespace OpenVic {
namespace NodeTools {
template<typename Fn, typename Return = void, typename... Args>
- concept Functor = requires(Fn&& fn, Args&&... args) {
- { std::invoke(std::forward<Fn>(fn), std::forward<Args>(args)...) } -> std::same_as<Return>;
+ concept Functor = requires(Fn&& fn, Args&& ... args) {
+ {
+ std::invoke(std::forward<Fn>(fn), std::forward<Args>(args)...)
+ }
+ -> std::same_as<Return>;
};
template<typename Fn, typename Return = void, typename... Args>
- concept FunctorConvertible = requires(Fn&& fn, Args&&... args) {
- { std::invoke(std::forward<Fn>(fn), std::forward<Args>(args)...) } -> std::convertible_to<Return>;
+ concept FunctorConvertible = requires(Fn&& fn, Args&& ... args) {
+ {
+ std::invoke(std::forward<Fn>(fn), std::forward<Args>(args)...)
+ }
+ -> std::convertible_to<Return>;
};
template<typename Fn, typename... Args>
@@ -52,10 +58,14 @@ namespace OpenVic {
using callback_t = std::function<bool(Args...)>;
using node_callback_t = callback_t<ast::NodeCPtr>;
- constexpr bool success_callback(ast::NodeCPtr) { return true; }
+ constexpr bool success_callback(ast::NodeCPtr) {
+ return true;
+ }
using key_value_callback_t = callback_t<std::string_view, ast::NodeCPtr>;
- constexpr bool key_value_success_callback(std::string_view, ast::NodeCPtr) { return true; }
+ constexpr bool key_value_success_callback(std::string_view, ast::NodeCPtr) {
+ return true;
+ }
inline bool key_value_invalid_callback(std::string_view key, ast::NodeCPtr) {
Logger::error("Invalid dictionary key: ", key);
return false;
@@ -109,7 +119,9 @@ namespace OpenVic {
node_callback_t expect_assign(key_value_callback_t callback);
using length_callback_t = std::function<size_t(size_t)>;
- constexpr size_t default_length_callback(size_t size) { return size; };
+ constexpr size_t default_length_callback(size_t size) {
+ return size;
+ };
node_callback_t expect_list_and_length(length_callback_t length_callback, node_callback_t callback);
node_callback_t expect_list_of_length(size_t length, node_callback_t callback);
@@ -147,33 +159,40 @@ namespace OpenVic {
using enum dictionary_entry_t::expected_count_t;
using key_map_t = string_map_t<dictionary_entry_t>;
- bool add_key_map_entry(key_map_t& key_map, std::string_view key, dictionary_entry_t::expected_count_t expected_count, node_callback_t callback);
+ bool add_key_map_entry(key_map_t& key_map, std::string_view key,
+ dictionary_entry_t::expected_count_t expected_count, node_callback_t callback);
bool remove_key_map_entry(key_map_t& key_map, std::string_view key);
key_value_callback_t dictionary_keys_callback(key_map_t& key_map, key_value_callback_t default_callback);
bool check_key_map_counts(key_map_t& key_map);
- constexpr bool add_key_map_entries(key_map_t& key_map) { return true; }
+ constexpr bool add_key_map_entries(key_map_t& key_map) {
+ return true;
+ }
template<typename... Args>
- bool add_key_map_entries(key_map_t& key_map, std::string_view key, dictionary_entry_t::expected_count_t expected_count, NodeCallback auto callback, Args... args) {
+ bool add_key_map_entries(key_map_t& key_map, std::string_view key,
+ dictionary_entry_t::expected_count_t expected_count, NodeCallback auto callback, Args... args) {
bool ret = add_key_map_entry(key_map, key, expected_count, callback);
ret &= add_key_map_entries(key_map, args...);
return ret;
}
- node_callback_t expect_dictionary_key_map_and_length_and_default(key_map_t key_map, length_callback_t length_callback, key_value_callback_t default_callback);
+ node_callback_t expect_dictionary_key_map_and_length_and_default(key_map_t key_map,
+ length_callback_t length_callback, key_value_callback_t default_callback);
node_callback_t expect_dictionary_key_map_and_length(key_map_t key_map, length_callback_t length_callback);
node_callback_t expect_dictionary_key_map_and_default(key_map_t key_map, key_value_callback_t default_callback);
node_callback_t expect_dictionary_key_map(key_map_t key_map);
template<typename... Args>
- NodeCallback auto expect_dictionary_key_map_and_length_and_default(key_map_t key_map, length_callback_t length_callback, key_value_callback_t default_callback, Args... args) {
+ NodeCallback auto expect_dictionary_key_map_and_length_and_default(key_map_t key_map,
+ length_callback_t length_callback, key_value_callback_t default_callback, Args... args) {
// TODO - pass return value back up (part of big key_map_t rewrite?)
add_key_map_entries(key_map, args...);
return expect_dictionary_key_map_and_length_and_default(std::move(key_map), length_callback, default_callback);
}
template<typename... Args>
- NodeCallback auto expect_dictionary_keys_and_length_and_default(LengthCallback auto length_callback, KeyValueCallback auto default_callback, Args... args) {
+ NodeCallback auto expect_dictionary_keys_and_length_and_default(LengthCallback auto length_callback,
+ KeyValueCallback auto default_callback, Args... args) {
return expect_dictionary_key_map_and_length_and_default({}, length_callback, default_callback, args...);
}
@@ -194,7 +213,10 @@ namespace OpenVic {
template<typename T>
concept Reservable = requires(T& t) {
- { t.size() } -> std::same_as<size_t>;
+ {
+ t.size()
+ }
+ -> std::same_as<size_t>;
t.reserve(size_t {});
};
template<Reservable T>