MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / EvaluateWithExtensionFunction

Function EvaluateWithExtensionFunction

codelab/solutions/exercise4.cc:159–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157} // namespace
158
159absl::StatusOr<bool> EvaluateWithExtensionFunction(
160 absl::string_view expr, const AttributeContext& context) {
161 // Prepare a checked expression.
162 CEL_ASSIGN_OR_RETURN(std::unique_ptr<cel::Compiler> compiler,
163 MakeConfiguredCompiler());
164 CEL_ASSIGN_OR_RETURN(auto checked_expr,
165 CompileToCheckedExpr(*compiler, expr));
166
167 // Prepare an evaluation environment.
168 Evaluator evaluator;
169 CEL_RETURN_IF_ERROR(evaluator.SetupEvaluatorEnvironment());
170
171 // Evaluate a checked expression against a particular activation
172 return evaluator.Evaluate(checked_expr, context);
173}
174
175} // namespace cel_codelab

Callers

nothing calls this directly

Calls 4

MakeConfiguredCompilerFunction · 0.70
CEL_ASSIGN_OR_RETURNFunction · 0.50
EvaluateMethod · 0.45

Tested by

no test coverage detected