drogon
C++14/17-based HTTP application framework
Loading...
Searching...
No Matches
RowIterator.h
1
14
15// Taken from libpqxx and modified.
16// The license for libpqxx can be found in the COPYING file.
17
18#pragma once
19
20#include <drogon/orm/Field.h>
21#include <drogon/orm/Row.h>
22
23namespace drogon
24{
25namespace orm
26{
27class ConstRowIterator : protected Field
28{
29 public:
30 using pointer = const Field *;
31 using reference = const Field &;
32 using value_type = const Field;
33 using size_type = Row::SizeType;
34 using difference_type = Row::DifferenceType;
35 using iterator_category = std::random_access_iterator_tag;
36
37 // ConstRowIterator(const Field &t) noexcept : Field(t) {}
38
39 pointer operator->()
40 {
41 return this;
42 }
43
44 reference operator*()
45 {
46 return *this;
47 }
48
49 ConstRowIterator operator++(int);
50
51 ConstRowIterator &operator++()
52 {
53 ++column_;
54 return *this;
55 }
56
57 ConstRowIterator operator--(int);
58
59 ConstRowIterator &operator--()
60 {
61 --column_;
62 return *this;
63 }
64
65 ConstRowIterator &operator+=(difference_type i)
66 {
67 column_ += i;
68 return *this;
69 }
70
71 ConstRowIterator &operator-=(difference_type i)
72 {
73 column_ -= i;
74 return *this;
75 }
76
77 bool operator==(const ConstRowIterator &other) const
78 {
79 return column_ == other.column_;
80 }
81
82 bool operator!=(const ConstRowIterator &other) const
83 {
84 return column_ != other.column_;
85 }
86
87 bool operator>(const ConstRowIterator &other) const
88 {
89 return column_ > other.column_;
90 }
91
92 bool operator<(const ConstRowIterator &other) const
93 {
94 return column_ < other.column_;
95 }
96
97 bool operator>=(const ConstRowIterator &other) const
98 {
99 return column_ >= other.column_;
100 }
101
102 bool operator<=(const ConstRowIterator &other) const
103 {
104 return column_ <= other.column_;
105 }
106
107 private:
108 friend class Row;
109
110 ConstRowIterator(const Row &r, SizeType column) noexcept : Field(r, column)
111 {
112 }
113};
114
115class ConstReverseRowIterator : private ConstRowIterator
116{
117 public:
118 using super = ConstRowIterator;
119 using iterator_type = ConstRowIterator;
120 using iterator_type::difference_type;
121 using iterator_type::iterator_category;
122 using iterator_type::pointer;
123 using iterator_type::reference;
124
125 // using iterator_type::value_type;
126
127 ConstReverseRowIterator(const ConstReverseRowIterator &rhs)
128 : ConstRowIterator(rhs)
129 {
130 }
131
132 explicit ConstReverseRowIterator(const ConstRowIterator &rhs)
133 : ConstRowIterator(rhs)
134 {
135 super::operator--();
136 }
137
138 ConstRowIterator base() const noexcept;
139
140 using iterator_type::operator->;
141 using iterator_type::operator*;
142
143 ConstReverseRowIterator operator++(int);
144
145 ConstReverseRowIterator &operator++()
146 {
147 iterator_type::operator--();
148 return *this;
149 }
150
151 ConstReverseRowIterator operator--(int);
152
153 ConstReverseRowIterator &operator--()
154 {
155 iterator_type::operator++();
156 return *this;
157 }
158
159 ConstReverseRowIterator &operator+=(difference_type i)
160 {
161 iterator_type::operator-=(i);
162 return *this;
163 }
164
165 ConstReverseRowIterator &operator-=(difference_type i)
166 {
167 iterator_type::operator+=(i);
168 return *this;
169 }
170
171 bool operator==(const ConstReverseRowIterator &other) const
172 {
173 return column_ == other.column_;
174 }
175
176 bool operator!=(const ConstReverseRowIterator &other) const
177 {
178 return column_ != other.column_;
179 }
180
181 bool operator>(const ConstReverseRowIterator &other) const
182 {
183 return column_ < other.column_;
184 }
185
186 bool operator<(const ConstReverseRowIterator &other) const
187 {
188 return column_ > other.column_;
189 }
190
191 bool operator>=(const ConstReverseRowIterator &other) const
192 {
193 return column_ <= other.column_;
194 }
195
196 bool operator<=(const ConstReverseRowIterator &other) const
197 {
198 return column_ >= other.column_;
199 }
200};
201
202} // namespace orm
203} // namespace drogon
long column_
Definition Field.h:156
Drogon Test is a minimal effort test framework developed because the major C++ test frameworks doesn'...
Definition Attribute.h:23