15typedef ResultSet::const_iterator iterator;
19class ResultSet_IteratorPrivate
22 ResultSet_IteratorPrivate(
const ResultSet *resultSet,
int currentRow = -1)
23 : resultSet(resultSet)
24 , currentRow(currentRow)
29 const ResultSet *resultSet;
31 std::optional<ResultSet::Result> currentValue;
33 inline void moveTo(
int row)
35 if (row == currentRow)
41 inline void moveBy(
int row)
43 moveTo(currentRow + row);
48 if (!resultSet || !resultSet->d->query.seek(currentRow)) {
52 auto value = resultSet->d->currentResult();
53 currentValue = std::move(value);
57 friend void swap(ResultSet_IteratorPrivate &left, ResultSet_IteratorPrivate &right)
59 std::swap(
left.resultSet,
right.resultSet);
60 std::swap(
left.currentRow,
right.currentRow);
61 std::swap(
left.currentValue,
right.currentValue);
64 bool operator==(
const ResultSet_IteratorPrivate &other)
const
66 bool thisValid = currentValue.has_value();
67 bool otherValid = other.currentValue.has_value();
72 thisValid != otherValid ? false :
79 resultSet == other.resultSet && currentRow == other.currentRow;
84 return currentValue.has_value();
87 static bool sameSource(
const ResultSet_IteratorPrivate &left,
const ResultSet_IteratorPrivate &right)
89 return left.resultSet ==
right.resultSet &&
left.resultSet !=
nullptr;
93iterator::const_iterator(
const ResultSet *resultSet,
int currentRow)
94 : d(new ResultSet_IteratorPrivate(resultSet, currentRow))
98iterator::const_iterator()
99 : d(new ResultSet_IteratorPrivate(nullptr, -1))
103iterator::const_iterator(
const const_iterator &source)
104 : d(new ResultSet_IteratorPrivate(source.d->resultSet, source.d->currentRow))
108bool iterator::isSourceValid()
const
110 return d->resultSet !=
nullptr;
113iterator &iterator::operator=(
const const_iterator &source)
115 const_iterator temp(source);
120iterator::~const_iterator()
125iterator::reference iterator::operator*()
const
127 return d->currentValue.value();
130iterator::pointer iterator::operator->()
const
132 return &d->currentValue.value();
136iterator &iterator::operator++()
145iterator iterator::operator++(
int)
147 return const_iterator(d->resultSet, d->currentRow + 1);
151iterator &iterator::operator--()
160iterator iterator::operator--(
int)
162 return const_iterator(d->resultSet, d->currentRow - 1);
167 return const_iterator(
this, d->database ? 0 : -1);
172 return const_iterator(
this, -1);
175iterator iterator::operator+(iterator::difference_type n)
const
177 return const_iterator(d->resultSet, d->currentRow + n);
180iterator &iterator::operator+=(iterator::difference_type n)
186iterator iterator::operator-(iterator::difference_type n)
const
188 return const_iterator(d->resultSet, d->currentRow - n);
191iterator &iterator::operator-=(iterator::difference_type n)
197iterator::reference iterator::operator[](iterator::difference_type n)
const
212bool operator==(
const iterator &left,
const iterator &right)
217bool operator!=(
const iterator &left,
const iterator &right)
222#define COMPARATOR_IMPL(OP) \
223 bool operator OP(const iterator &left, const iterator &right) \
225 return ResultSet_IteratorPrivate::sameSource(*left.d, *right.d) ? left.d->currentRow OP right.d->currentRow : false; \
233#undef COMPARATOR_IMPL
235iterator::difference_type operator-(
const iterator &left,
const iterator &right)
237 return ResultSet_IteratorPrivate::sameSource(*
left.d, *
right.d) ?
left.d->currentRow -
right.d->currentRow : 0;
Class that can query the KActivities usage tracking mechanism for resources.
const_iterator begin() const
const_iterator end() const
Provides enums and strucss to use.for building queries with Query.
KIOCORE_EXPORT bool operator!=(const UDSEntry &entry, const UDSEntry &other)
KIOCORE_EXPORT bool operator==(const UDSEntry &entry, const UDSEntry &other)
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)