diff options
Diffstat (limited to 'src/corelib/text/qstringview.cpp')
-rw-r--r-- | src/corelib/text/qstringview.cpp | 88 |
1 files changed, 65 insertions, 23 deletions
diff --git a/src/corelib/text/qstringview.cpp b/src/corelib/text/qstringview.cpp index e72980ef89..29b83ffe8f 100644 --- a/src/corelib/text/qstringview.cpp +++ b/src/corelib/text/qstringview.cpp @@ -179,7 +179,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn template <typename Char> QStringView::QStringView(const Char *str, qsizetype len) + \fn template <typename Char, QStringView::if_compatible_char<Char> = true> QStringView::QStringView(const Char *str, qsizetype len) Constructs a string view on \a str with length \a len. @@ -195,7 +195,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn template <typename Char> QStringView::QStringView(const Char *first, const Char *last) + \fn template <typename Char, QStringView::if_compatible_char<Char> = true> QStringView::QStringView(const Char *first, const Char *last) Constructs a string view on \a first with length (\a last - \a first). @@ -262,26 +262,26 @@ QT_BEGIN_NAMESPACE */ /*! - \fn template <typename Container, if_compatible_container<Container>> QStringView::QStringView(const Container &str) + \fn template <typename Container, QStringView::if_compatible_container<Container>> QStringView::QStringView(const Container &str) - Constructs a string view on \a str. The length is taken from \c{str.size()}. + Constructs a string view on \a str. The length is taken from \c{std::size(str)}. - \c{str.data()} must remain valid for the lifetime of this string view object. + \c{std::data(str)} must remain valid for the lifetime of this string view object. - This constructor only participates in overload resolution if \c StdBasicString is an - instantiation of \c std::basic_string with a compatible character type. The + This constructor only participates in overload resolution if \c Container is a + container with a compatible character type as \c{value_type}. The compatible character types are: \c QChar, \c ushort, \c char16_t and (on platforms, such as Windows, where it is a 16-bit type) \c wchar_t. - The string view will be empty if and only if \c{str.empty()}. It is unspecified - whether this constructor can result in a null string view (\c{str.data()} would + The string view will be empty if and only if \c{std::size(str) == 0}. It is unspecified + whether this constructor can result in a null string view (\c{std::data(str)} would have to return \nullptr for this). \sa isNull(), isEmpty() */ /*! - \fn template <typename Char, size_t Size> static QStringView QStringView::fromArray(const Char (&string)[Size]) noexcept + \fn template <typename Char, size_t Size, QStringView::if_compatible_char<Char> = true> static QStringView QStringView::fromArray(const Char (&string)[Size]) noexcept Constructs a string view on the full character string literal \a string, including any trailing \c{Char(0)}. If you don't want the @@ -471,7 +471,7 @@ QT_BEGIN_NAMESPACE /*! \fn qsizetype QStringView::size() const - Returns the size of this string view, in UTF-16 code points (that is, + Returns the size of this string view, in UTF-16 code units (that is, surrogate pairs count as two for the purposes of this function, the same as in QString). @@ -654,8 +654,10 @@ QT_BEGIN_NAMESPACE Returns a string view that points to \a n characters of this string view, starting at position \a pos. +//! [UB-sliced-index-length] \note The behavior is undefined when \a pos < 0, \a n < 0, or \a pos + \a n > size(). +//! [UB-sliced-index-length] \sa first(), last(), chopped(), chop(), truncate() */ @@ -668,7 +670,9 @@ QT_BEGIN_NAMESPACE Returns a string view starting at position \a pos in this object, and extending to its end. +//! [UB-sliced-index-only] \note The behavior is undefined when \a pos < 0 or \a pos > size(). +//! [UB-sliced-index-only] \sa first(), last(), chopped(), chop(), truncate() */ @@ -724,8 +728,9 @@ QT_BEGIN_NAMESPACE \fn int QStringView::compare(QStringView str, Qt::CaseSensitivity cs) const \since 5.12 - Returns an integer that compares to zero as this string view compares to the - string view \a str. + Compares this string view with string view \a str and returns a negative integer if + this string view is less than \a str, a positive integer if it is greater than + \a str, and zero if they are equal. \include qstring.qdocinc {search-comparison-case-sensitivity} {comparison} @@ -736,8 +741,9 @@ QT_BEGIN_NAMESPACE \fn int QStringView::compare(QUtf8StringView str, Qt::CaseSensitivity cs) const \since 6.5 - Returns an integer that compares to zero as this string view compares to the - string view \a str. + Compares this string view with QUtf8StringView \a str and returns a negative integer if + this string view is less than \a str, a positive integer if it is greater than + \a str, and zero if they are equal. \include qstring.qdocinc {search-comparison-case-sensitivity} {comparison} @@ -750,8 +756,9 @@ QT_BEGIN_NAMESPACE \fn int QStringView::compare(QChar ch, Qt::CaseSensitivity cs) const \since 5.15 - Returns an integer that compares to zero as this string view compares to the - Latin-1 string viewed by \a l1, or the character \a ch, respectively. + Compares this string view to the Latin-1 string view \a l1, or the character \a ch. + Returns a negative integer if this string view is less than \a l1 or \a ch, + a positive integer if it is greater than \a l1 or \a ch, and zero if they are equal. \include qstring.qdocinc {search-comparison-case-sensitivity} {comparison} @@ -759,12 +766,12 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QStringView::operator==(QStringView lhs, QStringView rhs) - \fn QStringView::operator!=(QStringView lhs, QStringView rhs) - \fn QStringView::operator< (QStringView lhs, QStringView rhs) - \fn QStringView::operator<=(QStringView lhs, QStringView rhs) - \fn QStringView::operator> (QStringView lhs, QStringView rhs) - \fn QStringView::operator>=(QStringView lhs, QStringView rhs) + \fn QStringView::operator==(const QStringView &lhs, const QStringView &rhs) + \fn QStringView::operator!=(const QStringView &lhs, const QStringView &rhs) + \fn QStringView::operator< (const QStringView &lhs, const QStringView &rhs) + \fn QStringView::operator<=(const QStringView &lhs, const QStringView &rhs) + \fn QStringView::operator> (const QStringView &lhs, const QStringView &rhs) + \fn QStringView::operator>=(const QStringView &lhs, const QStringView &rhs) Operators for comparing \a lhs to \a rhs. @@ -1090,6 +1097,32 @@ or the character \a ch */ /*! + \fn bool QStringView::isLower() const + \since 6.7 + Returns \c true if this view is identical to its lowercase folding. + + Note that this does \e not mean that the string view does not contain + uppercase letters (some uppercase letters do not have a lowercase + folding; they are left unchanged by toString().toLower()). + For more information, refer to the Unicode standard, section 3.13. + + \sa QChar::toLower(), isUpper() +*/ + +/*! + \fn bool QStringView::isUpper() const + \since 6.7 + Returns \c true if this view is identical to its uppercase folding. + + Note that this does \e not mean that the the string view does not contain + lowercase letters (some lowercase letters do not have a uppercase + folding; they are left unchanged by toString().toUpper()). + For more information, refer to the Unicode standard, section 3.13. + + \sa QChar::toUpper(), isLower() +*/ + +/*! \fn QStringView::toWCharArray(wchar_t *array) const \since 5.14 @@ -1411,4 +1444,13 @@ or the character \a ch \sa QStringTokenizer, qTokenize() */ +/*! + \fn QStringView::operator std::u16string_view() const + \since 6.7 + + Converts this QStringView object to a \c{std::u16string_view} object. + The returned view will have the same data pointer and length of + this view. +*/ + QT_END_NAMESPACE |