Add QStringView::localeAwareCompare()
QString already has a localeAwareCompare(QStringView, QStringView) static method. Use it in QStringView::localeAwareCompare(QStringView). [ChangeLog][QtCore][QStringView] Added QStringView::localeAwareCompare(). Task-number: QTBUG-98431 Change-Id: Iec3865a5439d9fb653cc1150da21042186bdee98 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
b86b22cfde
commit
893dd5d7be
@ -1555,6 +1555,8 @@ inline int QString::localeAwareCompare(QStringView s) const
|
||||
{ return localeAwareCompare_helper(constData(), length(), s.constData(), s.length()); }
|
||||
inline int QString::localeAwareCompare(QStringView s1, QStringView s2)
|
||||
{ return localeAwareCompare_helper(s1.constData(), s1.length(), s2.constData(), s2.length()); }
|
||||
inline int QStringView::localeAwareCompare(QStringView other) const
|
||||
{ return QString::localeAwareCompare(*this, other); }
|
||||
|
||||
namespace QtPrivate {
|
||||
// used by qPrintable() and qUtf8Printable() macros
|
||||
|
@ -806,6 +806,21 @@ QT_BEGIN_NAMESPACE
|
||||
\sa compare()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QStringView::localeAwareCompare(QStringView other) const
|
||||
\since 6.4
|
||||
|
||||
Compares this string view with the \a other string view and returns
|
||||
an integer less than, equal to, or greater than zero if this string
|
||||
view is less than, equal to, or greater than the \a other string view.
|
||||
|
||||
The comparison is performed in a locale- and also platform-dependent
|
||||
manner. Use this function to present sorted lists of strings to the
|
||||
user.
|
||||
|
||||
\sa {Comparing Strings}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QStringView::startsWith(QStringView str, Qt::CaseSensitivity cs) const
|
||||
\fn bool QStringView::startsWith(QLatin1String l1, Qt::CaseSensitivity cs) const
|
||||
|
@ -309,6 +309,8 @@ public:
|
||||
[[nodiscard]] int compare(QChar c, Qt::CaseSensitivity cs) const noexcept
|
||||
{ return QtPrivate::compareStrings(*this, QStringView(&c, 1), cs); }
|
||||
|
||||
[[nodiscard]] inline int localeAwareCompare(QStringView other) const;
|
||||
|
||||
[[nodiscard]] bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
|
||||
{ return QtPrivate::startsWith(*this, s, cs); }
|
||||
[[nodiscard]] inline bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
|
||||
|
@ -440,6 +440,10 @@ private Q_SLOTS:
|
||||
void member_localeAwareCompare_QString_QString() { member_localeAwareCompare_impl<QString, QString>(); }
|
||||
void member_localeAwareCompare_QString_QStringView_data() { member_localeAwareCompare_data(); }
|
||||
void member_localeAwareCompare_QString_QStringView() { member_localeAwareCompare_impl<QString, QStringView>(); }
|
||||
void member_localeAwareCompare_QStringView_QString_data() { member_localeAwareCompare_data(); }
|
||||
void member_localeAwareCompare_QStringView_QString() { member_localeAwareCompare_impl<QStringView, QString>(); }
|
||||
void member_localeAwareCompare_QStringView_QStringView_data() { member_localeAwareCompare_data(); }
|
||||
void member_localeAwareCompare_QStringView_QStringView() { member_localeAwareCompare_impl<QStringView, QStringView>(); }
|
||||
|
||||
private:
|
||||
void startsWith_data(bool rhsIsQChar = false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user