summaryrefslogtreecommitdiffstats
path: root/store/kyotodatabase.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2014-12-04 22:51:05 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2014-12-04 22:51:05 +0100
commit838bc745bbce58ec5892c453971d5f7bd48f74ff (patch)
treec8c9bb456eaabe01ae82f0458c5cc051620bcf08 /store/kyotodatabase.h
parent4626fdf480ccd989854015b53f656fe66fa02a66 (diff)
downloadsink-838bc745bbce58ec5892c453971d5f7bd48f74ff.tar.gz
sink-838bc745bbce58ec5892c453971d5f7bd48f74ff.zip
Added kyotodatabase code.
We should probably turn Database into an interface.
Diffstat (limited to 'store/kyotodatabase.h')
-rw-r--r--store/kyotodatabase.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/store/kyotodatabase.h b/store/kyotodatabase.h
new file mode 100644
index 0000000..e752ff5
--- /dev/null
+++ b/store/kyotodatabase.h
@@ -0,0 +1,28 @@
1#pragma once
2
3#include <string>
4#include <QString>
5
6class Database {
7public:
8 enum TransactionType { ReadOnly, ReadWrite };
9
10 Database(const QString &storageRoot, const QString &name);
11 ~Database();
12 bool isInTransaction() const;
13 bool startTransaction(TransactionType type = ReadWrite);
14 bool commitTransaction();
15 void abortTransaction();
16 bool write(const char *key, size_t keySize, const char *value, size_t valueSize);
17 bool write(const std::string &sKey, const std::string &sValue);
18 //Perhaps prefer iterators (assuming we need to be able to match multiple values
19 void read(const std::string &sKey, const std::function<void(const std::string &value)> &);
20 void read(const std::string &sKey, const std::function<void(void *ptr, int size)> &);
21
22 qint64 diskUsage() const;
23 void removeFromDisk() const;
24private:
25 class Private;
26 Private * const d;
27};
28