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

Function Has

eval/public/cel_value.h:607–621  ·  view source on GitHub ↗

Return whether the key is present within the map. Typically, key resolution will be a simple boolean result; however, there are scenarios where the conversion of the input key to the underlying key-type will produce an absl::StatusCode::kInvalidArgument. Evaluators are responsible for handling non-OK results by propagating the error, as appropriate, up the evaluation stack either as a `StatusOr`

Source from the content-addressed store, hash-verified

605 // error, as appropriate, up the evaluation stack either as a `StatusOr` or
606 // as a `CelError` value, depending on the context.
607 virtual absl::StatusOr<bool> Has(const CelValue& key) const {
608 // This check safeguards against issues with invalid key types such as NaN.
609 CEL_RETURN_IF_ERROR(CelValue::CheckMapKeyType(key));
610 google::protobuf::Arena arena;
611 auto value = (*this).Get(&arena, key);
612 if (!value.has_value()) {
613 return false;
614 }
615 // This protects from issues that may occur when looking up a key value,
616 // such as a failure to convert an int64 to an int32 map key.
617 if (value->IsError()) {
618 return *value->ErrorOrDie();
619 }
620 return true;
621 }
622
623 // Map size
624 virtual int size() const = 0;

Callers 3

ComprehensionSlotClass · 0.50
mutable_valueMethod · 0.50
mutable_attributeMethod · 0.50

Calls 5

CheckMapKeyTypeFunction · 0.85
ErrorOrDieMethod · 0.80
GetMethod · 0.45
has_valueMethod · 0.45
IsErrorMethod · 0.45

Tested by

no test coverage detected