MADARA  3.4.1
Iterator.cpp
Go to the documentation of this file.
1 #ifndef _TREE_ITERATOR_CPP
2 #define _TREE_ITERATOR_CPP
3 
4 #ifndef _MADARA_NO_KARL_
5 
6 #include <stdlib.h>
7 #include <algorithm>
8 #include <sstream>
9 
13 
15 
17  const ExpressionTreeIterator& ts)
18  : impl_(ts.impl_)
19 {
20 }
21 
23 
26  : impl_(impl)
27 {
28 }
29 
32 
34 operator*(void)
35 {
36  // return impl_->operator* ();
37  return *(*impl_);
38 }
39 
41 
44 {
45  // return impl_->operator* ();
46  return *(*impl_);
47 }
48 
50 
53 {
54  // return impl_->operator++ ();
55  ++(*impl_);
56  return *this;
57 }
58 
60 
63 {
64  ExpressionTreeIterator temp(impl_->clone());
65  // return impl_->operator++ ();
66  ++(*impl_);
67  return temp;
68 }
69 
71 
73  const ExpressionTreeIterator& rhs)
74 {
75  // return impl_->operator () == rhs.impl_->operator ();
76  return *impl_ == *rhs.impl_;
77 }
78 
80 
82  const ExpressionTreeIterator& rhs)
83 {
84  return !(*this == rhs);
85 }
86 
88 
91  : impl_(ts.impl_)
92 {
93 }
94 
96 
99  : impl_(impl)
100 {
101 }
102 
104 
107 {
108  return *(*impl_);
109 }
110 
112 
115 {
116  ++(*impl_);
117  return *this;
118 }
119 
121 
124 {
125  ExpressionTreeConstIterator temp(impl_.get_ptr()->clone());
126  ++(*impl_);
127  return *this;
128 }
129 
131 
133  const ExpressionTreeConstIterator& rhs)
134 {
135  return impl_->operator==(*rhs.impl_);
136 }
137 
139 
141  const ExpressionTreeConstIterator& rhs)
142 {
143  return !(*this == rhs);
144 }
145 
146 #endif // _MADARA_NO_KARL_
147 
148 #endif /* _TREE_ITERATOR_CPP */
Constant iterator over an expression tree.
Definition: Iterator.h:77
bool operator==(const ExpressionTreeConstIterator &rhs)
Equality operator.
Definition: Iterator.cpp:132
bool operator!=(const ExpressionTreeConstIterator &rhs)
Nonequality operator.
Definition: Iterator.cpp:140
ExpressionTreeConstIterator & operator++(void)
Preincrement operator.
Definition: Iterator.cpp:114
madara::utility::Refcounter< ExpressionTreeIteratorImpl > impl_
Pointer to actual implementation, i.e., the "bridge", which is reference counted to automate memory m...
Definition: Iterator.h:110
const ExpressionTree operator*(void) const
Returns a const reference to the item contained at the current position.
Definition: Iterator.cpp:106
ExpressionTreeConstIterator(const ExpressionTreeConstIterator &ts)
Copy ctor - needed for reference counting.
Definition: Iterator.cpp:89
Implementation of the ExpressionTreeIterator pattern that is used to define the various iterations al...
Definition: IteratorImpl.h:42
Non-const iterator for traversing an expression tree.
Definition: Iterator.h:27
bool operator==(const ExpressionTreeIterator &rhs)
Equality operator.
Definition: Iterator.cpp:72
madara::utility::Refcounter< ExpressionTreeIteratorImpl > impl_
Definition: Iterator.h:64
ExpressionTreeIterator & operator++(void)
Preincrement operator.
Definition: Iterator.cpp:52
bool operator!=(const ExpressionTreeIterator &rhs)
In-equality operator.
Definition: Iterator.cpp:81
ExpressionTree operator*(void)
Dereference operator returns a reference to the item contained at the current position.
Definition: Iterator.cpp:34
ExpressionTreeIterator(const ExpressionTreeIterator &ts)
Copy ctor - needed for reference counting.
Definition: Iterator.cpp:16
Encapsulates a MADARA KaRL expression into an evaluatable tree.