diff options
Diffstat (limited to 'common/storage/key.h')
-rw-r--r-- | common/storage/key.h | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/common/storage/key.h b/common/storage/key.h index 76dbd13..a5b92bb 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); |
@@ -45,6 +46,11 @@ public: | |||
45 | QByteArray toDisplayByteArray() const; | 46 | QByteArray toDisplayByteArray() const; |
46 | static Identifier fromDisplayByteArray(const QByteArray &bytes); | 47 | static Identifier fromDisplayByteArray(const QByteArray &bytes); |
47 | 48 | ||
49 | bool isNull() const; | ||
50 | |||
51 | bool operator==(const Identifier &other) const; | ||
52 | bool operator!=(const Identifier &other) const; | ||
53 | |||
48 | private: | 54 | private: |
49 | explicit Identifier(const QUuid &uid) : uid(uid) {} | 55 | explicit Identifier(const QUuid &uid) : uid(uid) {} |
50 | QUuid uid; | 56 | QUuid uid; |
@@ -66,6 +72,9 @@ public: | |||
66 | static Revision fromDisplayByteArray(const QByteArray &bytes); | 72 | static Revision fromDisplayByteArray(const QByteArray &bytes); |
67 | qint64 toQint64() const; | 73 | qint64 toQint64() const; |
68 | 74 | ||
75 | bool operator==(const Revision &other) const; | ||
76 | bool operator!=(const Revision &other) const; | ||
77 | |||
69 | private: | 78 | private: |
70 | qint64 rev; | 79 | qint64 rev; |
71 | }; | 80 | }; |
@@ -76,6 +85,7 @@ public: | |||
76 | static const constexpr size_t INTERNAL_REPR_SIZE = Identifier::INTERNAL_REPR_SIZE + Revision::INTERNAL_REPR_SIZE; | 85 | 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; | 86 | static const constexpr size_t DISPLAY_REPR_SIZE = Identifier::DISPLAY_REPR_SIZE + Revision::DISPLAY_REPR_SIZE; |
78 | 87 | ||
88 | Key() : id(), rev(0) {} | ||
79 | Key(const Identifier &id, const Revision &rev) : id(id), rev(rev) {} | 89 | Key(const Identifier &id, const Revision &rev) : id(id), rev(rev) {} |
80 | 90 | ||
81 | QByteArray toInternalByteArray() const; | 91 | QByteArray toInternalByteArray() const; |
@@ -87,6 +97,11 @@ public: | |||
87 | const Revision &revision() const; | 97 | const Revision &revision() const; |
88 | void setRevision(const Revision &newRev); | 98 | void setRevision(const Revision &newRev); |
89 | 99 | ||
100 | bool isNull() const; | ||
101 | |||
102 | bool operator==(const Key &other) const; | ||
103 | bool operator!=(const Key &other) const; | ||
104 | |||
90 | private: | 105 | private: |
91 | Identifier id; | 106 | Identifier id; |
92 | Revision rev; | 107 | Revision rev; |