| 79 | |
| 80 | template <typename Vector> |
| 81 | absl::Status ListValueToJsonArray( |
| 82 | const Vector& vector, |
| 83 | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
| 84 | google::protobuf::MessageFactory* absl_nonnull message_factory, |
| 85 | google::protobuf::Message* absl_nonnull json) { |
| 86 | ABSL_DCHECK(descriptor_pool != nullptr); |
| 87 | ABSL_DCHECK(message_factory != nullptr); |
| 88 | ABSL_DCHECK(json != nullptr); |
| 89 | ABSL_DCHECK_EQ(json->GetDescriptor()->well_known_type(), |
| 90 | google::protobuf::Descriptor::WELLKNOWNTYPE_LISTVALUE); |
| 91 | |
| 92 | ListValueReflection reflection; |
| 93 | CEL_RETURN_IF_ERROR(reflection.Initialize(json->GetDescriptor())); |
| 94 | |
| 95 | json->Clear(); |
| 96 | |
| 97 | if (vector.empty()) { |
| 98 | return absl::OkStatus(); |
| 99 | } |
| 100 | |
| 101 | for (const auto& element : vector) { |
| 102 | CEL_RETURN_IF_ERROR(element->ConvertToJson(descriptor_pool, message_factory, |
| 103 | reflection.AddValues(json))); |
| 104 | } |
| 105 | return absl::OkStatus(); |
| 106 | } |
| 107 | |
| 108 | template <typename Vector> |
| 109 | absl::Status ListValueToJson( |
no test coverage detected