mirror of https://gitee.com/bigwinds/arangodb
added class Expression
This commit is contained in:
parent
60d493c56c
commit
65386d8529
|
@ -64,7 +64,7 @@ AstNode::~AstNode () {
|
|||
/// the caller is responsible for freeing the JSON later
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_json_t* AstNode::toJson (TRI_memory_zone_t* zone) {
|
||||
TRI_json_t* AstNode::toJson (TRI_memory_zone_t* zone) const {
|
||||
TRI_json_t* node = TRI_CreateArrayJson(zone);
|
||||
|
||||
if (node == nullptr) {
|
||||
|
@ -151,7 +151,7 @@ TRI_json_t* AstNode::toJson (TRI_memory_zone_t* zone) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void AstNode::toJson (TRI_json_t* json,
|
||||
TRI_memory_zone_t* zone) {
|
||||
TRI_memory_zone_t* zone) const {
|
||||
TRI_ASSERT(TRI_IsListJson(json));
|
||||
|
||||
TRI_json_t* node = toJson(zone);
|
||||
|
|
|
@ -165,7 +165,7 @@ namespace triagens {
|
|||
/// the caller is responsible for freeing the JSON later
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct TRI_json_s* toJson (TRI_memory_zone_t*);
|
||||
struct TRI_json_s* toJson (TRI_memory_zone_t*) const;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief adds a JSON representation of the node to the JSON list specified
|
||||
|
@ -173,7 +173,7 @@ namespace triagens {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void toJson (TRI_json_t*,
|
||||
TRI_memory_zone_t*);
|
||||
TRI_memory_zone_t*) const;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief whether or not a value node is of numeric type
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Aql, expression
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2014 ArangoDB GmbH, Cologne, Germany
|
||||
/// Copyright 2004-2014 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 ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Jan Steemann
|
||||
/// @author Copyright 2014, ArangoDB GmbH, Cologne, Germany
|
||||
/// @author Copyright 2012-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Aql/Expression.h"
|
||||
#include "Aql/Types.h"
|
||||
#include "Utils/Exception.h"
|
||||
|
||||
using namespace triagens::aql;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- constructors / destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief create the expression
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Expression::Expression (AstNode const* node)
|
||||
: _node(node) {
|
||||
|
||||
TRI_ASSERT(node != nullptr);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destroy the expression
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Expression::~Expression () {
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief execute the expression
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AqlValue* Expression::execute (AqlItem* item) {
|
||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_NOT_IMPLEMENTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}"
|
||||
// End:
|
|
@ -0,0 +1,125 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief AQL, expression
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2014 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 Max Neunhoeffer
|
||||
/// @author Copyright 2014, triagens GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGODB_AQL_EXPRESSION_H
|
||||
#define ARANGODB_AQL_EXPRESSION_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Aql/AstNode.h"
|
||||
#include "Basics/JsonHelper.h"
|
||||
|
||||
namespace triagens {
|
||||
namespace aql {
|
||||
|
||||
struct AqlItem;
|
||||
struct AqlValue;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief AqlExpression, used in execution plans and execution blocks
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class Expression {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- constructors / destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructor, using an AST start node
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Expression (AstNode const*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destructor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
~Expression ();
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get the underlying AST node
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline AstNode const* node () {
|
||||
return _node;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief clone the expression, needed to clone execution plans
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Expression* clone () {
|
||||
// We do not need to copy the _ast, since it is managed by the
|
||||
// query object and the memory management of the ASTs
|
||||
return new Expression(_node);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief return a Json representation of the expression
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
triagens::basics::Json toJson (TRI_memory_zone_t* zone) const {
|
||||
return triagens::basics::Json(zone, _node->toJson(zone));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief execute the expression
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AqlValue* execute (AqlItem*);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- private variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
private:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief the abstract syntax tree
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// do we need a (possibly empty) subquery entry here?
|
||||
AstNode const* _node;
|
||||
|
||||
};
|
||||
|
||||
} // namespace triagens::aql
|
||||
} // namespace triagens
|
||||
|
||||
#endif
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
|
||||
// End:
|
||||
|
|
@ -62,6 +62,7 @@ add_executable(
|
|||
Aql/BindParameters.cpp
|
||||
Aql/ExecutionBlock.cpp
|
||||
Aql/ExecutionPlan.cpp
|
||||
Aql/Expression.cpp
|
||||
Aql/grammar.cpp
|
||||
Aql/Parser.cpp
|
||||
Aql/PlanGenerator.cpp
|
||||
|
|
|
@ -43,6 +43,7 @@ arangod_libarangod_a_SOURCES = \
|
|||
arangod/Aql/BindParameters.cpp \
|
||||
arangod/Aql/ExecutionBlock.cpp \
|
||||
arangod/Aql/ExecutionPlan.cpp \
|
||||
arangod/Aql/Expression.cpp \
|
||||
arangod/Aql/grammar.cpp \
|
||||
arangod/Aql/Parser.cpp \
|
||||
arangod/Aql/PlanGenerator.cpp \
|
||||
|
|
Loading…
Reference in New Issue