#include <Parser.h>
|
| virtual std::string | eval (hit::Field *n, const std::list< std::string > &args, hit::BraceExpander &exp) |
| |
Definition at line 36 of file Parser.h.
◆ eval()
| std::string EnumerateEvaler::eval |
( |
hit::Field * |
n, |
|
|
const std::list< std::string > & |
args, |
|
|
hit::BraceExpander & |
exp |
|
) |
| |
|
virtual |
Definition at line 144 of file Parser.C.
146 std::vector<std::string> argv;
147 argv.insert(argv.begin(), args.begin(), args.end());
149 if (argv.size() != 3)
151 exp.errors.emplace_back(
152 "enumerate error: Expected 3 arguments ${enumerate prefix first_index last_index} in '" +
158 const auto & prefix = argv[0];
159 std::array<int, 2> index;
162 const auto & arg = argv[i + 1];
163 if (arg.empty() || arg.find_first_not_of(
"0123456789") != std::string::npos)
165 exp.errors.emplace_back(
"enumerate error: index '" + arg +
166 "' is not a non-negative integer in '" + n->fullpath() +
"'",
170 index[i] = MooseUtils::convert<int>(arg);
173 if (index[1] < index[0])
175 exp.errors.emplace_back(
"enumerate error: last index " + argv[2] +
176 " is smaller than first index " + argv[1] +
" in '" +
182 std::vector<std::string> names;
183 for (
const auto i :
make_range(index[0], index[1] + 1))
184 names.push_back(prefix + std::to_string(i));
IntRange< T > make_range(T beg, T end)
std::string stringJoin(const std::vector< std::string > &values, const std::string &separator=" ")
Concatenates value into a single string separated by separator.
The documentation for this class was generated from the following files: