summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorMinijackson <minijackson@riseup.net>2018-07-19 10:08:39 +0200
committerMinijackson <minijackson@riseup.net>2018-07-19 10:08:39 +0200
commit0e54657272477ad779cc5c0e3f843b9f01b5e928 (patch)
tree886d026d9de3bd83fcf2656fafa36ad5a9e64268 /common
parent27a408876e179d62dc25050a6f386bf2d9b80a9b (diff)
downloadsink-0e54657272477ad779cc5c0e3f843b9f01b5e928.tar.gz
sink-0e54657272477ad779cc5c0e3f843b9f01b5e928.zip
Default constructor of Identifier produces null + safety net
Diffstat (limited to 'common')
-rw-r--r--common/storage/key.cpp6
-rw-r--r--common/storage/key.h5
2 files changed, 8 insertions, 3 deletions
diff --git a/common/storage/key.cpp b/common/storage/key.cpp
index 01a3e3a..4dacca2 100644
--- a/common/storage/key.cpp
+++ b/common/storage/key.cpp
@@ -46,8 +46,14 @@ QDebug &operator<<(QDebug &dbg, const Key &key)
46 46
47// Identifier 47// Identifier
48 48
49Identifier Identifier::createIdentifier()
50{
51 return Identifier(QUuid::createUuid());
52}
53
49QByteArray Identifier::toInternalByteArray() const 54QByteArray Identifier::toInternalByteArray() const
50{ 55{
56 Q_ASSERT(!uid.isNull());
51 return uid.toRfc4122(); 57 return uid.toRfc4122();
52} 58}
53 59
diff --git a/common/storage/key.h b/common/storage/key.h
index 40f4aca..151c333 100644
--- a/common/storage/key.h
+++ b/common/storage/key.h
@@ -37,7 +37,8 @@ public:
37 static const constexpr size_t INTERNAL_REPR_SIZE = 16; 37 static const constexpr size_t INTERNAL_REPR_SIZE = 16;
38 static const constexpr size_t DISPLAY_REPR_SIZE = 38; 38 static const constexpr size_t DISPLAY_REPR_SIZE = 38;
39 39
40 Identifier() : uid(QUuid::createUuid()){}; 40 Identifier() = default;
41 static Identifier createIdentifier();
41 42
42 QByteArray toInternalByteArray() const; 43 QByteArray toInternalByteArray() const;
43 static Identifier fromInternalByteArray(const QByteArray &bytes); 44 static Identifier fromInternalByteArray(const QByteArray &bytes);
@@ -76,8 +77,6 @@ public:
76 static const constexpr size_t INTERNAL_REPR_SIZE = Identifier::INTERNAL_REPR_SIZE + Revision::INTERNAL_REPR_SIZE; 77 static const constexpr size_t INTERNAL_REPR_SIZE = Identifier::INTERNAL_REPR_SIZE + Revision::INTERNAL_REPR_SIZE;
77 static const constexpr size_t DISPLAY_REPR_SIZE = Identifier::DISPLAY_REPR_SIZE + Revision::DISPLAY_REPR_SIZE; 78 static const constexpr size_t DISPLAY_REPR_SIZE = Identifier::DISPLAY_REPR_SIZE + Revision::DISPLAY_REPR_SIZE;
78 79
79 // Just to be able to store keys into Qt containers
80 [[deprecated("Don't use the default constructor")]]
81 Key() : id(), rev(0) {} 80 Key() : id(), rev(0) {}
82 Key(const Identifier &id, const Revision &rev) : id(id), rev(rev) {} 81 Key(const Identifier &id, const Revision &rev) : id(id), rev(rev) {}
83 82