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

Method ForEach

common/values/parsed_map_field_value.cc:431–467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

429}
430
431absl::Status ParsedMapFieldValue::ForEach(
432 ForEachCallback callback,
433 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
434 google::protobuf::MessageFactory* absl_nonnull message_factory,
435 google::protobuf::Arena* absl_nonnull arena) const {
436 ABSL_DCHECK(*this);
437 if (field_ == nullptr) {
438 return absl::OkStatus();
439 }
440 const auto* reflection = message_->GetReflection();
441 if (reflection->FieldSize(*message_, field_) > 0) {
442 const auto* value_field = field_->message_type()->map_value();
443 CEL_ASSIGN_OR_RETURN(auto key_accessor,
444 common_internal::MapFieldKeyAccessorFor(
445 field_->message_type()->map_key()));
446 CEL_ASSIGN_OR_RETURN(
447 auto value_accessor,
448 common_internal::MapFieldValueAccessorFor(value_field));
449 auto begin = extensions::protobuf_internal::ConstMapBegin(
450 *reflection, *message_, *field_);
451 const auto end = extensions::protobuf_internal::ConstMapEnd(
452 *reflection, *message_, *field_);
453 Value key_scratch;
454 Value value_scratch;
455 for (; begin != end; ++begin) {
456 (*key_accessor)(begin.GetKey(), message_, arena, &key_scratch);
457 (*value_accessor)(begin.GetValueRef(), message_, value_field,
458 descriptor_pool, message_factory, arena,
459 &value_scratch);
460 CEL_ASSIGN_OR_RETURN(auto ok, callback(key_scratch, value_scratch));
461 if (!ok) {
462 break;
463 }
464 }
465 }
466 return absl::OkStatus();
467}
468
469namespace {
470

Callers

nothing calls this directly

Calls 4

ConstMapBeginFunction · 0.85
ConstMapEndFunction · 0.85
GetKeyMethod · 0.80
GetReflectionMethod · 0.45

Tested by

no test coverage detected