src/uuid.cpp

Sat, 24 Aug 2019 14:44:42 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Sat, 24 Aug 2019 14:44:42 +0300
changeset 2
2bdc3ac5e77c
permissions
-rw-r--r--

things

2
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 #include "uuid.h"
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
2 #include <QIODevice>
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
3
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
4 void uuidToString(const Uuid &uuid, QTextStream &stream)
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
5 {
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
6 stream << "0x";
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
7 stream << QString::number(uuid.a, 16);
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
8 stream << QString::number(uuid.b, 16);
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
9 }
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
10
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
11 void incrementUuid(Uuid &uuid)
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
12 {
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
13 if (uuid.b == std::numeric_limits<decltype(uuid.b)>::max())
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
14 {
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
15 uuid.a += 1;
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
16 uuid.b = 0;
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
17 }
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
18 else
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
19 {
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
20 uuid.b += 1;
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
21 }
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
22 }

mercurial