From ed2f5e7cf2df6843bec2260b238cbcb216ea1dca Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 31 Aug 2020 12:58:03 +0200 Subject: [PATCH] QUuid: merge toString() overloads and toByteArray() overloads In each case, simply give WithBraces as default for mode, since that's what _q_uuidToHex() used internally. Task-number: QTBUG-85700 Change-Id: I9f6fddb259703917129d4be742bbdd2eb1647f44 Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- src/corelib/plugin/quuid.cpp | 90 +----------------------------------- src/corelib/plugin/quuid.h | 8 ++-- 2 files changed, 4 insertions(+), 94 deletions(-) diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index fc70ca1386b..77f60c516f8 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz ** Contact: https://www.qt.io/licensing/ ** @@ -568,49 +568,6 @@ QUuid QUuid::fromRfc4122(const QByteArray &bytes) otherwise returns \c false. */ -/*! - Returns the string representation of this QUuid. The string is - formatted as five hex fields separated by '-' and enclosed in - curly braces, i.e., "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" where - 'x' is a hex digit. From left to right, the five hex fields are - obtained from the four public data members in QUuid as follows: - - \table - \header - \li Field # - \li Source - - \row - \li 1 - \li data1 - - \row - \li 2 - \li data2 - - \row - \li 3 - \li data3 - - \row - \li 4 - \li data4[0] .. data4[1] - - \row - \li 5 - \li data4[2] .. data4[7] - - \endtable -*/ -QString QUuid::toString() const -{ - char latin1[MaxStringUuidLength]; - const auto end = _q_uuidToHex(*this, latin1); - Q_ASSERT(end - latin1 == MaxStringUuidLength); - Q_UNUSED(end); - return QString::fromLatin1(latin1, MaxStringUuidLength); -} - /*! \since 5.11 @@ -652,51 +609,6 @@ QString QUuid::toString(QUuid::StringFormat mode) const return QString::fromLatin1(latin1, end - latin1); } -/*! - Returns the binary representation of this QUuid. The byte array is - formatted as five hex fields separated by '-' and enclosed in - curly braces, i.e., "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" where - 'x' is a hex digit. From left to right, the five hex fields are - obtained from the four public data members in QUuid as follows: - - \table - \header - \li Field # - \li Source - - \row - \li 1 - \li data1 - - \row - \li 2 - \li data2 - - \row - \li 3 - \li data3 - - \row - \li 4 - \li data4[0] .. data4[1] - - \row - \li 5 - \li data4[2] .. data4[7] - - \endtable - - \since 4.8 -*/ -QByteArray QUuid::toByteArray() const -{ - QByteArray result(MaxStringUuidLength, Qt::Uninitialized); - const auto end = _q_uuidToHex(*this, const_cast(result.constData())); - Q_ASSERT(end - result.constData() == MaxStringUuidLength); - Q_UNUSED(end); - return result; -} - /*! \since 5.11 diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h index cc5745992c9..bfea13f9fc8 100644 --- a/src/corelib/plugin/quuid.h +++ b/src/corelib/plugin/quuid.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -127,11 +127,9 @@ public: static QUuid fromString(QStringView string) noexcept; static QUuid fromString(QLatin1String string) noexcept; explicit QUuid(const char *); - QString toString() const; - QString toString(StringFormat mode) const; // ### Qt6: merge with previous + QString toString(StringFormat mode = WithBraces) const; explicit QUuid(const QByteArray &); - QByteArray toByteArray() const; - QByteArray toByteArray(StringFormat mode) const; // ### Qt6: merge with previous + QByteArray toByteArray(StringFormat mode = WithBraces) const; QByteArray toRfc4122() const; static QUuid fromRfc4122(const QByteArray &); bool isNull() const noexcept;