| 265 | } |
| 266 | |
| 267 | absl::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 | |
| 288 | absl::StatusOr<absl::string_view> FormatBinary( |
| 289 | const Value& value, std::string& scratch ABSL_ATTRIBUTE_LIFETIME_BOUND) { |
nothing calls this directly
no test coverage detected