| 468 | } |
| 469 | |
| 470 | absl::Status LegacyListValue::ConvertToJsonArray( |
| 471 | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
| 472 | google::protobuf::MessageFactory* absl_nonnull message_factory, |
| 473 | google::protobuf::Message* absl_nonnull json) const { |
| 474 | { |
| 475 | ABSL_DCHECK(descriptor_pool != nullptr); |
| 476 | ABSL_DCHECK(message_factory != nullptr); |
| 477 | ABSL_DCHECK(json != nullptr); |
| 478 | ABSL_DCHECK_EQ(json->GetDescriptor()->well_known_type(), |
| 479 | google::protobuf::Descriptor::WELLKNOWNTYPE_LISTVALUE); |
| 480 | |
| 481 | google::protobuf::Arena arena; |
| 482 | const google::protobuf::Message* wrapped = |
| 483 | MaybeWrapValueToMessage(json->GetDescriptor(), message_factory, |
| 484 | CelValue::CreateList(impl_), &arena); |
| 485 | if (wrapped == nullptr) { |
| 486 | return absl::UnknownError("failed to convert legacy list to JSON"); |
| 487 | } |
| 488 | |
| 489 | if (wrapped->GetDescriptor() == json->GetDescriptor()) { |
| 490 | // We can directly use google::protobuf::Message::Copy(). |
| 491 | json->CopyFrom(*wrapped); |
| 492 | } else { |
| 493 | // Equivalent descriptors but not identical. Must serialize and |
| 494 | // deserialize. |
| 495 | absl::Cord serialized; |
| 496 | if (!wrapped->SerializePartialToString(&serialized)) { |
| 497 | return absl::UnknownError(absl::StrCat("failed to serialize message: ", |
| 498 | wrapped->GetTypeName())); |
| 499 | } |
| 500 | if (!json->ParsePartialFromString(serialized)) { |
| 501 | return absl::UnknownError( |
| 502 | absl::StrCat("failed to parsed message: ", json->GetTypeName())); |
| 503 | } |
| 504 | } |
| 505 | return absl::OkStatus(); |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | bool LegacyListValue::IsEmpty() const { return impl_->empty(); } |
| 510 |
nothing calls this directly
no test coverage detected