summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMinijackson <minijackson@riseup.net>2018-08-07 11:02:00 +0200
committerMinijackson <minijackson@riseup.net>2018-08-07 23:11:05 +0200
commit91a86f8664f4c8ddec6546bd1faeb793b8cd70e3 (patch)
tree13938d14f4777fabe09e65c633b54b2ce3e43a2b
parentea78028750bcf6e5ad526763c5916bf39794ae12 (diff)
downloadsink-91a86f8664f4c8ddec6546bd1faeb793b8cd70e3.tar.gz
sink-91a86f8664f4c8ddec6546bd1faeb793b8cd70e3.zip
Store revisions as size_t
-rw-r--r--common/storage/key.h4
-rw-r--r--common/utils.h9
2 files changed, 11 insertions, 2 deletions
diff --git a/common/storage/key.h b/common/storage/key.h
index baabe38..acd81cf 100644
--- a/common/storage/key.h
+++ b/common/storage/key.h
@@ -67,7 +67,7 @@ public:
67 static const constexpr size_t INTERNAL_REPR_SIZE = 19; 67 static const constexpr size_t INTERNAL_REPR_SIZE = 19;
68 static const constexpr size_t DISPLAY_REPR_SIZE = 19; 68 static const constexpr size_t DISPLAY_REPR_SIZE = 19;
69 69
70 Revision(qint64 rev) : rev(rev) {} 70 Revision(size_t rev) : rev(rev) {}
71 71
72 QByteArray toInternalByteArray() const; 72 QByteArray toInternalByteArray() const;
73 static Revision fromInternalByteArray(const QByteArray &bytes); 73 static Revision fromInternalByteArray(const QByteArray &bytes);
@@ -84,7 +84,7 @@ public:
84 bool operator!=(const Revision &other) const; 84 bool operator!=(const Revision &other) const;
85 85
86private: 86private:
87 qint64 rev; 87 size_t rev;
88}; 88};
89 89
90class Key 90class Key
diff --git a/common/utils.h b/common/utils.h
index 7066d79..ec1d5b1 100644
--- a/common/utils.h
+++ b/common/utils.h
@@ -27,6 +27,15 @@ namespace Sink {
27QByteArray createUuid(); 27QByteArray createUuid();
28 28
29template <typename T> 29template <typename T>
30static QByteArray padNumber(T number);
31
32template <>
33QByteArray padNumber<size_t>(size_t number)
34{
35 return padNumber<qint64>(number);
36}
37
38template <typename T>
30static QByteArray padNumber(T number) 39static QByteArray padNumber(T number)
31{ 40{
32 static T uint_num_digits = (T)std::log10(std::numeric_limits<T>::max()) + 1; 41 static T uint_num_digits = (T)std::log10(std::numeric_limits<T>::max()) + 1;