summaryrefslogtreecommitdiffstats
path: root/common/index.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/index.h')
-rw-r--r--common/index.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/common/index.h b/common/index.h
new file mode 100644
index 0000000..aea654a
--- /dev/null
+++ b/common/index.h
@@ -0,0 +1,35 @@
1#pragma once
2
3#include <string>
4#include <functional>
5#include <QString>
6#include "storage.h"
7
8/**
9 * An index for value pairs.
10 */
11class Index
12{
13public:
14 class Error
15 {
16 public:
17 Error(const std::string &s, int c, const std::string &m)
18 : store(s), message(m), code(c) {}
19 std::string store;
20 std::string message;
21 int code;
22 };
23
24 Index(const QString &storageRoot, const QString &name, Akonadi2::Storage::AccessMode mode = Akonadi2::Storage::ReadOnly);
25
26 void add(const QByteArray &key, const QByteArray &value);
27 // void remove(const QByteArray &key, const QByteArray &value);
28
29 void lookup(const QByteArray &key, const std::function<void(const QByteArray &value)> &resultHandler,
30 const std::function<void(const Error &error)> &errorHandler);
31
32private:
33 Q_DISABLE_COPY(Index);
34 Akonadi2::Storage mStorage;
35};