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

Function FromObject

common/internal/value_conversion.cc:79–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79absl::StatusOr<Value> FromObject(
80 const google::protobuf::Any& any,
81 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
82 google::protobuf::MessageFactory* absl_nonnull message_factory,
83 google::protobuf::Arena* absl_nonnull arena) {
84 if (any.type_url() == "type.googleapis.com/google.protobuf.Duration") {
85 google::protobuf::Duration duration;
86 if (!any.UnpackTo(&duration)) {
87 return absl::InvalidArgumentError("invalid duration");
88 }
89 absl::Duration d = internal::DecodeDuration(duration);
90 CEL_RETURN_IF_ERROR(cel::internal::ValidateDuration(d));
91 return cel::DurationValue(d);
92 } else if (any.type_url() ==
93 "type.googleapis.com/google.protobuf.Timestamp") {
94 google::protobuf::Timestamp timestamp;
95 if (!any.UnpackTo(&timestamp)) {
96 return absl::InvalidArgumentError("invalid timestamp");
97 }
98 absl::Time time = internal::DecodeTime(timestamp);
99 CEL_RETURN_IF_ERROR(cel::internal::ValidateTimestamp(time));
100 return cel::TimestampValue(time);
101 }
102
103 return extensions::ProtoMessageToValue(any, descriptor_pool, message_factory,
104 arena);
105}
106
107absl::StatusOr<MapValue> MapValueFromExpr(
108 const ExprMapValue& map_value,

Callers 1

FromExprValueFunction · 0.85

Calls 7

DecodeDurationFunction · 0.85
ValidateDurationFunction · 0.85
DecodeTimeFunction · 0.85
ValidateTimestampFunction · 0.85
ProtoMessageToValueFunction · 0.85
DurationValueClass · 0.50
TimestampValueClass · 0.50

Tested by

no test coverage detected