| 541 | } // namespace |
| 542 | |
| 543 | absl::Status RegisterStringFormattingFunctions( |
| 544 | FunctionRegistry& registry, const RuntimeOptions& options, |
| 545 | StringsExtensionFormatOptions format_options) { |
| 546 | const int max_precision = |
| 547 | std::clamp(format_options.max_precision, 0, kMaxPrecision); |
| 548 | CEL_RETURN_IF_ERROR(registry.Register( |
| 549 | BinaryFunctionAdapter<absl::StatusOr<Value>, StringValue, ListValue>:: |
| 550 | CreateDescriptor("format", /*receiver_style=*/true), |
| 551 | BinaryFunctionAdapter<absl::StatusOr<Value>, StringValue, ListValue>:: |
| 552 | WrapFunction( |
| 553 | [max_precision]( |
| 554 | const StringValue& format, const ListValue& args, |
| 555 | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
| 556 | google::protobuf::MessageFactory* absl_nonnull message_factory, |
| 557 | google::protobuf::Arena* absl_nonnull arena) { |
| 558 | return Format(format, args, max_precision, descriptor_pool, |
| 559 | message_factory, arena); |
| 560 | }))); |
| 561 | return absl::OkStatus(); |
| 562 | } |
| 563 | |
| 564 | } // namespace cel::extensions |