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

Method Evaluate

codelab/solutions/exercise4.cc:134–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132 }
133
134 absl::StatusOr<bool> Evaluate(const CheckedExpr& expr,
135 const AttributeContext& context) {
136 Activation activation;
137 CEL_RETURN_IF_ERROR(BindProtoToActivation(&context, &arena_, &activation));
138 CEL_ASSIGN_OR_RETURN(auto plan, builder_->CreateExpression(&expr));
139 CEL_ASSIGN_OR_RETURN(CelValue result, plan->Evaluate(activation, &arena_));
140
141 if (bool value; result.GetValue(&value)) {
142 return value;
143 } else if (const CelError* value; result.GetValue(&value)) {
144 return *value;
145 } else {
146 return absl::InvalidArgumentError(
147 absl::StrCat("unexpected return type: ", result.DebugString()));
148 }
149 }
150
151 private:
152 google::protobuf::Arena arena_;

Callers 2

Calls 3

BindProtoToActivationFunction · 0.50
GetValueMethod · 0.45
DebugStringMethod · 0.45

Tested by

no test coverage detected