//////////////////////////////////////////////////////////////////////////////// /// @brief V8 utility functions /// /// @file /// /// DISCLAIMER /// /// Copyright 2010-2011 triagens GmbH, Cologne, Germany /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. /// You may obtain a copy of the License at /// /// http://www.apache.org/licenses/LICENSE-2.0 /// /// Unless required by applicable law or agreed to in writing, software /// distributed under the License is distributed on an "AS IS" BASIS, /// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. /// See the License for the specific language governing permissions and /// limitations under the License. /// /// Copyright holder is triAGENS GmbH, Cologne, Germany /// /// @author Dr. Frank Celler /// @author Copyright 2011, triagens GmbH, Cologne, Germany //////////////////////////////////////////////////////////////////////////////// #ifndef TRIAGENS_DURHAM_V8_V8_UTILS_H #define TRIAGENS_DURHAM_V8_V8_UTILS_H 1 #include #include #include #include // ----------------------------------------------------------------------------- // --SECTION-- class V8LineEditor // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // --SECTION-- public functions // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup V8Shell /// @{ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @brief line editor //////////////////////////////////////////////////////////////////////////////// class V8LineEditor { public: static const int MAX_HISTORY_ENTRIES = 1000; static const char* HISTORY_FILENAME; public: bool open (); char* prompt (char const* prompt); void addHistory (const char* string); }; //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- CONVERSION FUNCTIONS // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // --SECTION-- public functions // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup V8Utils /// @{ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @brief converts a TRI_json_t into a V8 object //////////////////////////////////////////////////////////////////////////////// v8::Handle TRI_ObjectJson (TRI_json_t const*); //////////////////////////////////////////////////////////////////////////////// /// @brief converts a TRI_shaped_json_t into a V8 object //////////////////////////////////////////////////////////////////////////////// v8::Handle TRI_ObjectRSEntry (TRI_doc_collection_t* collection, TRI_shaper_t* shaper, TRI_rs_entry_t const* entry); //////////////////////////////////////////////////////////////////////////////// /// @brief converts a TRI_result_set_t into a V8 array //////////////////////////////////////////////////////////////////////////////// v8::Handle TRI_ArrayResultSet (TRI_result_set_t* rs); //////////////////////////////////////////////////////////////////////////////// /// @brief converts an V8 object to a TRI_shaped_json_t //////////////////////////////////////////////////////////////////////////////// TRI_shaped_json_t* TRI_ShapedJsonV8Object (v8::Handle object, TRI_shaper_t*); //////////////////////////////////////////////////////////////////////////////// /// @brief converts an V8 object to a string //////////////////////////////////////////////////////////////////////////////// std::string TRI_ObjectToString (v8::Handle value); //////////////////////////////////////////////////////////////////////////////// /// @brief converts an V8 object to a character //////////////////////////////////////////////////////////////////////////////// char TRI_ObjectToCharacter (v8::Handle value, bool& error); //////////////////////////////////////////////////////////////////////////////// /// @brief converts an V8 object to a double //////////////////////////////////////////////////////////////////////////////// double TRI_ObjectToDouble (v8::Handle value); //////////////////////////////////////////////////////////////////////////////// /// @brief converts an V8 object to a double //////////////////////////////////////////////////////////////////////////////// double TRI_ObjectToDouble (v8::Handle value, bool& error); //////////////////////////////////////////////////////////////////////////////// /// @brief converts an V8 object to a boolean //////////////////////////////////////////////////////////////////////////////// bool TRI_ObjectToBoolean (v8::Handle value); //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- GENERAL // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // --SECTION-- public functions // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup V8Utils /// @{ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @brief adds attributes to array //////////////////////////////////////////////////////////////////////////////// void TRI_AugmentObject (v8::Handle value, TRI_json_t const* json); //////////////////////////////////////////////////////////////////////////////// /// @brief reports an exception //////////////////////////////////////////////////////////////////////////////// std::string TRI_ReportV8Exception (v8::TryCatch* tryCatch); //////////////////////////////////////////////////////////////////////////////// /// @brief prints an exception and stacktrace //////////////////////////////////////////////////////////////////////////////// void TRI_PrintV8Exception (v8::TryCatch* tryCatch); //////////////////////////////////////////////////////////////////////////////// /// @brief reads a file into the current context //////////////////////////////////////////////////////////////////////////////// bool TRI_LoadJavaScriptFile (v8::Handle context, char const* filename); //////////////////////////////////////////////////////////////////////////////// /// @brief reads all files from a directory into the current context //////////////////////////////////////////////////////////////////////////////// bool TRI_LoadJavaScriptDirectory (v8::Handle context, char const* path); //////////////////////////////////////////////////////////////////////////////// /// @brief executes a string within a V8 context //////////////////////////////////////////////////////////////////////////////// bool TRI_ExecuteStringVocBase (v8::Handle context, v8::Handle source, v8::Handle name, bool printResult, bool reportExceptions); //////////////////////////////////////////////////////////////////////////////// /// @brief stores the V8 utils function inside the global variable //////////////////////////////////////////////////////////////////////////////// void TRI_InitV8Utils (v8::Handle context); //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// #endif // Local Variables: // mode: outline-minor // outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\)" // End: