1/*
2 This file is part of the KDE Baloo Project
3 SPDX-FileCopyrightText: 2013 Vishesh Handa <me@vhanda.in>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7
8#include "resultiterator.h"
9#include "result_p.h"
10#include "searchstore.h"
11#include <limits>
12#include <vector>
13#include <utility>
14
15using namespace Baloo;
16
17class Baloo::ResultIteratorPrivate {
18public:
19 ResultIteratorPrivate() = default;
20
21 ~ResultIteratorPrivate() {
22 }
23
24 ResultList results;
25 std::size_t pos = std::numeric_limits<size_t>::max();
26};
27
28ResultIterator::ResultIterator(ResultList&& res)
29 : d(new ResultIteratorPrivate)
30{
31 d->results = res;
32}
33
34ResultIterator::ResultIterator(ResultIterator &&rhs)
35 : d(std::move(rhs.d))
36{
37}
38
39ResultIterator::~ResultIterator() = default;
40
41bool ResultIterator::next()
42{
43 d->pos++; // overflows to 0 on first use
44 return d->pos < d->results.size();
45}
46
47QString ResultIterator::filePath() const
48{
49 Q_ASSERT(d->pos < d->results.size());
50 return QString::fromUtf8(ba: d->results.at(n: d->pos).filePath);
51}
52
53QByteArray ResultIterator::documentId() const
54{
55 Q_ASSERT(d->pos < d->results.size());
56 return QByteArray::number(d->results.at(n: d->pos).documentId, base: 16);
57}
58

source code of baloo/src/lib/resultiterator.cpp