From 687dc7fac7fec6c2f77aa1d130119a8bc1fd368b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 24 Jan 2018 14:09:08 -0800 Subject: QUuid: add a way to get the string form without the braces While we're at it, add a way to get it without the dashes too. I'm calling it "id128", as in "128-bit ID", as seen in journald's sd_id128_t type and the sd_id128_xxx() API. [ChangeLog][QtCore][QUuid] Added a parameter to both toString() and toByteArray() to allow controlling the use or not of the braces and dashes in the string form. Change-Id: I56b444f9d6274221a3b7fffd150cde706cfc5098 Reviewed-by: Lars Knoll Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/plugin/quuid.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/corelib/plugin/quuid.h') diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h index ee0a9f9dac..27a84b4e01 100644 --- a/src/corelib/plugin/quuid.h +++ b/src/corelib/plugin/quuid.h @@ -85,7 +85,14 @@ public: Sha1 = 5 // 0 1 0 1 }; + enum StringFormat { + WithBraces = 0, + WithoutBraces = 1, + Id128 = 3 + }; + #if defined(Q_COMPILER_UNIFORM_INIT) && !defined(Q_CLANG_QDOC) + Q_DECL_CONSTEXPR QUuid() Q_DECL_NOTHROW : data1(0), data2(0), data3(0), data4{0,0,0,0,0,0,0,0} {} Q_DECL_CONSTEXPR QUuid(uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, @@ -121,8 +128,10 @@ public: static QUuid fromString(QLatin1String string) Q_DECL_NOTHROW; QUuid(const char *); QString toString() const; + QString toString(StringFormat mode) const; // ### Qt6: merge with previous QUuid(const QByteArray &); QByteArray toByteArray() const; + QByteArray toByteArray(StringFormat mode) const; // ### Qt6: merge with previous QByteArray toRfc4122() const; static QUuid fromRfc4122(const QByteArray &); bool isNull() const Q_DECL_NOTHROW; -- cgit v1.2.3