diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index a46ff1e881..d6a87378ee 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -10907,6 +10907,46 @@ static inline bool qt_starts_with(QStringView haystack, QChar needle, Qt::CaseSe : foldCase(haystack.front()) == foldCase(needle)); } +/*! + \fn bool qStartsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs) + \since 5.10 + \fn bool qStartsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs) + \since 5.10 + \fn bool qStartsWith(QLatin1String haystack, QStringview needle, Qt::CaseSensitivity cs) + \since 5.10 + \fn bool qStartsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs) + \since 5.10 + \relates QStringView + + Returns \c true if \a haystack starts with \a needle, + otherwise returns \c false. + + If \a cs is Qt::CaseSensitive (the default), the search is case-sensitive; + otherwise the search is case-insensitive. + + \sa qEndsWith(), QString::endsWith(), QStringView::endsWith(), QLatin1String::endsWith() +*/ + +bool qStartsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +{ + return qt_starts_with_impl(haystack, needle, cs); +} + +bool qStartsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +{ + return qt_starts_with_impl(haystack, needle, cs); +} + +bool qStartsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +{ + return qt_starts_with_impl(haystack, needle, cs); +} + +bool qStartsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +{ + return qt_starts_with_impl(haystack, needle, cs); +} + template bool qt_ends_with_impl(Haystack haystack, Needle needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW { @@ -10939,6 +10979,46 @@ static inline bool qt_ends_with(QStringView haystack, QChar needle, Qt::CaseSens : foldCase(haystack.back()) == foldCase(needle)); } +/*! + \fn bool qEndsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs) + \since 5.10 + \fn bool qEndsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs) + \since 5.10 + \fn bool qEndsWith(QLatin1String haystack, QStringview needle, Qt::CaseSensitivity cs) + \since 5.10 + \fn bool qEndsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs) + \since 5.10 + \relates QStringView + + Returns \c true if \a haystack ends with \a needle, + otherwise returns \c false. + + If \a cs is Qt::CaseSensitive (the default), the search is case-sensitive; + otherwise the search is case-insensitive. + + \sa qEndsWith(), QString::endsWith(), QStringView::endsWith(), QLatin1String::endsWith() +*/ + +bool qEndsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +{ + return qt_ends_with_impl(haystack, needle, cs); +} + +bool qEndsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +{ + return qt_ends_with_impl(haystack, needle, cs); +} + +bool qEndsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +{ + return qt_ends_with_impl(haystack, needle, cs); +} + +bool qEndsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +{ + return qt_ends_with_impl(haystack, needle, cs); +} + /*! \since 4.8 diff --git a/src/corelib/tools/qstringalgorithms.h b/src/corelib/tools/qstringalgorithms.h index 29fefd4cf5..91d85cb76b 100644 --- a/src/corelib/tools/qstringalgorithms.h +++ b/src/corelib/tools/qstringalgorithms.h @@ -58,6 +58,18 @@ Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int qCompareStrings(QStringView lhs, QLatin Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int qCompareStrings(QLatin1String lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW Q_REQUIRED_RESULT; Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int qCompareStrings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW Q_REQUIRED_RESULT; + +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool qStartsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool qStartsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool qStartsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool qStartsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; + +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool qEndsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool qEndsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool qEndsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool qEndsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; + + Q_CORE_EXPORT QByteArray qConvertToLatin1(QStringView str) Q_REQUIRED_RESULT; Q_CORE_EXPORT QByteArray qConvertToUtf8(QStringView str) Q_REQUIRED_RESULT; Q_CORE_EXPORT QByteArray qConvertToLocal8Bit(QStringView str) Q_REQUIRED_RESULT;