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 <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
533df067e9
commit
ed2f5e7cf2
@ -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 <marc.mutz@kdab.com>
|
** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
@ -568,49 +568,6 @@ QUuid QUuid::fromRfc4122(const QByteArray &bytes)
|
|||||||
otherwise returns \c false.
|
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
|
\since 5.11
|
||||||
|
|
||||||
@ -652,51 +609,6 @@ QString QUuid::toString(QUuid::StringFormat mode) const
|
|||||||
return QString::fromLatin1(latin1, end - latin1);
|
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<char*>(result.constData()));
|
|
||||||
Q_ASSERT(end - result.constData() == MaxStringUuidLength);
|
|
||||||
Q_UNUSED(end);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\since 5.11
|
\since 5.11
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
** Copyright (C) 2020 The Qt Company Ltd.
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of the QtCore module of the Qt Toolkit.
|
** 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(QStringView string) noexcept;
|
||||||
static QUuid fromString(QLatin1String string) noexcept;
|
static QUuid fromString(QLatin1String string) noexcept;
|
||||||
explicit QUuid(const char *);
|
explicit QUuid(const char *);
|
||||||
QString toString() const;
|
QString toString(StringFormat mode = WithBraces) const;
|
||||||
QString toString(StringFormat mode) const; // ### Qt6: merge with previous
|
|
||||||
explicit QUuid(const QByteArray &);
|
explicit QUuid(const QByteArray &);
|
||||||
QByteArray toByteArray() const;
|
QByteArray toByteArray(StringFormat mode = WithBraces) const;
|
||||||
QByteArray toByteArray(StringFormat mode) const; // ### Qt6: merge with previous
|
|
||||||
QByteArray toRfc4122() const;
|
QByteArray toRfc4122() const;
|
||||||
static QUuid fromRfc4122(const QByteArray &);
|
static QUuid fromRfc4122(const QByteArray &);
|
||||||
bool isNull() const noexcept;
|
bool isNull() const noexcept;
|
||||||
|
Loading…
Reference in New Issue
Block a user