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
leftedgeiterator.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 LEFTEDGEITERATOR_H
29 #define LEFTEDGEITERATOR_H
30 #include "src/ast/expressionnode.h"
32 #include <iterator>
33 
34 namespace jmespath { namespace parser {
35 
40 class LeftEdgeIterator : public std::iterator<std::forward_iterator_tag,
41  ast::ExpressionNode>
42 {
43 public:
49  : m_node(nullptr)
50  {
51  }
57  : m_node(&node)
58  {
59  }
64  reference operator*() const
65  {
66  return *m_node;
67  }
72  pointer operator->() const
73  {
74  return m_node;
75  }
82  bool operator!=(const LeftEdgeIterator& other) const
83  {
84  return m_node != other.m_node;
85  }
92  {
94  return *this;
95  }
102  {
103  auto tempIterator = *this;
105  return tempIterator;
106  }
107 
108 private:
117 };
118 }} // namespace jmespath::parser
119 #endif // LEFTEDGEITERATOR_H
The LeftEdgeIterator class is a forward iterator which can be used to iterate over the ExpressionNode...
Definition: leftedgeiterator.h:40
LeftEdgeIterator()
Constructs an empty LeftEdgeIterator object which can be used as an end iterator. ...
Definition: leftedgeiterator.h:48
LeftEdgeIterator operator++(int)
Advances the iterator to the next node on the left edge of the AST.
Definition: leftedgeiterator.h:101
ast::ExpressionNode * m_node
Pointer to the current node object.
Definition: leftedgeiterator.h:112
pointer operator->() const
Returns a pointer to the current node.
Definition: leftedgeiterator.h:72
The LeftChildExtractor class is a functor that extracts the child expression node from the given node...
Definition: leftchildextractor.h:40
LeftChildExtractor m_childExtractor
Functor used for extracting the left child of the given node.
Definition: leftedgeiterator.h:116
reference operator*() const
Returns a reference to the current node.
Definition: leftedgeiterator.h:64
bool operator!=(const LeftEdgeIterator &other) const
Checks whether this iterator doesn't equals to the other.
Definition: leftedgeiterator.h:82
The ExpressionNode class represents a JMESPath expression.
Definition: expressionnode.h:56
LeftEdgeIterator & operator++()
Advances the iterator to the next node on the left edge of the AST.
Definition: leftedgeiterator.h:91
LeftEdgeIterator(ast::ExpressionNode &node)
Constructs a LeftEdgeIterator which points to the given node.
Definition: leftedgeiterator.h:56