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

Method WrapMessage

common/value.cc:1402–1434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1400}
1401
1402Value Value::WrapMessage(
1403 const google::protobuf::Message* absl_nonnull message ABSL_ATTRIBUTE_LIFETIME_BOUND,
1404 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool
1405 ABSL_ATTRIBUTE_LIFETIME_BOUND,
1406 google::protobuf::MessageFactory* absl_nonnull message_factory
1407 ABSL_ATTRIBUTE_LIFETIME_BOUND,
1408 google::protobuf::Arena* absl_nonnull arena ABSL_ATTRIBUTE_LIFETIME_BOUND) {
1409 ABSL_DCHECK(message != nullptr);
1410 ABSL_DCHECK(descriptor_pool != nullptr);
1411 ABSL_DCHECK(message_factory != nullptr);
1412 ABSL_DCHECK(arena != nullptr);
1413
1414 std::string scratch;
1415 absl::StatusOr<well_known_types::Value> adapted_value =
1416 well_known_types::AdaptFromMessage(arena, *message, descriptor_pool,
1417 message_factory, scratch);
1418 if (ABSL_PREDICT_FALSE(!adapted_value.ok())) {
1419 return ErrorValue(std::move(adapted_value).status());
1420 }
1421 return absl::visit(
1422 absl::Overload(BorrowingWellKnownTypesValueVisitor{
1423 /* .message = */ message, /* .arena = */ arena,
1424 /* .scratch = */ &scratch},
1425 [&](absl::monostate) -> Value {
1426 if (message->GetArena() != arena) {
1427 auto* cloned = message->New(arena);
1428 cloned->CopyFrom(*message);
1429 return ParsedMessageValue(cloned, arena);
1430 }
1431 return ParsedMessageValue(message, arena);
1432 }),
1433 std::move(adapted_value).value());
1434}
1435
1436Value Value::WrapMessageUnsafe(
1437 const google::protobuf::Message* absl_nonnull message ABSL_ATTRIBUTE_LIFETIME_BOUND,

Callers

nothing calls this directly

Calls 8

AdaptFromMessageFunction · 0.85
ErrorValueFunction · 0.85
CopyFromMethod · 0.80
ParsedMessageValueClass · 0.50
okMethod · 0.45
GetArenaMethod · 0.45
NewMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected