MCPcopy Create free account
hub / github.com/apache/nifi-minifi-cpp / make_allAttributes

Function make_allAttributes

extensions/expression-language/Expression.cpp:1079–1122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1077}
1078
1079Expression make_allAttributes(const std::string &function_name, const std::vector<Expression> &args) {
1080 if (args.size() < 1) {
1081 std::stringstream message_ss;
1082 message_ss << "Expression language function " << function_name << " called with " << args.size() << " argument(s), but " << 1 << " are required";
1083 throw std::runtime_error(message_ss.str());
1084 }
1085
1086 auto result = make_dynamic([=](const Parameters &params, const std::vector<Expression> &sub_exprs) -> Value {
1087 std::vector<Value> evaluated_args;
1088
1089 bool all_true = true;
1090
1091 for (const auto &sub_expr : sub_exprs) {
1092 all_true = all_true && sub_expr(params).asBoolean();
1093 }
1094
1095 return Value(all_true);
1096 });
1097
1098 result.make_multi([=](const Parameters& /*params*/) -> std::vector<Expression> {
1099 std::vector<Expression> out_exprs;
1100
1101 for (const auto &arg : args) {
1102 out_exprs.emplace_back(make_dynamic([=](const Parameters &params,
1103 const std::vector<Expression>& /*sub_exprs*/) -> Value {
1104 std::string attr_id;
1105 attr_id = arg(params).asString();
1106 std::string attr_val;
1107
1108 const auto cur_flow_file = params.flow_file.lock();
1109
1110 if (cur_flow_file && cur_flow_file->getAttribute(attr_id, attr_val)) {
1111 return Value(attr_val);
1112 } else {
1113 return Value();
1114 }
1115 }));
1116 }
1117
1118 return out_exprs;
1119 });
1120
1121 return result;
1122}
1123
1124Expression make_anyAttribute(const std::string &function_name, const std::vector<Expression> &args) {
1125 if (args.size() < 1) {

Callers 1

make_dynamic_functionFunction · 0.85

Calls 8

make_dynamicFunction · 0.85
asBooleanMethod · 0.80
make_multiMethod · 0.80
asStringMethod · 0.80
lockMethod · 0.80
ValueClass · 0.50
sizeMethod · 0.45
getAttributeMethod · 0.45

Tested by

no test coverage detected