diff options
Diffstat (limited to 'common/storage_common.cpp')
-rw-r--r-- | common/storage_common.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/common/storage_common.cpp b/common/storage_common.cpp index 057dce4..b36ffcb 100644 --- a/common/storage_common.cpp +++ b/common/storage_common.cpp | |||
@@ -24,18 +24,40 @@ | |||
24 | #include "log.h" | 24 | #include "log.h" |
25 | #include "utils.h" | 25 | #include "utils.h" |
26 | 26 | ||
27 | #include <QUuid> | ||
28 | |||
27 | QDebug& operator<<(QDebug &dbg, const Sink::Storage::DataStore::Error &error) | 29 | QDebug& operator<<(QDebug &dbg, const Sink::Storage::DataStore::Error &error) |
28 | { | 30 | { |
29 | dbg << error.message << "Code: " << error.code << "Db: " << error.store; | 31 | dbg << error.message << "Code: " << error.code << "Db: " << error.store; |
30 | return dbg; | 32 | return dbg; |
31 | } | 33 | } |
32 | 34 | ||
35 | QDebug& operator<<(QDebug &dbg, const Sink::Storage::Identifier &id) | ||
36 | { | ||
37 | dbg << id.toDisplayString(); | ||
38 | return dbg; | ||
39 | } | ||
40 | |||
41 | QDebug& operator<<(QDebug &dbg, const Sink::Storage::Revision &rev) | ||
42 | { | ||
43 | dbg << rev.toDisplayString(); | ||
44 | return dbg; | ||
45 | } | ||
46 | |||
47 | QDebug& operator<<(QDebug &dbg, const Sink::Storage::Key &key) | ||
48 | { | ||
49 | dbg << key.toDisplayString(); | ||
50 | return dbg; | ||
51 | } | ||
52 | |||
33 | namespace Sink { | 53 | namespace Sink { |
34 | namespace Storage { | 54 | namespace Storage { |
35 | 55 | ||
36 | static const char *s_internalPrefix = "__internal"; | 56 | static const char *s_internalPrefix = "__internal"; |
37 | static const int s_internalPrefixSize = strlen(s_internalPrefix); | 57 | static const int s_internalPrefixSize = strlen(s_internalPrefix); |
38 | static const int s_lengthOfUid = 38; | 58 | static const int s_lengthOfUid = 38; |
59 | // RFC 4122 Section 4.1.2 says 128 bits -> 16 bytes | ||
60 | //static const int s_lengthOfUid = 16; | ||
39 | 61 | ||
40 | DbLayout::DbLayout() | 62 | DbLayout::DbLayout() |
41 | { | 63 | { |
@@ -194,6 +216,7 @@ bool DataStore::isInternalKey(const QByteArray &key) | |||
194 | return key.startsWith(s_internalPrefix); | 216 | return key.startsWith(s_internalPrefix); |
195 | } | 217 | } |
196 | 218 | ||
219 | /* | ||
197 | QByteArray DataStore::assembleKey(const QByteArray &key, qint64 revision) | 220 | QByteArray DataStore::assembleKey(const QByteArray &key, qint64 revision) |
198 | { | 221 | { |
199 | Q_ASSERT(revision <= 9223372036854775807); | 222 | Q_ASSERT(revision <= 9223372036854775807); |
@@ -201,15 +224,17 @@ QByteArray DataStore::assembleKey(const QByteArray &key, qint64 revision) | |||
201 | return key + QByteArray::number(revision).rightJustified(19, '0', false); | 224 | return key + QByteArray::number(revision).rightJustified(19, '0', false); |
202 | } | 225 | } |
203 | 226 | ||
204 | QByteArray DataStore::uidFromKey(const QByteArray &key) | 227 | //QByteArray DataStore::uidFromKey(const QByteArray &key) |
228 | Identifier DataStore::uidFromKey(const QByteArray &key) | ||
205 | { | 229 | { |
206 | return key.mid(0, s_lengthOfUid); | 230 | return Identifier::fromByteArray(key.mid(0, s_lengthOfUid)); |
207 | } | 231 | } |
208 | 232 | ||
209 | qint64 DataStore::revisionFromKey(const QByteArray &key) | 233 | qint64 DataStore::revisionFromKey(const QByteArray &key) |
210 | { | 234 | { |
211 | return key.mid(s_lengthOfUid + 1).toLongLong(); | 235 | return key.mid(s_lengthOfUid + 1).toLongLong(); |
212 | } | 236 | } |
237 | */ | ||
213 | 238 | ||
214 | QByteArray DataStore::generateUid() | 239 | QByteArray DataStore::generateUid() |
215 | { | 240 | { |