| 107 | } // namespace |
| 108 | |
| 109 | absl::Status RegisterStringFunctions(FunctionRegistry& registry, |
| 110 | const RuntimeOptions& options) { |
| 111 | // Basic substring tests (contains, startsWith, endsWith) |
| 112 | for (bool receiver_style : {true, false}) { |
| 113 | auto status = |
| 114 | BinaryFunctionAdapter<bool, const StringValue&, const StringValue&>:: |
| 115 | Register(cel::builtin::kStringContains, receiver_style, |
| 116 | StringContains, registry); |
| 117 | CEL_RETURN_IF_ERROR(status); |
| 118 | |
| 119 | status = |
| 120 | BinaryFunctionAdapter<bool, const StringValue&, const StringValue&>:: |
| 121 | Register(cel::builtin::kStringEndsWith, receiver_style, |
| 122 | StringEndsWith, registry); |
| 123 | CEL_RETURN_IF_ERROR(status); |
| 124 | |
| 125 | status = |
| 126 | BinaryFunctionAdapter<bool, const StringValue&, const StringValue&>:: |
| 127 | Register(cel::builtin::kStringStartsWith, receiver_style, |
| 128 | StringStartsWith, registry); |
| 129 | CEL_RETURN_IF_ERROR(status); |
| 130 | } |
| 131 | |
| 132 | // string concatenation if enabled |
| 133 | if (options.enable_string_concat) { |
| 134 | CEL_RETURN_IF_ERROR(RegisterConcatFunctions(registry)); |
| 135 | } |
| 136 | |
| 137 | return RegisterSizeFunctions(registry); |
| 138 | } |
| 139 | |
| 140 | } // namespace cel |