QUuid: port createUuidV{3,5}() to QByteArrayView
Requires to mark the existing QString overload as Q_WEAK_OVERLOAD.¹ And since this non-polymorphic class is exported wholesale, we need to involve REMOVED_SINCE here, too. ¹ While QString and QByteArray don't overload well, the new overload set makes calls with QByteArray arguments ambiguous, unless the QString overload is demoted to a weak one. As a drive-by, change the QUuid argument passing from cref to by-value, fixing a Clazy warning. [ChangeLog][QtCore][QUuid] Ported createUuidV3() and createUuidV5() from QByteArray to QByteArrayView, made them noexcept, and fixed various ambiguities in the overload set. Change-Id: I9f71209f2ddb58ace4e15fb68418b1a21d2b3602 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
parent
fa8256bb5a
commit
d8131960d8
@ -1167,6 +1167,16 @@ bool QUuid::operator>(const QUuid &other) const noexcept
|
||||
return is_gt(compareThreeWay(*this, other));
|
||||
}
|
||||
|
||||
QUuid QUuid::createUuidV3(const QUuid &ns, const QByteArray &baseData) noexcept
|
||||
{
|
||||
return createUuidV3(ns, qToByteArrayViewIgnoringNull(baseData));
|
||||
}
|
||||
|
||||
QUuid QUuid::createUuidV5(const QUuid &ns, const QByteArray &baseData) noexcept
|
||||
{
|
||||
return createUuidV5(ns, qToByteArrayViewIgnoringNull(baseData));
|
||||
}
|
||||
|
||||
#include "qxmlstream.h" // inlined API
|
||||
|
||||
// #include "qotherheader.h"
|
||||
|
@ -532,11 +532,14 @@ QUuid QUuid::fromString(QAnyStringView text) noexcept
|
||||
|
||||
/*!
|
||||
\since 5.0
|
||||
\fn QUuid QUuid::createUuidV3(const QUuid &ns, const QByteArray &baseData);
|
||||
\fn QUuid QUuid::createUuidV3(QUuid ns, QByteArrayView baseData);
|
||||
|
||||
This function returns a new UUID with variant QUuid::DCE and version QUuid::Md5.
|
||||
\a ns is the namespace and \a baseData is the basic data as described by RFC 4122.
|
||||
|
||||
\note In Qt versions prior to 6.8, this function took QByteArray, not
|
||||
QByteArrayView.
|
||||
|
||||
\sa variant(), version(), createUuidV5()
|
||||
*/
|
||||
|
||||
@ -552,11 +555,14 @@ QUuid QUuid::fromString(QAnyStringView text) noexcept
|
||||
|
||||
/*!
|
||||
\since 5.0
|
||||
\fn QUuid QUuid::createUuidV5(const QUuid &ns, const QByteArray &baseData);
|
||||
\fn QUuid QUuid::createUuidV5(QUuid ns, QByteArrayView baseData);
|
||||
|
||||
This function returns a new UUID with variant QUuid::DCE and version QUuid::Sha1.
|
||||
\a ns is the namespace and \a baseData is the basic data as described by RFC 4122.
|
||||
|
||||
\note In Qt versions prior to 6.8, this function took QByteArray, not
|
||||
QByteArrayView.
|
||||
|
||||
\sa variant(), version(), createUuidV3()
|
||||
*/
|
||||
|
||||
@ -570,13 +576,13 @@ QUuid QUuid::fromString(QAnyStringView text) noexcept
|
||||
\sa variant(), version(), createUuidV3()
|
||||
*/
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
QUuid QUuid::createUuidV3(const QUuid &ns, const QByteArray &baseData) noexcept
|
||||
QUuid QUuid::createUuidV3(QUuid ns, QByteArrayView baseData) noexcept
|
||||
{
|
||||
return createFromName(ns, baseData, QCryptographicHash::Md5, 3);
|
||||
}
|
||||
#endif
|
||||
|
||||
QUuid QUuid::createUuidV5(const QUuid &ns, const QByteArray &baseData) noexcept
|
||||
QUuid QUuid::createUuidV5(QUuid ns, QByteArrayView baseData) noexcept
|
||||
{
|
||||
return createFromName(ns, baseData, QCryptographicHash::Sha1, 5);
|
||||
}
|
||||
|
@ -220,20 +220,27 @@ public:
|
||||
#endif
|
||||
public:
|
||||
static QUuid createUuid();
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
#if QT_CORE_REMOVED_SINCE(6, 8)
|
||||
static QUuid createUuidV3(const QUuid &ns, const QByteArray &baseData) noexcept;
|
||||
#endif
|
||||
static QUuid createUuidV5(const QUuid &ns, const QByteArray &baseData) noexcept;
|
||||
#endif
|
||||
static QUuid createUuidV5(QUuid ns, QByteArrayView baseData) noexcept;
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
static QUuid createUuidV3(QUuid ns, QByteArrayView baseData) noexcept;
|
||||
#if !QT_CORE_REMOVED_SINCE(6, 8)
|
||||
Q_WEAK_OVERLOAD
|
||||
#endif
|
||||
static inline QUuid createUuidV3(const QUuid &ns, const QString &baseData)
|
||||
{
|
||||
return QUuid::createUuidV3(ns, baseData.toUtf8());
|
||||
return QUuid::createUuidV3(ns, qToByteArrayViewIgnoringNull(baseData.toUtf8()));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !QT_CORE_REMOVED_SINCE(6, 8)
|
||||
Q_WEAK_OVERLOAD
|
||||
#endif
|
||||
static inline QUuid createUuidV5(const QUuid &ns, const QString &baseData)
|
||||
{
|
||||
return QUuid::createUuidV5(ns, baseData.toUtf8());
|
||||
return QUuid::createUuidV5(ns, qToByteArrayViewIgnoringNull(baseData.toUtf8()));
|
||||
}
|
||||
|
||||
QUuid::Variant variant() const noexcept;
|
||||
|
Loading…
x
Reference in New Issue
Block a user