summaryrefslogtreecommitdiffstats
path: root/common/fulltextindex.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/fulltextindex.h')
-rw-r--r--common/fulltextindex.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/common/fulltextindex.h b/common/fulltextindex.h
new file mode 100644
index 0000000..e06f29d
--- /dev/null
+++ b/common/fulltextindex.h
@@ -0,0 +1,39 @@
1#pragma once
2
3#include "sink_export.h"
4
5#include <string>
6#include <functional>
7#include <QString>
8#include <memory>
9#include "storage.h"
10#include "log.h"
11
12namespace Xapian {
13 class Database;
14 class WritableDatabase;
15};
16
17class SINK_EXPORT FulltextIndex
18{
19public:
20 FulltextIndex(const QByteArray &resourceInstanceIdentifier, Sink::Storage::DataStore::AccessMode mode = Sink::Storage::DataStore::ReadOnly);
21 ~FulltextIndex();
22
23 void add(const QByteArray &key, const QString &value);
24 void add(const QByteArray &key, const QList<QPair<QString, QString>> &values);
25 void remove(const QByteArray &key);
26
27 void commitTransaction();
28 void abortTransaction();
29
30 QVector<QByteArray> lookup(const QString &key);
31
32private:
33 Xapian::WritableDatabase* writableDatabase();
34 Q_DISABLE_COPY(FulltextIndex);
35 Xapian::Database *mDb{nullptr};
36 QString mName;
37 QString mDbPath;
38 bool mHasTransactionOpen{false};
39};