Inline QString's conversions to integral types, except long long ones

As requested by a ### Qt6 comment.

Task-number: QTBUG-85700
Change-Id: I7c2813c0d8fbc38bcd2f7229de3a9d8e1b8b1f03
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Edward Welbourne 2020-08-13 15:24:50 +02:00
parent 0d11a92af9
commit 34a095848d
2 changed files with 18 additions and 39 deletions

View File

@ -6678,11 +6678,6 @@ qulonglong QString::toIntegral_helper(QStringView string, bool *ok, uint base)
\sa number(), toULong(), toInt(), QLocale::toInt() \sa number(), toULong(), toInt(), QLocale::toInt()
*/ */
long QString::toLong(bool *ok, int base) const
{
return toIntegral_helper<long>(*this, ok, base);
}
/*! /*!
\fn ulong QString::toULong(bool *ok, int base) const \fn ulong QString::toULong(bool *ok, int base) const
@ -6709,13 +6704,8 @@ long QString::toLong(bool *ok, int base) const
\sa number(), QLocale::toUInt() \sa number(), QLocale::toUInt()
*/ */
ulong QString::toULong(bool *ok, int base) const
{
return toIntegral_helper<ulong>(*this, ok, base);
}
/*! /*!
\fn int QString::toInt(bool *ok, int base) const
Returns the string converted to an \c int using base \a Returns the string converted to an \c int using base \a
base, which is 10 by default and must be between 2 and 36, or 0. base, which is 10 by default and must be between 2 and 36, or 0.
Returns 0 if the conversion fails. Returns 0 if the conversion fails.
@ -6739,12 +6729,8 @@ ulong QString::toULong(bool *ok, int base) const
\sa number(), toUInt(), toDouble(), QLocale::toInt() \sa number(), toUInt(), toDouble(), QLocale::toInt()
*/ */
int QString::toInt(bool *ok, int base) const
{
return toIntegral_helper<int>(*this, ok, base);
}
/*! /*!
\fn uint QString::toUInt(bool *ok, int base) const
Returns the string converted to an \c{unsigned int} using base \a Returns the string converted to an \c{unsigned int} using base \a
base, which is 10 by default and must be between 2 and 36, or 0. base, which is 10 by default and must be between 2 and 36, or 0.
Returns 0 if the conversion fails. Returns 0 if the conversion fails.
@ -6768,12 +6754,9 @@ int QString::toInt(bool *ok, int base) const
\sa number(), toInt(), QLocale::toUInt() \sa number(), toInt(), QLocale::toUInt()
*/ */
uint QString::toUInt(bool *ok, int base) const
{
return toIntegral_helper<uint>(*this, ok, base);
}
/*! /*!
\fn short QString::toShort(bool *ok, int base) const
Returns the string converted to a \c short using base \a Returns the string converted to a \c short using base \a
base, which is 10 by default and must be between 2 and 36, or 0. base, which is 10 by default and must be between 2 and 36, or 0.
Returns 0 if the conversion fails. Returns 0 if the conversion fails.
@ -6797,12 +6780,9 @@ uint QString::toUInt(bool *ok, int base) const
\sa number(), toUShort(), toInt(), QLocale::toShort() \sa number(), toUShort(), toInt(), QLocale::toShort()
*/ */
short QString::toShort(bool *ok, int base) const
{
return toIntegral_helper<short>(*this, ok, base);
}
/*! /*!
\fn ushort QString::toUShort(bool *ok, int base) const
Returns the string converted to an \c{unsigned short} using base \a Returns the string converted to an \c{unsigned short} using base \a
base, which is 10 by default and must be between 2 and 36, or 0. base, which is 10 by default and must be between 2 and 36, or 0.
Returns 0 if the conversion fails. Returns 0 if the conversion fails.
@ -6826,12 +6806,6 @@ short QString::toShort(bool *ok, int base) const
\sa number(), toShort(), QLocale::toUShort() \sa number(), toShort(), QLocale::toUShort()
*/ */
ushort QString::toUShort(bool *ok, int base) const
{
return toIntegral_helper<ushort>(*this, ok, base);
}
/*! /*!
Returns the string converted to a \c double value. Returns the string converted to a \c double value.

View File

@ -712,13 +712,18 @@ public:
static int localeAwareCompare(QStringView s1, QStringView s2); static int localeAwareCompare(QStringView s1, QStringView s2);
// ### Qt6: make inline except for the long long versions short toShort(bool *ok=nullptr, int base=10) const
short toShort(bool *ok=nullptr, int base=10) const; { return toIntegral_helper<short>(*this, ok, base); }
ushort toUShort(bool *ok=nullptr, int base=10) const; ushort toUShort(bool *ok=nullptr, int base=10) const
int toInt(bool *ok=nullptr, int base=10) const; { return toIntegral_helper<ushort>(*this, ok, base); }
uint toUInt(bool *ok=nullptr, int base=10) const; int toInt(bool *ok=nullptr, int base=10) const
long toLong(bool *ok=nullptr, int base=10) const; { return toIntegral_helper<int>(*this, ok, base); }
ulong toULong(bool *ok=nullptr, int base=10) const; uint toUInt(bool *ok=nullptr, int base=10) const
{ return toIntegral_helper<uint>(*this, ok, base); }
long toLong(bool *ok=nullptr, int base=10) const
{ return toIntegral_helper<long>(*this, ok, base); }
ulong toULong(bool *ok=nullptr, int base=10) const
{ return toIntegral_helper<ulong>(*this, ok, base); }
qlonglong toLongLong(bool *ok=nullptr, int base=10) const; qlonglong toLongLong(bool *ok=nullptr, int base=10) const;
qulonglong toULongLong(bool *ok=nullptr, int base=10) const; qulonglong toULongLong(bool *ok=nullptr, int base=10) const;
float toFloat(bool *ok=nullptr) const; float toFloat(bool *ok=nullptr) const;