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

Method ListKeys

common/values/parsed_map_field_value.cc:399–429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397}
398
399absl::Status ParsedMapFieldValue::ListKeys(
400 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
401 google::protobuf::MessageFactory* absl_nonnull message_factory,
402 google::protobuf::Arena* absl_nonnull arena, ListValue* absl_nonnull result) const {
403 ABSL_DCHECK(*this);
404 if (field_ == nullptr) {
405 *result = ListValue();
406 return absl::OkStatus();
407 }
408 const auto* reflection = message_->GetReflection();
409 if (reflection->FieldSize(*message_, field_) == 0) {
410 *result = ListValue();
411 return absl::OkStatus();
412 }
413 CEL_ASSIGN_OR_RETURN(auto key_accessor,
414 common_internal::MapFieldKeyAccessorFor(
415 field_->message_type()->map_key()));
416 auto builder = NewListValueBuilder(arena);
417 builder->Reserve(Size());
418 auto begin = extensions::protobuf_internal::ConstMapBegin(*reflection,
419 *message_, *field_);
420 const auto end = extensions::protobuf_internal::ConstMapEnd(
421 *reflection, *message_, *field_);
422 for (; begin != end; ++begin) {
423 Value scratch;
424 (*key_accessor)(begin.GetKey(), message_, arena, &scratch);
425 CEL_RETURN_IF_ERROR(builder->Add(std::move(scratch)));
426 }
427 *result = std::move(*builder).Build();
428 return absl::OkStatus();
429}
430
431absl::Status ParsedMapFieldValue::ForEach(
432 ForEachCallback callback,

Callers

nothing calls this directly

Calls 8

ConstMapBeginFunction · 0.85
ConstMapEndFunction · 0.85
GetKeyMethod · 0.80
ListValueClass · 0.70
GetReflectionMethod · 0.45
ReserveMethod · 0.45
AddMethod · 0.45
BuildMethod · 0.45

Tested by

no test coverage detected