diff options
Diffstat (limited to 'common/storage.h')
-rw-r--r-- | common/storage.h | 22 |
1 files changed, 19 insertions, 3 deletions
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 { | |||
7 | public: | 7 | public: |
8 | enum AccessMode { ReadOnly, ReadWrite }; | 8 | enum AccessMode { ReadOnly, ReadWrite }; |
9 | 9 | ||
10 | class Error | ||
11 | { | ||
12 | public: | ||
13 | Error(const std::string &s, int c, const std::string &m) | ||
14 | : store(s), message(m), code(c) {} | ||
15 | std::string store; | ||
16 | std::string message; | ||
17 | int code; | ||
18 | }; | ||
19 | |||
10 | Storage(const QString &storageRoot, const QString &name, AccessMode mode = ReadOnly); | 20 | Storage(const QString &storageRoot, const QString &name, AccessMode mode = ReadOnly); |
11 | ~Storage(); | 21 | ~Storage(); |
12 | bool isInTransaction() const; | 22 | bool isInTransaction() const; |
@@ -15,9 +25,15 @@ public: | |||
15 | void abortTransaction(); | 25 | void abortTransaction(); |
16 | bool write(const char *key, size_t keySize, const char *value, size_t valueSize); | 26 | 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); | 27 | bool write(const std::string &sKey, const std::string &sValue); |
18 | //Perhaps prefer iterators (assuming we need to be able to match multiple values | 28 | void read(const std::string &sKey, |
19 | bool read(const std::string &sKey, const std::function<void(const std::string &value)> &); | 29 | const std::function<bool(const std::string &value)> &resultHandler); |
20 | bool read(const std::string &sKey, const std::function<void(void *ptr, int size)> &); | 30 | void read(const std::string &sKey, |
31 | const std::function<bool(const std::string &value)> &resultHandler, | ||
32 | const std::function<void(const Storage::Error &error)> &errors); | ||
33 | void read(const std::string &sKey, const std::function<bool(void *ptr, int size)> &resultHandler); | ||
34 | void read(const std::string &sKey, | ||
35 | const std::function<bool(void *ptr, int size)> & resultHandler, | ||
36 | const std::function<void(const Storage::Error &error)> &errorHandler); | ||
21 | 37 | ||
22 | qint64 diskUsage() const; | 38 | qint64 diskUsage() const; |
23 | void removeFromDisk() const; | 39 | void removeFromDisk() const; |