summaryrefslogtreecommitdiffstats
path: root/common/resultset.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-05-25 23:14:57 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-05-25 23:14:57 +0200
commit3601ee575f833bf204540f4fac41d87a0d977a79 (patch)
tree740e62969ba7cd6384161b40d499fd63b2029f5f /common/resultset.h
parent9e3bcbdd45ec05d0a1fd423e6219ac6443feed1c (diff)
downloadsink-3601ee575f833bf204540f4fac41d87a0d977a79.tar.gz
sink-3601ee575f833bf204540f4fac41d87a0d977a79.zip
Centralized type specific code.
Diffstat (limited to 'common/resultset.h')
-rw-r--r--common/resultset.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/common/resultset.h b/common/resultset.h
new file mode 100644
index 0000000..7d7f19a
--- /dev/null
+++ b/common/resultset.h
@@ -0,0 +1,61 @@
1/*
2 * Copyright (C) 2014 Christian Mollekopf <chrigi_1@fastmail.fm>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19#pragma once
20
21#include <QVector>
22
23/*
24 * An iterator to a result set.
25 *
26 * We'll eventually want to lazy load results in next().
27 */
28class ResultSet {
29 public:
30 ResultSet(const QVector<QByteArray> &resultSet)
31 : mResultSet(resultSet),
32 mIt(nullptr)
33 {
34
35 }
36
37 bool next()
38 {
39 if (!mIt) {
40 mIt = mResultSet.constBegin();
41 } else {
42 mIt++;
43 }
44 return mIt != mResultSet.constEnd();
45 }
46
47 QByteArray id()
48 {
49 return *mIt;
50 }
51
52 bool isEmpty()
53 {
54 mResultSet.isEmpty();
55 }
56
57 private:
58 QVector<QByteArray> mResultSet;
59 QVector<QByteArray>::ConstIterator mIt;
60};
61