aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/dataloader/NodeTools.cpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-01-08 23:19:39 +0100
committer hop311 <hop3114@gmail.com>2024-01-08 23:19:39 +0100
commit83802dfead4938e6f98b4b9961b286e06ab78b18 (patch)
treeb0b404a1826d455767b16d3e3ae1d6bf7516e06d /src/openvic-simulation/dataloader/NodeTools.cpp
parent79b8b73304753fedab822e6aa859fa15673f52cc (diff)
Added map_callback and expect_item_dictionary_reserve_length
Diffstat (limited to 'src/openvic-simulation/dataloader/NodeTools.cpp')
-rw-r--r--src/openvic-simulation/dataloader/NodeTools.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/openvic-simulation/dataloader/NodeTools.cpp b/src/openvic-simulation/dataloader/NodeTools.cpp
index 4612f77..957aa01 100644
--- a/src/openvic-simulation/dataloader/NodeTools.cpp
+++ b/src/openvic-simulation/dataloader/NodeTools.cpp
@@ -400,9 +400,9 @@ node_callback_t NodeTools::expect_dictionary_key_map(key_map_t key_map) {
);
}
-node_callback_t NodeTools::name_list_callback(callback_t<std::vector<std::string>&&> callback) {
+node_callback_t NodeTools::name_list_callback(callback_t<name_list_t&&> callback) {
return [callback](ast::NodeCPtr node) -> bool {
- std::vector<std::string> list;
+ name_list_t list;
bool ret = expect_list_reserve_length(
list, expect_identifier_or_string(vector_callback<std::string_view>(list))
)(node);
@@ -411,6 +411,17 @@ node_callback_t NodeTools::name_list_callback(callback_t<std::vector<std::string
};
}
+std::ostream& OpenVic::operator<<(std::ostream& stream, name_list_t const& name_list) {
+ stream << '[';
+ if (!name_list.empty()) {
+ stream << name_list.front();
+ std::for_each(name_list.begin() + 1, name_list.end(), [&stream](std::string const& name) -> void {
+ stream << ", " << name;
+ });
+ }
+ return stream << ']';
+}
+
callback_t<std::string_view> NodeTools::assign_variable_callback_string(std::string& var) {
return assign_variable_callback_cast<std::string_view>(var);
}