1
0
Fork 0
arangodb/RestServer/js-shell.h

255 lines
9.9 KiB
C

static string JS_shell =
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief JavaScript server functions\n"
"///\n"
"/// @file\n"
"///\n"
"/// DISCLAIMER\n"
"///\n"
"/// Copyright by triAGENS GmbH - All rights reserved.\n"
"///\n"
"/// The Programs (which include both the software and documentation)\n"
"/// contain proprietary information of triAGENS GmbH; they are\n"
"/// provided under a license agreement containing restrictions on use and\n"
"/// disclosure and are also protected by copyright, patent and other\n"
"/// intellectual and industrial property laws. Reverse engineering,\n"
"/// disassembly or decompilation of the Programs, except to the extent\n"
"/// required to obtain interoperability with other independently created\n"
"/// software or as specified by law, is prohibited.\n"
"///\n"
"/// The Programs are not intended for use in any nuclear, aviation, mass\n"
"/// transit, medical, or other inherently dangerous applications. It shall\n"
"/// be the licensee's responsibility to take all appropriate fail-safe,\n"
"/// backup, redundancy, and other measures to ensure the safe use of such\n"
"/// applications if the Programs are used for such purposes, and triAGENS\n"
"/// GmbH disclaims liability for any damages caused by such use of\n"
"/// the Programs.\n"
"///\n"
"/// This software is the confidential and proprietary information of\n"
"/// triAGENS GmbH. You shall not disclose such confidential and\n"
"/// proprietary information and shall use it only in accordance with the\n"
"/// terms of the license agreement you entered into with triAGENS GmbH.\n"
"///\n"
"/// Copyright holder is triAGENS GmbH, Cologne, Germany\n"
"///\n"
"/// @author Dr. Frank Celler\n"
"/// @author Copyright 2011, triAGENS GmbH, Cologne, Germany\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"// -----------------------------------------------------------------------------\n"
"// --SECTION-- printing\n"
"// -----------------------------------------------------------------------------\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @addtogroup V8Shell\n"
"/// @{\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief prints objects to standard output\n"
"///\n"
"/// @FUN{print(@FA{arg1}, @FA{arg2}, @FA{arg3}, ...)}\n"
"///\n"
"/// Only available in shell mode.\n"
"///\n"
"/// Prints the arguments. If an argument is an object having a\n"
"/// function @FN{PRINT}, then this function is called. Otherwise @FN{toJson} is\n"
"/// used. A final newline is printed\n"
"///\n"
"/// @verbinclude fluent40\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function print () {\n"
" for (var i = 0; i < arguments.length; ++i) {\n"
" if (0 < i) {\n"
" output(\" \");\n"
" }\n"
"\n"
" PRINT(arguments[i]);\n"
" }\n"
"\n"
" output(\"\\n\");\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief prints objects to standard output without a new-line\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function PRINT (value) {\n"
" if (value instanceof Object) {\n"
" if ('PRINT' in value) {\n"
" value.PRINT();\n"
" }\n"
" else if (value.prototype == undefined) {\n"
" PRINT_OBJECT(value);\n"
" }\n"
" else if ('toString' in value) {\n"
" output(value.toString());\n"
" }\n"
" else {\n"
" PRINT_OBJECT(value);\n"
" }\n"
" }\n"
" else if (value === undefined) {\n"
" output(\"undefined\");\n"
" }\n"
" else {\n"
" output(\"\" + value);\n"
" }\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @}\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"// -----------------------------------------------------------------------------\n"
"// --SECTION-- Array\n"
"// -----------------------------------------------------------------------------\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @addtogroup V8Shell\n"
"/// @{\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief JSON representation of an array\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"Array.prototype.PRINT = function() {\n"
" if (this.length == 0) {\n"
" output(\"[ ]\");\n"
" }\n"
" else {\n"
" var sep = \" \";\n"
"\n"
" output(\"[\");\n"
"\n"
" for (var i = 0; i < this.length; i++) {\n"
" output(sep);\n"
" PRINT(this[i]);\n"
" sep = \", \";\n"
" }\n"
"\n"
" output(\" ]\");\n"
" }\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @}\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"// -----------------------------------------------------------------------------\n"
"// --SECTION-- Function\n"
"// -----------------------------------------------------------------------------\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @addtogroup V8Shell\n"
"/// @{\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief prints a function\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"Function.prototype.PRINT = function() {\n"
" output(this.toString());\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @}\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"// -----------------------------------------------------------------------------\n"
"// --SECTION-- Object\n"
"// -----------------------------------------------------------------------------\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @addtogroup V8Shell\n"
"/// @{\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief string representation of an object\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function PRINT_OBJECT (object) {\n"
" var sep = \" \";\n"
"\n"
" output(\"{\");\n"
"\n"
" for (var k in object) {\n"
" if (object.hasOwnProperty(k)) {\n"
" var val = object[k];\n"
"\n"
" output(sep, k, \" : \");\n"
" PRINT(val);\n"
" sep = \", \";\n"
" }\n"
" }\n"
"\n"
" output(\" }\");\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @}\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"// -----------------------------------------------------------------------------\n"
"// --SECTION-- AvocadoQuery\n"
"// -----------------------------------------------------------------------------\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @addtogroup V8Shell\n"
"/// @{\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief global variable holding the current printed query\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"var it = undefined;\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief number of results to print\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"var queryLimit = 20;\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief prints a query\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"AvocadoQuery.prototype.PRINT = function() {\n"
" if (this instanceof AvocadoQuery) {\n"
" var count = 0;\n"
"\n"
" try {\n"
" while (this.hasNext() && count++ < queryLimit) {\n"
" output(JSON.stringify(this.next()), \"\\n\");\n"
" }\n"
"\n"
" if (this.hasNext()) {\n"
" output(\"...more results...\");\n"
" }\n"
"\n"
" it = this;\n"
" }\n"
" catch (e) {\n"
" output(\"encountered error while printing: \" + e);\n"
" }\n"
" }\n"
" else {\n"
" output(this.toString());\n"
" }\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @}\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"// Local Variables:\n"
"// mode: outline-minor\n"
"// outline-regexp: \"^\\\\(/// @brief\\\\|/// @addtogroup\\\\|// --SECTION--\\\\)\"\n"
"// End:\n"
;