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

Method ForEach

common/values/parsed_json_map_value.cc:312–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

310}
311
312absl::Status ParsedJsonMapValue::ForEach(
313 ForEachCallback callback,
314 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
315 google::protobuf::MessageFactory* absl_nonnull message_factory,
316 google::protobuf::Arena* absl_nonnull arena) const {
317 if (value_ == nullptr) {
318 return absl::OkStatus();
319 }
320 const auto reflection =
321 well_known_types::GetStructReflectionOrDie(value_->GetDescriptor());
322 Value key_scratch;
323 Value value_scratch;
324 auto map_begin = reflection.BeginFields(*value_);
325 const auto map_end = reflection.EndFields(*value_);
326 for (; map_begin != map_end; ++map_begin) {
327 // We have to copy until `google::protobuf::MapKey` is just a view.
328 key_scratch = StringValue(arena, map_begin.GetKey().GetStringValue());
329 value_scratch = common_internal::ParsedJsonValue(
330 &map_begin.GetValueRef().GetMessageValue(), arena);
331 CEL_ASSIGN_OR_RETURN(auto ok, callback(key_scratch, value_scratch));
332 if (!ok) {
333 break;
334 }
335 }
336 return absl::OkStatus();
337}
338
339namespace {
340

Callers

nothing calls this directly

Calls 8

GetStructReflectionOrDieFunction · 0.85
ParsedJsonValueFunction · 0.85
GetKeyMethod · 0.80
StringValueClass · 0.70
GetDescriptorMethod · 0.45
BeginFieldsMethod · 0.45
EndFieldsMethod · 0.45
GetStringValueMethod · 0.45

Tested by

no test coverage detected