summaryrefslogtreecommitdiffstats
path: root/common/index.cpp
diff options
context:
space:
mode:
authorMinijackson <minijackson@riseup.net>2018-07-04 16:12:58 +0200
committerMinijackson <minijackson@riseup.net>2018-07-04 16:12:58 +0200
commitbe09c96b977db014932a3d28b5ee6643ed5eff84 (patch)
treea460c06d845282c3e7beafc422e695a134c662e0 /common/index.cpp
parent456d18b45a825a4d236ccc10c576da1fcbc4f74d (diff)
downloadsink-be09c96b977db014932a3d28b5ee6643ed5eff84.tar.gz
sink-be09c96b977db014932a3d28b5ee6643ed5eff84.zip
Use key API in indexes
Diffstat (limited to 'common/index.cpp')
-rw-r--r--common/index.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/common/index.cpp b/common/index.cpp
index 86a2dd5..238a745 100644
--- a/common/index.cpp
+++ b/common/index.cpp
@@ -2,6 +2,8 @@
2 2
3#include "log.h" 3#include "log.h"
4 4
5using Sink::Storage::Identifier;
6
5Index::Index(const QString &storageRoot, const QString &dbName, const QString &indexName, Sink::Storage::DataStore::AccessMode mode) 7Index::Index(const QString &storageRoot, const QString &dbName, const QString &indexName, Sink::Storage::DataStore::AccessMode mode)
6 : mTransaction(Sink::Storage::DataStore(storageRoot, dbName, mode).createTransaction(mode)), 8 : mTransaction(Sink::Storage::DataStore(storageRoot, dbName, mode).createTransaction(mode)),
7 mDb(mTransaction.openDatabase(indexName.toLatin1(), std::function<void(const Sink::Storage::DataStore::Error &)>(), true)), 9 mDb(mTransaction.openDatabase(indexName.toLatin1(), std::function<void(const Sink::Storage::DataStore::Error &)>(), true)),
@@ -32,6 +34,11 @@ Index::Index(const QByteArray &name, Sink::Storage::DataStore::Transaction &tran
32{ 34{
33} 35}
34 36
37void Index::add(const Identifier &key, const QByteArray &value)
38{
39 add(key.toInternalByteArray(), value);
40}
41
35void Index::add(const QByteArray &key, const QByteArray &value) 42void Index::add(const QByteArray &key, const QByteArray &value)
36{ 43{
37 Q_ASSERT(!key.isEmpty()); 44 Q_ASSERT(!key.isEmpty());
@@ -40,6 +47,11 @@ void Index::add(const QByteArray &key, const QByteArray &value)
40 }); 47 });
41} 48}
42 49
50void Index::remove(const Identifier &key, const QByteArray &value)
51{
52 remove(key.toInternalByteArray(), value);
53}
54
43void Index::remove(const QByteArray &key, const QByteArray &value) 55void Index::remove(const QByteArray &key, const QByteArray &value)
44{ 56{
45 mDb.remove(key, value, [&] (const Sink::Storage::DataStore::Error &error) { 57 mDb.remove(key, value, [&] (const Sink::Storage::DataStore::Error &error) {