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

Function RepeatedFieldAsEquatableValue

internal/message_equality.cc:515–574  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

513}
514
515absl::StatusOr<EquatableValue> RepeatedFieldAsEquatableValue(
516 google::protobuf::Arena* absl_nonnull arena, const DescriptorPool* absl_nonnull pool,
517 MessageFactory* absl_nonnull factory, EquatableValueReflection& reflection,
518 const Message& message, const FieldDescriptor* absl_nonnull field,
519 int index, std::string& scratch, Unique<Message>& unpacked) {
520 if (IsAnyField(field)) {
521 const auto& field_value =
522 message.GetReflection()->GetRepeatedMessage(message, field, index);
523 CEL_ASSIGN_OR_RETURN(unpacked, well_known_types::UnpackAnyIfResolveable(
524 arena, reflection.any_reflection,
525 field_value, pool, factory));
526 if (unpacked) {
527 return AsEquatableValue(reflection, *unpacked, unpacked->GetDescriptor(),
528 scratch);
529 }
530 return AsEquatableValue(reflection, field_value,
531 field_value.GetDescriptor(), scratch);
532 }
533 switch (field->cpp_type()) {
534 case FieldDescriptor::CPPTYPE_INT32:
535 return static_cast<int64_t>(
536 message.GetReflection()->GetRepeatedInt32(message, field, index));
537 case FieldDescriptor::CPPTYPE_INT64:
538 return message.GetReflection()->GetRepeatedInt64(message, field, index);
539 case FieldDescriptor::CPPTYPE_UINT32:
540 return static_cast<uint64_t>(
541 message.GetReflection()->GetRepeatedUInt32(message, field, index));
542 case FieldDescriptor::CPPTYPE_UINT64:
543 return message.GetReflection()->GetRepeatedUInt64(message, field, index);
544 case FieldDescriptor::CPPTYPE_DOUBLE:
545 return message.GetReflection()->GetRepeatedDouble(message, field, index);
546 case FieldDescriptor::CPPTYPE_FLOAT:
547 return static_cast<double>(
548 message.GetReflection()->GetRepeatedFloat(message, field, index));
549 case FieldDescriptor::CPPTYPE_BOOL:
550 return message.GetReflection()->GetRepeatedBool(message, field, index);
551 case FieldDescriptor::CPPTYPE_ENUM:
552 if (field->enum_type()->full_name() == "google.protobuf.NullValue") {
553 return nullptr;
554 }
555 return static_cast<int64_t>(
556 message.GetReflection()->GetRepeatedEnumValue(message, field, index));
557 case FieldDescriptor::CPPTYPE_STRING:
558 if (field->type() == FieldDescriptor::TYPE_BYTES) {
559 return well_known_types::GetRepeatedBytesField(message, field, index,
560 scratch);
561 }
562 return well_known_types::GetRepeatedStringField(message, field, index,
563 scratch);
564 case FieldDescriptor::CPPTYPE_MESSAGE: {
565 const auto& submessage =
566 message.GetReflection()->GetRepeatedMessage(message, field, index);
567 return AsEquatableValue(reflection, submessage,
568 submessage.GetDescriptor(), scratch);
569 }
570 default:
571 return absl::InternalError(
572 absl::StrCat("unexpected field type: ", field->cpp_type_name()));

Callers 1

RepeatedFieldEqualsMethod · 0.85

Calls 9

IsAnyFieldFunction · 0.85
UnpackAnyIfResolveableFunction · 0.85
AsEquatableValueFunction · 0.85
typeMethod · 0.80
GetRepeatedBytesFieldFunction · 0.70
GetRepeatedStringFieldFunction · 0.70
CEL_ASSIGN_OR_RETURNFunction · 0.50
GetReflectionMethod · 0.45
GetDescriptorMethod · 0.45

Tested by

no test coverage detected