| 1366 | } |
| 1367 | |
| 1368 | Expression make_join(const std::string &function_name, const std::vector<Expression> &args) { |
| 1369 | if (args.size() != 2) { |
| 1370 | std::stringstream message_ss; |
| 1371 | message_ss << "Expression language function " << function_name << " called with " << args.size() << " argument(s), but " << 2 << " are required"; |
| 1372 | throw std::runtime_error(message_ss.str()); |
| 1373 | } |
| 1374 | |
| 1375 | if (!args[0].is_multi()) { |
| 1376 | std::stringstream message_ss; |
| 1377 | message_ss << "Expression language function " << function_name << " called against singular expression."; |
| 1378 | throw std::runtime_error(message_ss.str()); |
| 1379 | } |
| 1380 | |
| 1381 | auto delim_expr = args[1]; |
| 1382 | |
| 1383 | return args[0].make_aggregate([delim_expr](const Parameters ¶ms, |
| 1384 | const std::vector<Expression> &sub_exprs) -> Value { |
| 1385 | std::string delim = delim_expr(params).asString(); |
| 1386 | std::stringstream out_ss; |
| 1387 | bool first = true; |
| 1388 | |
| 1389 | for (const auto &sub_expr : sub_exprs) { |
| 1390 | if (!first) { |
| 1391 | out_ss << delim; |
| 1392 | } |
| 1393 | out_ss << sub_expr(params).asString(); |
| 1394 | first = false; |
| 1395 | } |
| 1396 | |
| 1397 | return Value(out_ss.str()); |
| 1398 | }); |
| 1399 | } |
| 1400 | |
| 1401 | Expression make_dynamic_function(const std::string &function_name, const std::vector<Expression> &args) { |
| 1402 | if (function_name == "hostname") { |
no test coverage detected