diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2018-01-24 14:09:08 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2018-02-03 21:30:37 +0000 |
commit | 687dc7fac7fec6c2f77aa1d130119a8bc1fd368b (patch) | |
tree | 83f67123c1430067ae497f84a4153d0509f2c3a5 /src/corelib/plugin/quuid.h | |
parent | 017569f702b6dd0bc3aa077d85e4a7fc27562133 (diff) |
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 <lars.knoll@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/plugin/quuid.h')
-rw-r--r-- | src/corelib/plugin/quuid.h | 9 |
1 files changed, 9 insertions, 0 deletions
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; |