1
0
Fork 0
arangodb/js/server/js-aql-functions-string.h

151 lines
5.0 KiB
C

static string JS_server_aql_functions_string =
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief AQL query language string functions\n"
"///\n"
"/// @file\n"
"///\n"
"/// DISCLAIMER\n"
"///\n"
"/// Copyright 2010-2012 triagens GmbH, Cologne, Germany\n"
"///\n"
"/// Licensed under the Apache License, Version 2.0 (the \"License\");\n"
"/// you may not use this file except in compliance with the License.\n"
"/// You may obtain a copy of the License at\n"
"///\n"
"/// http://www.apache.org/licenses/LICENSE-2.0\n"
"///\n"
"/// Unless required by applicable law or agreed to in writing, software\n"
"/// distributed under the License is distributed on an \"AS IS\" BASIS,\n"
"/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
"/// See the License for the specific language governing permissions and\n"
"/// limitations under the License.\n"
"///\n"
"/// Copyright holder is triAGENS GmbH, Cologne, Germany\n"
"///\n"
"/// @author Jan Steemann\n"
"/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief returns the length of the string in number of characters\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_STRING_LENGTH (value) {\n"
" if (!AQL_IS_STRING(value)) {\n"
" return undefined;\n"
" }\n"
"\n"
" return value.length;\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief returns a substring from the original string\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_STRING_SUBSTRING (value, start, length) {\n"
" if (!AQL_IS_STRING(value)) {\n"
" return undefined;\n"
" }\n"
" if (!AQL_IS_NUMBER(start)) {\n"
" return undefined;\n"
" }\n"
"\n"
" if (length === undefined) {\n"
" return value.substr(start);\n"
" }\n"
"\n"
" if (!AQL_IS_NUMBER(length) || length < 0) {\n"
" return undefined;\n"
" }\n"
"\n"
" return value.substr(start, length);\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief returns the string in upper case\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_STRING_UPPER (value) {\n"
" if (!AQL_IS_STRING(value)) {\n"
" return undefined;\n"
" }\n"
"\n"
" return value.toUpperCase();\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief returns the string in lower case\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_STRING_LOWER (value) {\n"
" if (!AQL_IS_STRING(value)) {\n"
" return undefined;\n"
" }\n"
"\n"
" return value.toLowerCase();\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief returns the position of substring search in value\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_STRING_POSITION (value, search, insensitive) {\n"
" if (!AQL_IS_STRING(value)) {\n"
" return undefined;\n"
" }\n"
"\n"
" var args = \"g\";\n"
" if (insensitive) {\n"
" args += \"i\";\n"
" }\n"
"\n"
" var result = value.search(new RegExp(search), args);\n"
" if (result === -1) {\n"
" return undefined;\n"
" }\n"
"\n"
" return result;\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief returns whether value contains the substring search\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_STRING_CONTAINS (value, search, insensitive) {\n"
" if (!AQL_IS_STRING(value)) {\n"
" return undefined;\n"
" }\n"
"\n"
" var args = \"g\";\n"
" if (insensitive) {\n"
" args += \"i\";\n"
" }\n"
"\n"
" return (value.search(new RegExp(search), args) !== -1);\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief replaces pattern in value with replace\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_STRING_REPLACE (value, pattern, replace, insensitive) {\n"
" if (!AQL_IS_STRING(value)) {\n"
" return undefined;\n"
" }\n"
" if (!AQL_IS_STRING(pattern) || pattern.length == 0) {\n"
" return undefined;\n"
" }\n"
" if (!AQL_IS_STRING(replace)) {\n"
" return undefined;\n"
" }\n"
"\n"
" var args = \"g\";\n"
" if (insensitive) {\n"
" args += \"i\";\n"
" }\n"
"\n"
" return value.replace(new RegExp(pattern, args), replace);\n"
"}\n"
"\n"
;