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

Function CompileToCheckedExpr

codelab/cel_compiler.h:32–43  ·  view source on GitHub ↗

Helper for compiling expression and converting to proto. Simplifies error handling for brevity in the codelab.

Source from the content-addressed store, hash-verified

30//
31// Simplifies error handling for brevity in the codelab.
32inline absl::StatusOr<cel::expr::CheckedExpr> CompileToCheckedExpr(
33 const cel::Compiler& compiler, absl::string_view expr) {
34 CEL_ASSIGN_OR_RETURN(cel::ValidationResult result, compiler.Compile(expr));
35
36 if (!result.IsValid() || result.GetAst() == nullptr) {
37 return absl::InvalidArgumentError(result.FormatError());
38 }
39
40 cel::expr::CheckedExpr pb;
41 CEL_RETURN_IF_ERROR(cel::AstToCheckedExpr(*result.GetAst(), &pb));
42 return pb;
43};
44
45} // namespace cel_codelab
46

Callers 1

TESTFunction · 0.85

Calls 4

AstToCheckedExprFunction · 0.85
IsValidMethod · 0.80
GetAstMethod · 0.80
FormatErrorMethod · 0.80

Tested by 1

TESTFunction · 0.68