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

Function FormatDecimal

extensions/formatting.cc:267–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265}
266
267absl::StatusOr<absl::string_view> FormatDecimal(
268 const Value& value, std::string& scratch ABSL_ATTRIBUTE_LIFETIME_BOUND) {
269 scratch.clear();
270 switch (value.kind()) {
271 case ValueKind::kInt:
272 absl::StrAppend(&scratch, value.GetInt().NativeValue());
273 return scratch;
274 case ValueKind::kUint:
275 absl::StrAppend(&scratch, value.GetUint().NativeValue());
276 return scratch;
277 case ValueKind::kDouble:
278 return FormatDouble(value.GetDouble().NativeValue(),
279 /*precision=*/std::nullopt,
280 /*use_scientific_notation=*/false, scratch);
281 default:
282 return absl::InvalidArgumentError(
283 absl::StrCat("decimal clause can only be used on numbers, was given ",
284 value.GetTypeName()));
285 }
286}
287
288absl::StatusOr<absl::string_view> FormatBinary(
289 const Value& value, std::string& scratch ABSL_ATTRIBUTE_LIFETIME_BOUND) {

Callers

nothing calls this directly

Calls 8

clearMethod · 0.80
FormatDoubleFunction · 0.70
kindMethod · 0.45
NativeValueMethod · 0.45
GetIntMethod · 0.45
GetUintMethod · 0.45
GetDoubleMethod · 0.45
GetTypeNameMethod · 0.45

Tested by

no test coverage detected