QVersionNumber: change int to qsizetype in fromString()
This completes the update to qsizetype in this class, adding a couple of methods that need to be removed in Qt 7. They're only required where int is not qsizetype (i.e., 64-bit platforms). Change-Id: I0e5f6bec596a4a78bd3bfffd16c9de29bec4c637 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
f718c35055
commit
1a440e557b
@ -113,7 +113,41 @@ QByteArray QtPrivate::QByteArrayList_join(const QByteArrayList *that, const char
|
||||
return QByteArrayList_join(that, {sep, seplen});
|
||||
}
|
||||
|
||||
#endif // QT_REMOVED_SINCE(6, 3)
|
||||
#if QT_REMOVED_SINCE(6, 4)
|
||||
|
||||
#include "qversionnumber.h"
|
||||
|
||||
# if QT_POINTER_SIZE != 4
|
||||
QVersionNumber QVersionNumber::fromString(const QString &string, int *suffixIndex)
|
||||
{
|
||||
qsizetype si;
|
||||
QVersionNumber r = fromString(QLatin1String(string.toLatin1()), &si);
|
||||
if (suffixIndex)
|
||||
*suffixIndex = si;
|
||||
return r;
|
||||
}
|
||||
|
||||
QVersionNumber QVersionNumber::fromString(QStringView string, int *suffixIndex)
|
||||
{
|
||||
qsizetype si;
|
||||
QVersionNumber r = fromString(QLatin1String(string.toLatin1()), &si);
|
||||
if (suffixIndex)
|
||||
*suffixIndex = si;
|
||||
return r;
|
||||
}
|
||||
|
||||
QVersionNumber QVersionNumber::fromString(QLatin1String string, int *suffixIndex)
|
||||
{
|
||||
qsizetype si;
|
||||
QVersionNumber r = fromString(string, &si);
|
||||
if (suffixIndex)
|
||||
*suffixIndex = si;
|
||||
return r;
|
||||
}
|
||||
# endif // QT_POINTER_SIZE != 4
|
||||
|
||||
// #include <qotherheader.h>
|
||||
// // implement removed functions from qotherheader.h
|
||||
|
||||
#endif // QT_REMOVED_SINCE(6, 3)
|
||||
#endif // QT_REMOVED_SINCE(6, 4)
|
||||
|
@ -413,7 +413,7 @@ QString QVersionNumber::toString() const
|
||||
|
||||
\sa isNull()
|
||||
*/
|
||||
QVersionNumber QVersionNumber::fromString(const QString &string, int *suffixIndex)
|
||||
QVersionNumber QVersionNumber::fromString(const QString &string, qsizetype *suffixIndex)
|
||||
{
|
||||
return fromString(QLatin1String(string.toLatin1()), suffixIndex);
|
||||
}
|
||||
@ -434,7 +434,7 @@ QVersionNumber QVersionNumber::fromString(const QString &string, int *suffixInde
|
||||
|
||||
\sa isNull()
|
||||
*/
|
||||
QVersionNumber QVersionNumber::fromString(QStringView string, int *suffixIndex)
|
||||
QVersionNumber QVersionNumber::fromString(QStringView string, qsizetype *suffixIndex)
|
||||
{
|
||||
return fromString(QLatin1String(string.toLatin1()), suffixIndex);
|
||||
}
|
||||
@ -454,7 +454,7 @@ QVersionNumber QVersionNumber::fromString(QStringView string, int *suffixIndex)
|
||||
|
||||
\sa isNull()
|
||||
*/
|
||||
QVersionNumber QVersionNumber::fromString(QLatin1String string, int *suffixIndex)
|
||||
QVersionNumber QVersionNumber::fromString(QLatin1String string, qsizetype *suffixIndex)
|
||||
{
|
||||
QList<int> seg;
|
||||
|
||||
@ -474,7 +474,7 @@ QVersionNumber QVersionNumber::fromString(QLatin1String string, int *suffixIndex
|
||||
} while (start < endOfString && (end < endOfString && *end == '.'));
|
||||
|
||||
if (suffixIndex)
|
||||
*suffixIndex = int(lastGoodEnd - string.begin());
|
||||
*suffixIndex = lastGoodEnd - string.begin();
|
||||
|
||||
return QVersionNumber(std::move(seg));
|
||||
}
|
||||
|
@ -276,10 +276,16 @@ public:
|
||||
|
||||
[[nodiscard]] Q_CORE_EXPORT QString toString() const;
|
||||
#if QT_STRINGVIEW_LEVEL < 2
|
||||
[[nodiscard]] Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
|
||||
[[nodiscard]] Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, qsizetype *suffixIndex = nullptr);
|
||||
#endif
|
||||
[[nodiscard]] Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, qsizetype *suffixIndex = nullptr);
|
||||
[[nodiscard]] Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, qsizetype *suffixIndex = nullptr);
|
||||
|
||||
#if QT_REMOVED_SINCE(6, 4) && QT_POINTER_SIZE != 4
|
||||
[[nodiscard]] Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex);
|
||||
[[nodiscard]] Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex);
|
||||
[[nodiscard]] Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex);
|
||||
#endif
|
||||
[[nodiscard]] Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
|
||||
[[nodiscard]] Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
|
||||
|
||||
[[nodiscard]] friend bool operator> (const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept
|
||||
{ return compare(lhs, rhs) > 0; }
|
||||
|
@ -511,7 +511,7 @@ void tst_QVersionNumber::fromString()
|
||||
QFETCH(QVersionNumber, expectedVersion);
|
||||
QFETCH(int, suffixIndex);
|
||||
|
||||
int index;
|
||||
qsizetype index;
|
||||
QCOMPARE(QVersionNumber::fromString(constructionString), expectedVersion);
|
||||
QCOMPARE(QVersionNumber::fromString(constructionString, &index), expectedVersion);
|
||||
QCOMPARE(index, suffixIndex);
|
||||
|
Loading…
x
Reference in New Issue
Block a user