src/uuid.cpp

Thu, 03 Oct 2019 11:45:44 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Thu, 03 Oct 2019 11:45:44 +0300
changeset 5
593a658cba8e
parent 2
2bdc3ac5e77c
permissions
-rw-r--r--

stuff

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