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

Function BytesRepeatedFieldAccessor

common/value.cc:981–1020  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

979}
980
981void BytesRepeatedFieldAccessor(
982 int index, const google::protobuf::Message* absl_nonnull message,
983 const google::protobuf::FieldDescriptor* absl_nonnull field,
984 const google::protobuf::Reflection* absl_nonnull reflection,
985 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
986 google::protobuf::MessageFactory* absl_nonnull message_factory,
987 google::protobuf::Arena* absl_nonnull arena, Value* absl_nonnull result) {
988 ABSL_DCHECK(message != nullptr);
989 ABSL_DCHECK(field != nullptr);
990 ABSL_DCHECK(message_factory != nullptr);
991 ABSL_DCHECK(descriptor_pool != nullptr);
992 ABSL_DCHECK(reflection != nullptr);
993 ABSL_DCHECK(arena != nullptr);
994 ABSL_DCHECK(result != nullptr);
995 ABSL_DCHECK_EQ(reflection, message->GetReflection());
996 ABSL_DCHECK_EQ(field->containing_type(), message->GetDescriptor());
997 ABSL_DCHECK(field->is_repeated());
998 ABSL_DCHECK_EQ(field->type(), google::protobuf::FieldDescriptor::TYPE_BYTES);
999 ABSL_DCHECK_GE(index, 0);
1000 ABSL_DCHECK_LT(index, reflection->FieldSize(*message, field));
1001
1002 std::string scratch;
1003 absl::visit(
1004 absl::Overload(
1005 [&](absl::string_view string) {
1006 if (string.data() == scratch.data() &&
1007 string.size() == scratch.size()) {
1008 *result = BytesValue(arena, std::move(scratch));
1009 } else {
1010 if (message->GetArena() == nullptr) {
1011 *result = BytesValue(arena, string);
1012 } else {
1013 *result = BytesValue(Borrower::Arena(arena), string);
1014 }
1015 }
1016 },
1017 [&](absl::Cord&& cord) { *result = BytesValue(std::move(cord)); }),
1018 well_known_types::AsVariant(well_known_types::GetRepeatedBytesField(
1019 *message, field, index, scratch)));
1020}
1021
1022void EnumRepeatedFieldAccessor(
1023 int index, const google::protobuf::Message* absl_nonnull message,

Callers

nothing calls this directly

Calls 8

ArenaFunction · 0.85
typeMethod · 0.80
BytesValueClass · 0.50
GetRepeatedBytesFieldFunction · 0.50
GetReflectionMethod · 0.45
GetDescriptorMethod · 0.45
sizeMethod · 0.45
GetArenaMethod · 0.45

Tested by

no test coverage detected