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

Function RegisterStringsDecls

extensions/strings.cc:184–304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182}
183
184absl::Status RegisterStringsDecls(TypeCheckerBuilder& builder, int version) {
185 // Runtime Supported functions.
186 CEL_ASSIGN_OR_RETURN(
187 auto join_decl,
188 MakeFunctionDecl(
189 "join",
190 MakeMemberOverloadDecl("list_join", StringType(), ListStringType()),
191 MakeMemberOverloadDecl("list_join_string", StringType(),
192 ListStringType(), StringType())));
193 CEL_ASSIGN_OR_RETURN(
194 auto split_decl,
195 MakeFunctionDecl(
196 "split",
197 MakeMemberOverloadDecl("string_split_string", ListStringType(),
198 StringType(), StringType()),
199 MakeMemberOverloadDecl("string_split_string_int", ListStringType(),
200 StringType(), StringType(), IntType())));
201 CEL_ASSIGN_OR_RETURN(
202 auto lower_decl,
203 MakeFunctionDecl("lowerAscii",
204 MakeMemberOverloadDecl("string_lower_ascii",
205 StringType(), StringType())));
206
207 CEL_ASSIGN_OR_RETURN(
208 auto replace_decl,
209 MakeFunctionDecl(
210 "replace",
211 MakeMemberOverloadDecl("string_replace_string_string", StringType(),
212 StringType(), StringType(), StringType()),
213 MakeMemberOverloadDecl("string_replace_string_string_int",
214 StringType(), StringType(), StringType(),
215 StringType(), IntType())));
216
217 // Additional functions described in the spec.
218 CEL_ASSIGN_OR_RETURN(
219 auto char_at_decl,
220 MakeFunctionDecl(
221 "charAt", MakeMemberOverloadDecl("string_char_at_int", StringType(),
222 StringType(), IntType())));
223 CEL_ASSIGN_OR_RETURN(
224 auto index_of_decl,
225 MakeFunctionDecl(
226 "indexOf",
227 MakeMemberOverloadDecl("string_index_of_string", IntType(),
228 StringType(), StringType()),
229 MakeMemberOverloadDecl("string_index_of_string_int", IntType(),
230 StringType(), StringType(), IntType())));
231 CEL_ASSIGN_OR_RETURN(
232 auto last_index_of_decl,
233 MakeFunctionDecl(
234 "lastIndexOf",
235 MakeMemberOverloadDecl("string_last_index_of_string", IntType(),
236 StringType(), StringType()),
237 MakeMemberOverloadDecl("string_last_index_of_string_int", IntType(),
238 StringType(), StringType(), IntType())));
239
240 CEL_ASSIGN_OR_RETURN(
241 auto substring_decl,

Callers 1

StringsCheckerLibraryFunction · 0.85

Calls 4

MakeOverloadDeclFunction · 0.85
MergeFunctionMethod · 0.80
StringTypeClass · 0.50
AddFunctionMethod · 0.45

Tested by

no test coverage detected