| 103 | } |
| 104 | |
| 105 | absl::optional<CelValue> operator[](CelValue cel_key) const override { |
| 106 | if (!cel_key.IsString()) { |
| 107 | return CreateErrorValue( |
| 108 | arena_, absl::InvalidArgumentError( |
| 109 | absl::StrCat("Invalid map key type: '", |
| 110 | CelValue::TypeName(cel_key.type()), "'"))); |
| 111 | } |
| 112 | const absl::string_view key = cel_key.StringOrDie().value(); |
| 113 | const auto it = std::lower_bound( |
| 114 | list_->begin(), list_->end(), key, |
| 115 | [this](const flatbuffers::Table* t, const absl::string_view key) { |
| 116 | auto value = flatbuffers::GetFieldS(*t, index_); |
| 117 | auto sv = value ? absl::string_view(value->c_str(), value->size()) |
| 118 | : absl::string_view(); |
| 119 | return sv < key; |
| 120 | }); |
| 121 | if (it != list_->end()) { |
| 122 | auto value = flatbuffers::GetFieldS(**it, index_); |
| 123 | auto sv = value ? absl::string_view(value->c_str(), value->size()) |
| 124 | : absl::string_view(); |
| 125 | if (sv == key) { |
| 126 | return CelValue::CreateMap(google::protobuf::Arena::Create<FlatBuffersMapImpl>( |
| 127 | arena_, **it, schema_, object_, arena_)); |
| 128 | } |
| 129 | } |
| 130 | return absl::nullopt; |
| 131 | } |
| 132 | |
| 133 | absl::StatusOr<const CelList*> ListKeys() const override { return &keys_; } |
| 134 |
nothing calls this directly
no test coverage detected