jmespath.cpp
C++ implementation of JMESPath, a query language for JSON http://jmespath.org
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
functionexpressionnode.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Author: Róbert Márki <gsmiko@gmail.com>
4 ** Copyright (c) 2016 Róbert Márki
5 **
6 ** This file is part of the jmespath.cpp project which is distributed under
7 ** the MIT License (MIT).
8 **
9 ** Permission is hereby granted, free of charge, to any person obtaining a copy
10 ** of this software and associated documentation files (the "Software"), to
11 ** deal in the Software without restriction, including without limitation the
12 ** rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
13 ** sell copies of the Software, and to permit persons to whom the Software is
14 ** furnished to do so, subject to the following conditions:
15 **
16 ** The above copyright notice and this permission notice shall be included in
17 ** all copies or substantial portions of the Software.
18 **
19 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 ** FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 ** DEALINGS IN THE SOFTWARE.
26 **
27 ****************************************************************************/
28 #ifndef FUNCTIONEXPRESSIONNODE_H
29 #define FUNCTIONEXPRESSIONNODE_H
30 #include "src/ast/abstractnode.h"
31 #include "jmespath/types.h"
32 #include <vector>
33 #include <initializer_list>
34 #include <boost/variant.hpp>
35 #include <boost/fusion/include/adapt_struct.hpp>
36 
37 namespace jmespath { namespace ast {
38 
39 class ExpressionNode;
40 class ExpressionArgumentNode;
46 {
47 public:
48  using ArgumentType = boost::variant<boost::blank,
49  boost::recursive_wrapper<ExpressionNode>,
50  boost::recursive_wrapper<ExpressionArgumentNode> >;
61  FunctionExpressionNode(const String& name,
62  const std::initializer_list<ArgumentType>& argumentList = {});
68  void accept(interpreter::AbstractVisitor* visitor) const override;
75  bool operator==(const FunctionExpressionNode& other) const;
83  std::vector<ArgumentType> arguments;
84 };
85 }} // namespace jmespath::ast
86 
87 BOOST_FUSION_ADAPT_STRUCT(
89  (jmespath::String, functionName)
90  (std::vector<jmespath::ast::FunctionExpressionNode::ArgumentType>,
91  arguments)
92 )
93 #endif // FUNCTIONEXPRESSIONNODE_H
bool operator==(const FunctionExpressionNode &other) const
Equality compares this node to the other.
Definition: functionexpressionnode.cpp:52
std::vector< ArgumentType > arguments
The function expressions's arguments.
Definition: functionexpressionnode.h:83
boost::variant< boost::blank, boost::recursive_wrapper< ExpressionNode >, boost::recursive_wrapper< ExpressionArgumentNode > > ArgumentType
Definition: functionexpressionnode.h:50
void accept(interpreter::AbstractVisitor *visitor) const override
Calls the visit method of the given visitor with the dynamic type of the node.
Definition: functionexpressionnode.cpp:47
std::basic_string< Char > String
UTF-8 encoded string type.
Definition: types.h:44
FunctionExpressionNode()
Constructs an empty FunctionExpressionNode object.
Definition: functionexpressionnode.cpp:34
The AbstractVisitor class is an interface which defines the member functions required to visit every ...
Definition: abstractvisitor.h:71
String functionName
The function's name.
Definition: functionexpressionnode.h:79
The AbstractNode class is the common interface class for all AST node types.
Definition: abstractnode.h:45
The FunctionExpressionNode class represents a JMESPath function expression.
Definition: functionexpressionnode.h:45