diff options
author | Aaron Seigo <aseigo@kde.org> | 2015-01-27 18:44:03 +0100 |
---|---|---|
committer | Aaron Seigo <aseigo@kde.org> | 2015-01-27 18:45:54 +0100 |
commit | 142bf3d8bc6569a432e065e851f026a46e9595ed (patch) | |
tree | 631d40828e2dcc63e0a12e5b9de1e8c0e3ebddf0 /common/storage_common.cpp | |
parent | 7137cb09a1f7a4d36e9865d9c9e1f54d59ddbc68 (diff) | |
download | sink-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.cpp | 22 |
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 @@ | |||
25 | namespace Akonadi2 | 25 | namespace Akonadi2 |
26 | { | 26 | { |
27 | 27 | ||
28 | static const char *s_internalPrefix = "__internal"; | ||
29 | static const int s_internalPrefixSize = strlen(s_internalPrefix); | ||
30 | |||
28 | void errorHandler(const Storage::Error &error) | 31 | void 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 | ||
77 | bool Storage::isInternalKey(const char *key) | ||
78 | { | ||
79 | return key && strncmp(key, s_internalPrefix, s_internalPrefixSize) == 0; | ||
80 | } | ||
81 | |||
82 | bool 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 | |||
91 | bool Storage::isInternalKey(const QByteArray &key) | ||
92 | { | ||
93 | return key.startsWith(s_internalPrefix); | ||
94 | } | ||
95 | |||
74 | } // namespace Akonadi2 | 96 | } // namespace Akonadi2 |