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

Method Find

common/values/parsed_map_field_value.cc:327–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325}
326
327absl::StatusOr<bool> ParsedMapFieldValue::Find(
328 const Value& key,
329 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
330 google::protobuf::MessageFactory* absl_nonnull message_factory,
331 google::protobuf::Arena* absl_nonnull arena, Value* absl_nonnull result) const {
332 ABSL_DCHECK(*this);
333 ABSL_DCHECK(message_ != nullptr);
334 if (ABSL_PREDICT_FALSE(field_ == nullptr)) {
335 *result = NullValue();
336 return false;
337 }
338 if (key.IsError() || key.IsUnknown()) {
339 *result = key;
340 return false;
341 }
342 const google::protobuf::Descriptor* absl_nonnull entry_descriptor =
343 field_->message_type();
344 const google::protobuf::FieldDescriptor* absl_nonnull key_field =
345 entry_descriptor->map_key();
346 const google::protobuf::FieldDescriptor* absl_nonnull value_field =
347 entry_descriptor->map_value();
348 std::string proto_key_scratch;
349 google::protobuf::MapKey proto_key;
350 if (!ValueToProtoMapKey(key, key_field->cpp_type(), &proto_key,
351 proto_key_scratch)) {
352 *result = NullValue();
353 return false;
354 }
355 google::protobuf::MapValueConstRef proto_value;
356 if (!extensions::protobuf_internal::LookupMapValue(
357 *GetReflection(), *message_, *field_, proto_key, &proto_value)) {
358 *result = NullValue();
359 return false;
360 }
361 if (arena_ == nullptr) {
362 *result =
363 Value::WrapMapFieldValueUnsafe(proto_value, message_, value_field,
364 descriptor_pool, message_factory, arena);
365 } else {
366 *result = Value::WrapMapFieldValue(proto_value, message_, value_field,
367 descriptor_pool, message_factory, arena);
368 }
369 return true;
370}
371
372absl::Status ParsedMapFieldValue::Has(
373 const Value& key,

Callers

nothing calls this directly

Calls 5

ValueToProtoMapKeyFunction · 0.85
NullValueClass · 0.70
LookupMapValueFunction · 0.50
IsErrorMethod · 0.45
IsUnknownMethod · 0.45

Tested by

no test coverage detected