| 470 | } |
| 471 | |
| 472 | CelValue ValueFromString(const google::protobuf::Message* message) { |
| 473 | CEL_ASSIGN_OR_RETURN(auto reflection, |
| 474 | cel::well_known_types::GetStringValueReflection( |
| 475 | message->GetDescriptor()), |
| 476 | _.With(ReturnCelValueError(arena_))); |
| 477 | std::string scratch; |
| 478 | return absl::visit( |
| 479 | absl::Overload( |
| 480 | [&](absl::string_view string) -> CelValue { |
| 481 | if (string.data() == scratch.data() && |
| 482 | string.size() == scratch.size()) { |
| 483 | return CelValue::CreateString( |
| 484 | google::protobuf::Arena::Create<std::string>(arena_, |
| 485 | std::move(scratch))); |
| 486 | } |
| 487 | return CelValue::CreateString(google::protobuf::Arena::Create<std::string>( |
| 488 | arena_, std::string(string))); |
| 489 | }, |
| 490 | [&](absl::Cord&& cord) -> CelValue { |
| 491 | auto* string = google::protobuf::Arena::Create<std::string>(arena_); |
| 492 | absl::CopyCordToString(cord, string); |
| 493 | return CelValue::CreateString(string); |
| 494 | }), |
| 495 | cel::well_known_types::AsVariant( |
| 496 | reflection.GetValue(*message, scratch))); |
| 497 | } |
| 498 | |
| 499 | CelValue ValueFromString(const absl::Cord& value) { |
| 500 | return CelValue::CreateString( |