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

Function CompileAndEvaluateWithBoolVar

codelab/solutions/exercise2.cc:113–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111} // namespace
112
113absl::StatusOr<bool> CompileAndEvaluateWithBoolVar(absl::string_view cel_expr,
114 bool bool_var) {
115 CEL_ASSIGN_OR_RETURN(std::unique_ptr<cel::Compiler> compiler,
116 MakeCelCompiler());
117
118 CEL_ASSIGN_OR_RETURN(CheckedExpr checked_expr,
119 CompileToCheckedExpr(*compiler, cel_expr));
120
121 Activation activation;
122 google::protobuf::Arena arena;
123 // === Start Codelab ===
124 activation.InsertValue("bool_var", CelValue::CreateBool(bool_var));
125 // === End Codelab ===
126
127 return EvalCheckedExpr(checked_expr, activation, &arena);
128}
129
130absl::StatusOr<bool> CompileAndEvaluateWithContext(
131 absl::string_view cel_expr, const AttributeContext& context) {

Callers 1

TruthTableTestFunction · 0.70

Calls 4

InsertValueMethod · 0.80
MakeCelCompilerFunction · 0.70
EvalCheckedExprFunction · 0.70
CEL_ASSIGN_OR_RETURNFunction · 0.50

Tested by 1

TruthTableTestFunction · 0.56