R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandCommonFunc.h
Go to the documentation of this file.
1#pragma once
2
3#include <R3BException.h>
4#include <algorithm>
5#include <boost/algorithm/string/classification.hpp>
6#include <boost/algorithm/string/split.hpp>
7#include <boost/algorithm/string/trim.hpp>
8#include <fmt/format.h>
9#include <string>
10#include <vector>
11
12namespace R3B::Neuland
13{
14 template <typename Option>
15 void parse_io_branch_names(const Option& option,
16 std::vector<std::string>& read,
17 int read_num,
18 std::vector<std::string>& write,
19 int write_num)
20 {
21 auto resolve_branch_names = [](const std::string& input, std::vector<std::string>& output)
22 {
23 output.clear();
24 boost::split(output, input, boost::is_any_of(";"));
25 // trim the empty spaces
26 std::for_each(output.begin(), output.end(), [](auto& name) { boost::trim(name); });
27 // remove empty names
28 output.erase(std::remove(output.begin(), output.end(), ""), output.end());
29 };
30
31 resolve_branch_names(option.read, read);
32 if (read.size() != read_num)
33 {
34 throw R3B::logic_error(fmt::format(
35 "Task {:?} requires {} read branch(es) but only received {} branch(es)! Parsed string: {:?}",
36 option.name,
37 read_num,
38 read.size(),
39 option.read));
40 }
41 resolve_branch_names(option.write, write);
42 if (write.size() != write_num)
43 {
44 throw R3B::logic_error(fmt::format(
45 "Task {:?} requires {} write branch(es) but only received {} branch(es)! Parsed string: {:?}",
46 option.name,
47 read_num,
48 write.size(),
49 option.write));
50 }
51 }
52} // namespace R3B::Neuland
Simulation of NeuLAND Bar/Paddle.
void parse_io_branch_names(const Option &option, std::vector< std::string > &read, int read_num, std::vector< std::string > &write, int write_num)