From 838bc745bbce58ec5892c453971d5f7bd48f74ff Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 4 Dec 2014 22:51:05 +0100 Subject: Added kyotodatabase code. We should probably turn Database into an interface. --- store/kyotodatabase.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 store/kyotodatabase.h (limited to 'store/kyotodatabase.h') 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 @@ +#pragma once + +#include +#include + +class Database { +public: + enum TransactionType { ReadOnly, ReadWrite }; + + Database(const QString &storageRoot, const QString &name); + ~Database(); + bool isInTransaction() const; + bool startTransaction(TransactionType type = ReadWrite); + bool commitTransaction(); + void abortTransaction(); + bool write(const char *key, size_t keySize, const char *value, size_t valueSize); + bool write(const std::string &sKey, const std::string &sValue); + //Perhaps prefer iterators (assuming we need to be able to match multiple values + void read(const std::string &sKey, const std::function &); + void read(const std::string &sKey, const std::function &); + + qint64 diskUsage() const; + void removeFromDisk() const; +private: + class Private; + Private * const d; +}; + -- cgit v1.2.3