summaryrefslogtreecommitdiffstats
path: root/common/storage_common.cpp
diff options
context:
space:
mode:
authorAaron Seigo <aseigo@kde.org>2015-01-27 18:44:03 +0100
committerAaron Seigo <aseigo@kde.org>2015-01-27 18:45:54 +0100
commit142bf3d8bc6569a432e065e851f026a46e9595ed (patch)
tree631d40828e2dcc63e0a12e5b9de1e8c0e3ebddf0 /common/storage_common.cpp
parent7137cb09a1f7a4d36e9865d9c9e1f54d59ddbc68 (diff)
downloadsink-142bf3d8bc6569a432e065e851f026a46e9595ed.tar.gz
sink-142bf3d8bc6569a432e065e851f026a46e9595ed.zip
introduce a set of isInternalKey functions to hide this impl detail
Diffstat (limited to 'common/storage_common.cpp')
-rw-r--r--common/storage_common.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/common/storage_common.cpp b/common/storage_common.cpp
index bdae9dd..ff2a2cd 100644
--- a/common/storage_common.cpp
+++ b/common/storage_common.cpp
@@ -25,6 +25,9 @@
25namespace Akonadi2 25namespace Akonadi2
26{ 26{
27 27
28static const char *s_internalPrefix = "__internal";
29static const int s_internalPrefixSize = strlen(s_internalPrefix);
30
28void errorHandler(const Storage::Error &error) 31void errorHandler(const Storage::Error &error)
29{ 32{
30 //TODO: allow this to be turned on / off globally 33 //TODO: allow this to be turned on / off globally
@@ -71,4 +74,23 @@ qint64 Storage::maxRevision()
71 return r; 74 return r;
72} 75}
73 76
77bool Storage::isInternalKey(const char *key)
78{
79 return key && strncmp(key, s_internalPrefix, s_internalPrefixSize) == 0;
80}
81
82bool Storage::isInternalKey(void *key, int size)
83{
84 if (size < 1) {
85 return false;
86 }
87
88 return key && strncmp(static_cast<char *>(key), s_internalPrefix, (size > s_internalPrefixSize ? s_internalPrefixSize : size)) == 0;
89}
90
91bool Storage::isInternalKey(const QByteArray &key)
92{
93 return key.startsWith(s_internalPrefix);
94}
95
74} // namespace Akonadi2 96} // namespace Akonadi2