Baloo

resultiterator.cpp
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(d->results.at(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(d->pos).documentId, 16);
57}
Implements storage for docIds without any associated data Instantiated for:
Definition coding.cpp:11
KIOCORE_EXPORT CopyJob * move(const QList< QUrl > &src, const QUrl &dest, JobFlags flags=DefaultFlags)
QByteArray number(double n, char format, int precision)
QString fromUtf8(QByteArrayView str)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:53:02 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.