mirror of https://gitee.com/bigwinds/arangodb
166 lines
5.5 KiB
C
166 lines
5.5 KiB
C
static string JS_server_aql_functions_numeric =
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief AQL query language numeric 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 integer closest to value, not greater than value\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"function AQL_NUMBER_FLOOR (value) {\n"
|
|
" if (!AQL_IS_NUMBER(value)) {\n"
|
|
" return undefined;\n"
|
|
" }\n"
|
|
" \n"
|
|
" return Math.floor(value);\n"
|
|
"}\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief integer closest to value and not less than value\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"function AQL_NUMBER_CEIL (value) {\n"
|
|
" if (!AQL_IS_NUMBER(value)) {\n"
|
|
" return undefined;\n"
|
|
" }\n"
|
|
" \n"
|
|
" return Math.ceil(value);\n"
|
|
"}\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief integer closest to value \n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"function AQL_NUMBER_ROUND (value) {\n"
|
|
" if (!AQL_IS_NUMBER(value)) {\n"
|
|
" return undefined;\n"
|
|
" }\n"
|
|
" \n"
|
|
" return Math.round(value);\n"
|
|
"}\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief absolute value\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"function AQL_NUMBER_ABS (value) {\n"
|
|
" if (!AQL_IS_NUMBER(value)) {\n"
|
|
" return undefined;\n"
|
|
" }\n"
|
|
" \n"
|
|
" return Math.abs(value);\n"
|
|
"}\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief minimum of all values, ignores undefined\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"function AQL_NUMBER_MIN_WU () {\n"
|
|
" var result = undefined;\n"
|
|
"\n"
|
|
" for (var i in arguments) {\n"
|
|
" var value = arguments[i];\n"
|
|
" if (!AQL_IS_NUMBER(value)) {\n"
|
|
" continue;\n"
|
|
" }\n"
|
|
" if (result === undefined || value < result) {\n"
|
|
" result = value;\n"
|
|
" }\n"
|
|
" }\n"
|
|
"\n"
|
|
" return result;\n"
|
|
"}\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief maximum of all values, ignores undefined\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"function AQL_NUMBER_MAX_WU () {\n"
|
|
" var result = undefined;\n"
|
|
"\n"
|
|
" for (var i in arguments) {\n"
|
|
" var value = arguments[i];\n"
|
|
" if (!AQL_IS_NUMBER(value)) {\n"
|
|
" continue;\n"
|
|
" }\n"
|
|
" if (result === undefined || value > result) {\n"
|
|
" result = value;\n"
|
|
" }\n"
|
|
" }\n"
|
|
"\n"
|
|
" return result;\n"
|
|
"}\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief minimum of all values\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"function AQL_NUMBER_MIN () {\n"
|
|
" var result = undefined;\n"
|
|
"\n"
|
|
" for (var i in arguments) {\n"
|
|
" var value = arguments[i];\n"
|
|
" if (!AQL_IS_NUMBER(value)) {\n"
|
|
" return undefined;\n"
|
|
" }\n"
|
|
" if (result === undefined || value < result) {\n"
|
|
" result = value;\n"
|
|
" }\n"
|
|
" }\n"
|
|
"\n"
|
|
" return result;\n"
|
|
"}\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief maximum of all values\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"function AQL_NUMBER_MAX () {\n"
|
|
" var result = undefined;\n"
|
|
"\n"
|
|
" for (var i in arguments) {\n"
|
|
" var value = arguments[i];\n"
|
|
" if (!AQL_IS_NUMBER(value)) {\n"
|
|
" return undefined;\n"
|
|
" }\n"
|
|
" if (result === undefined || value > result) {\n"
|
|
" result = value;\n"
|
|
" }\n"
|
|
" }\n"
|
|
"\n"
|
|
" return result;\n"
|
|
"}\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief a random value between 0 and 1\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"function AQL_NUMBER_RAND () {\n"
|
|
" return Math.random();\n"
|
|
"}\n"
|
|
"\n"
|
|
;
|