From 66bcbab0990c965196991d66ca2a595cf9135074 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Sat, 6 Dec 2014 00:39:07 +0100 Subject: read takes an error handler rather than returns a bool --- common/storage.h | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'common/storage.h') diff --git a/common/storage.h b/common/storage.h index 846e15b..e5e592c 100644 --- a/common/storage.h +++ b/common/storage.h @@ -7,6 +7,16 @@ class Storage { public: enum AccessMode { ReadOnly, ReadWrite }; + class Error + { + public: + Error(const std::string &s, int c, const std::string &m) + : store(s), message(m), code(c) {} + std::string store; + std::string message; + int code; + }; + Storage(const QString &storageRoot, const QString &name, AccessMode mode = ReadOnly); ~Storage(); bool isInTransaction() const; @@ -15,9 +25,15 @@ public: 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 - bool read(const std::string &sKey, const std::function &); - bool read(const std::string &sKey, const std::function &); + void read(const std::string &sKey, + const std::function &resultHandler); + void read(const std::string &sKey, + const std::function &resultHandler, + const std::function &errors); + void read(const std::string &sKey, const std::function &resultHandler); + void read(const std::string &sKey, + const std::function & resultHandler, + const std::function &errorHandler); qint64 diskUsage() const; void removeFromDisk() const; -- cgit v1.2.3