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

Function UnsafeLegacyValue

common/legacy_value.cc:353–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351} // namespace
352
353google::api::expr::runtime::CelValue UnsafeLegacyValue(
354 const Value& value, bool stable, google::protobuf::Arena* absl_nonnull arena) {
355 switch (value.kind()) {
356 case ValueKind::kNull:
357 return CelValue::CreateNull();
358 case ValueKind::kBool:
359 return CelValue::CreateBool(value.GetBool());
360 case ValueKind::kInt:
361 return CelValue::CreateInt64(value.GetInt());
362 case ValueKind::kUint:
363 return CelValue::CreateUint64(value.GetUint());
364 case ValueKind::kDouble:
365 return CelValue::CreateDouble(value.GetDouble());
366 case ValueKind::kString:
367 return CelValue::CreateStringView(
368 LegacyStringValue(value.GetString(), stable, arena));
369 case ValueKind::kBytes:
370 return CelValue::CreateBytesView(
371 LegacyBytesValue(value.GetBytes(), stable, arena));
372 case ValueKind::kStruct:
373 return LegacyTrivialStructValue(arena, value);
374 case ValueKind::kDuration:
375 return CelValue::CreateDuration(value.GetDuration().ToDuration());
376 case ValueKind::kTimestamp:
377 return CelValue::CreateTimestamp(value.GetTimestamp().ToTime());
378 case ValueKind::kList:
379 return LegacyTrivialListValue(arena, value);
380 case ValueKind::kMap:
381 return LegacyTrivialMapValue(arena, value);
382 case ValueKind::kType:
383 return CelValue::CreateCelTypeView(value.GetType().name());
384 default:
385 // Everything else is unsupported.
386 return CelValue::CreateError(google::protobuf::Arena::Create<absl::Status>(
387 arena, absl::InvalidArgumentError(absl::StrCat(
388 "unsupported conversion from cel::Value to CelValue: ",
389 value->GetRuntimeType().DebugString()))));
390 }
391}
392
393} // namespace common_internal
394

Callers 4

GetMethod · 0.85
GetMethod · 0.85
GetMethod · 0.85
GetMethod · 0.85

Calls 15

LegacyStringValueFunction · 0.85
LegacyBytesValueFunction · 0.85
LegacyTrivialStructValueFunction · 0.85
LegacyTrivialListValueFunction · 0.85
LegacyTrivialMapValueFunction · 0.85
CreateErrorFunction · 0.50
kindMethod · 0.45
GetBoolMethod · 0.45
GetIntMethod · 0.45
GetUintMethod · 0.45
GetDoubleMethod · 0.45
GetStringMethod · 0.45

Tested by

no test coverage detected