From 767312e2063f4e58af3de0f27aba52de49e14295 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Fri, 5 Dec 2014 09:17:46 +0100 Subject: major reorg that puts Storage (previously Database) into common there is now a top-level tests dir, and a compile time switch for lmdb vs kyotocabinet --- common/storage.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 common/storage.h (limited to 'common/storage.h') diff --git a/common/storage.h b/common/storage.h new file mode 100644 index 0000000..f7dbd89 --- /dev/null +++ b/common/storage.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include + +class Storage { +public: + enum TransactionType { ReadOnly, ReadWrite }; + + Storage(const QString &storageRoot, const QString &name); + ~Storage(); + 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 From 351a66b5fb1c8659bff8ea20d60f5a6d2d3263ad Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Fri, 5 Dec 2014 09:46:53 +0100 Subject: make read return a bool on success not happy with this API, but we need to discuss the whole read thing anyways --- common/storage.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common/storage.h') diff --git a/common/storage.h b/common/storage.h index f7dbd89..0b548fb 100644 --- a/common/storage.h +++ b/common/storage.h @@ -16,8 +16,8 @@ public: 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 &); + bool read(const std::string &sKey, const std::function &); + bool read(const std::string &sKey, const std::function &); qint64 diskUsage() const; void removeFromDisk() const; -- cgit v1.2.3