| 306 | } // namespace |
| 307 | |
| 308 | absl::Status RegisterStringsFunctions( |
| 309 | FunctionRegistry& registry, const RuntimeOptions& options, |
| 310 | const StringsExtensionOptions& extension_options) { |
| 311 | const int version = extension_options.version; |
| 312 | CEL_RETURN_IF_ERROR(registry.Register( |
| 313 | BinaryFunctionAdapter<absl::StatusOr<Value>, StringValue, StringValue>:: |
| 314 | CreateDescriptor("split", /*receiver_style=*/true), |
| 315 | BinaryFunctionAdapter<absl::StatusOr<Value>, StringValue, |
| 316 | StringValue>::WrapFunction(Split2))); |
| 317 | CEL_RETURN_IF_ERROR(registry.Register( |
| 318 | TernaryFunctionAdapter< |
| 319 | absl::StatusOr<Value>, StringValue, StringValue, |
| 320 | int64_t>::CreateDescriptor("split", /*receiver_style=*/true), |
| 321 | TernaryFunctionAdapter<absl::StatusOr<Value>, StringValue, StringValue, |
| 322 | int64_t>::WrapFunction(Split3))); |
| 323 | CEL_RETURN_IF_ERROR(registry.Register( |
| 324 | UnaryFunctionAdapter<absl::StatusOr<Value>, StringValue>:: |
| 325 | CreateDescriptor("lowerAscii", /*receiver_style=*/true), |
| 326 | UnaryFunctionAdapter<absl::StatusOr<Value>, StringValue>::WrapFunction( |
| 327 | LowerAscii))); |
| 328 | CEL_RETURN_IF_ERROR(registry.Register( |
| 329 | UnaryFunctionAdapter<absl::StatusOr<Value>, StringValue>:: |
| 330 | CreateDescriptor("upperAscii", /*receiver_style=*/true), |
| 331 | UnaryFunctionAdapter<absl::StatusOr<Value>, StringValue>::WrapFunction( |
| 332 | UpperAscii))); |
| 333 | CEL_RETURN_IF_ERROR(registry.Register( |
| 334 | TernaryFunctionAdapter< |
| 335 | absl::StatusOr<Value>, StringValue, StringValue, |
| 336 | StringValue>::CreateDescriptor("replace", /*receiver_style=*/true), |
| 337 | TernaryFunctionAdapter<absl::StatusOr<Value>, StringValue, StringValue, |
| 338 | StringValue>::WrapFunction(Replace1))); |
| 339 | CEL_RETURN_IF_ERROR(registry.Register( |
| 340 | QuaternaryFunctionAdapter< |
| 341 | absl::StatusOr<Value>, StringValue, StringValue, StringValue, |
| 342 | int64_t>::CreateDescriptor("replace", /*receiver_style=*/true), |
| 343 | QuaternaryFunctionAdapter<absl::StatusOr<Value>, StringValue, StringValue, |
| 344 | StringValue, int64_t>::WrapFunction(Replace2))); |
| 345 | CEL_RETURN_IF_ERROR( |
| 346 | (BinaryFunctionAdapter<Value, StringValue, |
| 347 | int64_t>::RegisterMemberOverload("charAt", &CharAt, |
| 348 | registry))); |
| 349 | CEL_RETURN_IF_ERROR( |
| 350 | (BinaryFunctionAdapter<int64_t, StringValue, |
| 351 | StringValue>::RegisterMemberOverload("indexOf", |
| 352 | &IndexOf2, |
| 353 | registry))); |
| 354 | CEL_RETURN_IF_ERROR( |
| 355 | (TernaryFunctionAdapter<Value, StringValue, StringValue, |
| 356 | int64_t>::RegisterMemberOverload("indexOf", |
| 357 | &IndexOf3, |
| 358 | registry))); |
| 359 | CEL_RETURN_IF_ERROR( |
| 360 | (BinaryFunctionAdapter<int64_t, StringValue, |
| 361 | StringValue>::RegisterMemberOverload("lastIndexOf", |
| 362 | &LastIndexOf2, |
| 363 | registry))); |
| 364 | CEL_RETURN_IF_ERROR( |
| 365 | (TernaryFunctionAdapter<Value, StringValue, StringValue, |