summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/storage.h5
-rw-r--r--common/storage_common.cpp11
2 files changed, 16 insertions, 0 deletions
diff --git a/common/storage.h b/common/storage.h
index 22bf06c..daeace8 100644
--- a/common/storage.h
+++ b/common/storage.h
@@ -90,6 +90,11 @@ public:
90 const std::function<void(const QByteArray &key, const QByteArray &value)> &resultHandler, 90 const std::function<void(const QByteArray &key, const QByteArray &value)> &resultHandler,
91 const std::function<void(const Storage::Error &error)> &errorHandler = std::function<void(const Storage::Error &error)>()) const; 91 const std::function<void(const Storage::Error &error)> &errorHandler = std::function<void(const Storage::Error &error)>()) const;
92 92
93 /**
94 * Returns true if the database contains the substring key.
95 */
96 bool contains(const QByteArray &uid);
97
93 NamedDatabase(NamedDatabase&& other) : d(other.d) 98 NamedDatabase(NamedDatabase&& other) : d(other.d)
94 { 99 {
95 d = other.d; 100 d = other.d;
diff --git a/common/storage_common.cpp b/common/storage_common.cpp
index 1dbc178..10870d4 100644
--- a/common/storage_common.cpp
+++ b/common/storage_common.cpp
@@ -158,4 +158,15 @@ QByteArray Storage::uidFromKey(const QByteArray &key)
158 return key.mid(0, 38); 158 return key.mid(0, 38);
159} 159}
160 160
161bool Storage::NamedDatabase::contains(const QByteArray &uid)
162{
163 bool found = false;
164 scan(uid, [&found](const QByteArray &, const QByteArray &) -> bool {
165 found = true;
166 return false;
167 }, [this](const Akonadi2::Storage::Error &error) {
168 }, true);
169 return found;
170}
171
161} // namespace Akonadi2 172} // namespace Akonadi2