mirror of https://gitee.com/bigwinds/arangodb
176 lines
7.5 KiB
C++
176 lines
7.5 KiB
C++
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief V8 utility functions
|
|
///
|
|
/// @file
|
|
///
|
|
/// DISCLAIMER
|
|
///
|
|
/// Copyright 2004-2012 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-2012, triAGENS GmbH, Cologne, Germany
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef TRIAGENS_V8_V8_CONV_H
|
|
#define TRIAGENS_V8_V8_CONV_H 1
|
|
|
|
#include "V8/v8-globals.h"
|
|
|
|
#include "BasicsC/json.h"
|
|
#include "V8/v8-c-utils.h"
|
|
#include "VocBase/simple-collection.h"
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// --SECTION-- CONVERSION FUNCTIONS
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// --SECTION-- public functions
|
|
// -----------------------------------------------------------------------------
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @addtogroup V8Conversions
|
|
/// @{
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief pushes the names of an associative char* array into a V8 array
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
v8::Handle<v8::Array> TRI_ArrayAssociativePointer (const TRI_associative_pointer_t* const);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief converts identifier into a object reference
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
v8::Handle<v8::Value> TRI_ObjectReference (TRI_voc_cid_t, TRI_voc_did_t);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief extratcs identifiers from a object reference
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
bool TRI_IdentifiersObjectReference (v8::Handle<v8::Value>, TRI_voc_cid_t&, TRI_voc_did_t&);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief converts a TRI_json_t into a V8 object
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
v8::Handle<v8::Value> TRI_ObjectJson (TRI_json_t const*);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief convert V8 object to TRI_json_t
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
TRI_json_t* TRI_JsonObject (v8::Handle<v8::Value> parameter);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief converts a TRI_shaped_json_t into a V8 object
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
v8::Handle<v8::Value> TRI_JsonShapeData (TRI_shaper_t*,
|
|
TRI_shape_t const*,
|
|
char const* data,
|
|
size_t size);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief converts an V8 object to a TRI_shaped_json_t
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
TRI_shaped_json_t* TRI_ShapedJsonV8Object (v8::Handle<v8::Value>, TRI_shaper_t*);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief convert a V8 value to a json_t value
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
TRI_json_t* TRI_ObjectToJson (v8::Handle<v8::Value>);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief converts an V8 object to a string
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
std::string TRI_ObjectToString (v8::Handle<v8::Value>);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief converts an V8 object to a character
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
char TRI_ObjectToCharacter (v8::Handle<v8::Value>, bool& error);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief converts an V8 object to an int64_t
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
int64_t TRI_ObjectToInt64 (v8::Handle<v8::Value>);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief converts an V8 object to a uint64_t
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
uint64_t TRI_ObjectToUInt64 (v8::Handle<v8::Value>);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief converts an V8 object to a double
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
double TRI_ObjectToDouble (v8::Handle<v8::Value>);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief converts an V8 object to a double with error handling
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
double TRI_ObjectToDouble (v8::Handle<v8::Value>, bool& error);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief converts an V8 object to a boolean
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
bool TRI_ObjectToBoolean (v8::Handle<v8::Value>);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @}
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// --SECTION-- GENERAL
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// --SECTION-- public functions
|
|
// -----------------------------------------------------------------------------
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @addtogroup V8Conversions
|
|
/// @{
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief initialises the V8 conversion module
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
void TRI_InitV8Conversions (v8::Handle<v8::Context>);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @}
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#endif
|
|
|
|
// Local Variables:
|
|
// mode: outline-minor
|
|
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
|
|
// End:
|