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

Function StringRepeatedFieldAccessor

common/value.cc:914–953  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

912}
913
914void StringRepeatedFieldAccessor(
915 int index, const google::protobuf::Message* absl_nonnull message,
916 const google::protobuf::FieldDescriptor* absl_nonnull field,
917 const google::protobuf::Reflection* absl_nonnull reflection,
918 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
919 google::protobuf::MessageFactory* absl_nonnull message_factory,
920 google::protobuf::Arena* absl_nonnull arena, Value* absl_nonnull result) {
921 ABSL_DCHECK(message != nullptr);
922 ABSL_DCHECK(field != nullptr);
923 ABSL_DCHECK(message_factory != nullptr);
924 ABSL_DCHECK(descriptor_pool != nullptr);
925 ABSL_DCHECK(reflection != nullptr);
926 ABSL_DCHECK(arena != nullptr);
927 ABSL_DCHECK(result != nullptr);
928 ABSL_DCHECK_EQ(reflection, message->GetReflection());
929 ABSL_DCHECK_EQ(field->containing_type(), message->GetDescriptor());
930 ABSL_DCHECK(field->is_repeated());
931 ABSL_DCHECK_EQ(field->type(), google::protobuf::FieldDescriptor::TYPE_STRING);
932 ABSL_DCHECK_GE(index, 0);
933 ABSL_DCHECK_LT(index, reflection->FieldSize(*message, field));
934
935 std::string scratch;
936 absl::visit(
937 absl::Overload(
938 [&](absl::string_view string) {
939 if (string.data() == scratch.data() &&
940 string.size() == scratch.size()) {
941 *result = StringValue(arena, std::move(scratch));
942 } else {
943 if (message->GetArena() == nullptr) {
944 *result = StringValue(arena, string);
945 } else {
946 *result = StringValue(Borrower::Arena(arena), string);
947 }
948 }
949 },
950 [&](absl::Cord&& cord) { *result = StringValue(std::move(cord)); }),
951 well_known_types::AsVariant(well_known_types::GetRepeatedStringField(
952 *message, field, index, scratch)));
953}
954
955void MessageRepeatedFieldAccessor(
956 int index, const google::protobuf::Message* absl_nonnull message,

Callers

nothing calls this directly

Calls 8

ArenaFunction · 0.85
typeMethod · 0.80
StringValueClass · 0.50
GetRepeatedStringFieldFunction · 0.50
GetReflectionMethod · 0.45
GetDescriptorMethod · 0.45
sizeMethod · 0.45
GetArenaMethod · 0.45

Tested by

no test coverage detected