src/basics.cpp

changeset 1440
265b2e95a8e8
parent 1419
f7c53002a990
--- a/src/basics.cpp	Fri Dec 28 00:03:47 2018 +0200
+++ b/src/basics.cpp	Thu Jun 20 08:54:35 2019 +0300
@@ -269,3 +269,29 @@
 {
 	return not (one == other);
 }
+
+QString Uuid::toString() const
+{
+	const std::uint32_t octet_1 = (a & 0xffffffff00000000) >> 32;
+	const std::uint16_t octet_2 = (a & 0x00000000ffff0000) >> 16;
+	const std::uint16_t octet_3 = (a & 0x000000000000ffff);
+	const std::uint16_t octet_4 = (b & 0xffff000000000000) >> 48;
+	const std::uint64_t octet_5 = (b & 0xffffffffffff0000);
+	char buffer[32 + 4 + 1];
+	std::sprintf(buffer, "%08x-%04x-%04x-%04x-%012lx", octet_1, octet_2, octet_3, octet_4, octet_5);
+	return buffer;
+}
+
+Uuid& Uuid::operator++()
+{
+	if (b == std::numeric_limits<quint64>::max())
+	{
+		b = 0;
+		a += 1;
+	}
+	else
+	{
+		b += 1;
+	}
+	return *this;
+}

mercurial