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`
| 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; |
no test coverage detected