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

Function EvaluateWithExtensionFunction

codelab/exercise4.cc:116–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114} // namespace
115
116absl::StatusOr<bool> EvaluateWithExtensionFunction(
117 absl::string_view expr, const AttributeContext& context) {
118 // Prepare a checked expression.
119 CEL_ASSIGN_OR_RETURN(std::unique_ptr<cel::Compiler> compiler,
120 MakeConfiguredCompiler());
121 CEL_ASSIGN_OR_RETURN(auto checked_expr,
122 CompileToCheckedExpr(*compiler, expr));
123
124 // Prepare an evaluation environment.
125 Evaluator evaluator;
126 CEL_RETURN_IF_ERROR(evaluator.SetupEvaluatorEnvironment());
127
128 // Evaluate a checked expression against a particular activation
129 return evaluator.Evaluate(checked_expr, context);
130}
131
132} // namespace cel_codelab

Callers 1

TESTFunction · 0.70

Calls 4

MakeConfiguredCompilerFunction · 0.70
CEL_ASSIGN_OR_RETURNFunction · 0.50
EvaluateMethod · 0.45

Tested by 1

TESTFunction · 0.56