Struct qt_core::QStringView

source ·
#[repr(C)]
pub struct QStringView { /* private fields */ }
Expand description

The QStringView class provides a unified view on UTF-16 strings with a read-only subset of the QString API.

C++ class: QStringView.

C++ documentation:

The QStringView class provides a unified view on UTF-16 strings with a read-only subset of the QString API.

A QStringView references a contiguous portion of a UTF-16 string it does not own. It acts as an interface type to all kinds of UTF-16 string, without the need to construct a QString first.

The UTF-16 string may be represented as an array (or an array-compatible data-structure such as QString, std::basic_string, etc.) of QChar, ushort, char16_t (on compilers that support C++11 Unicode strings) or (on platforms, such as Windows, where it is a 16-bit type) wchar_t.

QStringView is designed as an interface type; its main use-case is as a function parameter type. When QStringViews are used as automatic variables or data members, care must be taken to ensure that the referenced string data (for example, owned by a QString) outlives the QStringView on all code paths, lest the string view ends up referencing deleted data.

When used as an interface type, QStringView allows a single function to accept a wide variety of UTF-16 string data sources. One function accepting QStringView thus replaces three function overloads (taking QString, QStringRef, and (const QChar*, int)), while at the same time enabling even more string data sources to be passed to the function, such as u"Hello World", a char16_t string literal.

QStringViews should be passed by value, not by reference-to-const:

void myfun1(QStringView sv); // preferred void myfun2(const QStringView &sv); // compiles and works, but slower

If you want to give your users maximum freedom in what strings they can pass to your function, accompany the QStringView overload with overloads for

  • QChar: this overload can delegate to the QStringView version:

    void fun(QChar ch) { fun(QStringView(&ch, 1)); }

    even though, for technical reasons, QStringView cannot provide a QChar constructor by itself.

  • QString: if you store an unmodified copy of the string and thus would like to take advantage of QString's implicit sharing.
  • QLatin1String: if you can implement the function without converting the QLatin1String to UTF-16 first; users expect a function overloaded on QLatin1String to perform strictly less memory allocations than the semantically equivalent call of the QStringView version, involving construction of a QString from the QLatin1String.

QStringView can also be used as the return value of a function. If you call a function returning QStringView, take extra care to not keep the QStringView around longer than the function promises to keep the referenced string data alive. If in doubt, obtain a strong reference to the data by calling toString() to convert the QStringView into a QString.

QStringView is a Literal Type, but since it stores data as char16_t, iteration is not constexpr (casts from const char16_t* to const QChar*, which is not allowed in constexpr functions). You can use an indexed loop and/or utf16() in constexpr contexts instead.

Note: We strongly discourage the use of QList<QStringView>, because QList is a very inefficient container for QStringViews (it would heap-allocate every element). Use QVector (or std::vector) to hold QStringViews instead.

Implementations§

source§

impl QStringView

source

pub unsafe fn at(&self, n: c_longlong) -> CppBox<QChar>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns the character at position n in this string view.

Calls C++ function: QChar QStringView::at(long long n) const.

C++ documentation:

Returns the character at position n in this string view.

The behavior is undefined if n is negative or not less than size().

See also operator[](), front(), and back().

source

pub unsafe fn back(&self) -> CppBox<QChar>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns the last character in the string. Same as last().

Calls C++ function: QChar QStringView::back() const.

C++ documentation:

Returns the last character in the string. Same as last().

This function is provided for STL compatibility.

Warning: Calling this function on an empty string view constitutes undefined behavior.

See also front(), first(), and last().

source

pub unsafe fn begin(&self) -> Ptr<QChar>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns a const STL-style iterator pointing to the first character in the string.

Calls C++ function: const QChar* QStringView::begin() const.

C++ documentation:

Returns a const STL-style iterator pointing to the first character in the string.

This function is provided for STL compatibility.

See also end(), cbegin(), rbegin(), and data().

source

pub unsafe fn cbegin(&self) -> Ptr<QChar>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Same as begin().

Calls C++ function: const QChar* QStringView::cbegin() const.

C++ documentation:

Same as begin().

This function is provided for STL compatibility.

See also cend(), begin(), crbegin(), and data().

source

pub unsafe fn cend(&self) -> Ptr<QChar>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Same as end().

Calls C++ function: const QChar* QStringView::cend() const.

C++ documentation:

Same as end().

This function is provided for STL compatibility.

See also cbegin(), end(), and crend().

source

pub unsafe fn chop(&self, n: c_longlong)

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Truncates this string view by length characters.

Calls C++ function: void QStringView::chop(long long n).

C++ documentation:

Truncates this string view by length characters.

Same as *this = left(size() - length).

Note: The behavior is undefined when length < 0 or length > size().

See also mid(), left(), right(), chopped(), and truncate().

source

pub unsafe fn chopped(&self, n: c_longlong) -> CppBox<QStringView>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns the substring of length size() - length starting at the beginning of this object.

Calls C++ function: QStringView QStringView::chopped(long long n) const.

C++ documentation:

Returns the substring of length size() - length starting at the beginning of this object.

Same as left(size() - length).

Note: The behavior is undefined when length < 0 or length > size().

See also mid(), left(), right(), chop(), and truncate().

source

pub unsafe fn compare_2a( &self, other: impl CastInto<Ref<QStringView>>, cs: CaseSensitivity ) -> c_int

Available on cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Compares this string-view with the 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 other string-view.

Calls C++ function: int QStringView::compare(QStringView other, Qt::CaseSensitivity cs = …) const.

C++ documentation:

Compares this string-view with the 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 other string-view.

If cs is Qt::CaseSensitive, the comparison is case sensitive; otherwise the comparison is case insensitive.

This function was introduced in Qt 5.12.

See also operator==(), operator<(), and operator>().

source

pub unsafe fn compare_1a(&self, other: impl CastInto<Ref<QStringView>>) -> c_int

Available on cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Compares this string-view with the 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 other string-view.

Calls C++ function: int QStringView::compare(QStringView other) const.

C++ documentation:

Compares this string-view with the 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 other string-view.

If cs is Qt::CaseSensitive, the comparison is case sensitive; otherwise the comparison is case insensitive.

This function was introduced in Qt 5.12.

See also operator==(), operator<(), and operator>().

source

pub unsafe fn contains_q_char_case_sensitivity( &self, c: impl CastInto<Ref<QChar>>, cs: CaseSensitivity ) -> bool

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: bool QStringView::contains(QChar c, Qt::CaseSensitivity cs = …) const.

source

pub unsafe fn contains_q_string_view_case_sensitivity( &self, s: impl CastInto<Ref<QStringView>>, cs: CaseSensitivity ) -> bool

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: bool QStringView::contains(QStringView s, Qt::CaseSensitivity cs = …) const.

source

pub unsafe fn contains_q_latin1_string_case_sensitivity( &self, s: impl CastInto<Ref<QLatin1String>>, cs: CaseSensitivity ) -> bool

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: bool QStringView::contains(QLatin1String s, Qt::CaseSensitivity cs = …) const.

source

pub unsafe fn contains_q_char(&self, c: impl CastInto<Ref<QChar>>) -> bool

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: bool QStringView::contains(QChar c) const.

source

pub unsafe fn contains_q_string_view( &self, s: impl CastInto<Ref<QStringView>> ) -> bool

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: bool QStringView::contains(QStringView s) const.

source

pub unsafe fn contains_q_latin1_string( &self, s: impl CastInto<Ref<QLatin1String>> ) -> bool

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: bool QStringView::contains(QLatin1String s) const.

source

pub unsafe fn copy_from( &self, other: impl CastInto<Ref<QStringView>> ) -> Ref<QStringView>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

The QStringView class provides a unified view on UTF-16 strings with a read-only subset of the QString API.

Calls C++ function: QStringView& QStringView::operator=(const QStringView& other).

C++ documentation:

The QStringView class provides a unified view on UTF-16 strings with a read-only subset of the QString API.

A QStringView references a contiguous portion of a UTF-16 string it does not own. It acts as an interface type to all kinds of UTF-16 string, without the need to construct a QString first.

The UTF-16 string may be represented as an array (or an array-compatible data-structure such as QString, std::basic_string, etc.) of QChar, ushort, char16_t (on compilers that support C++11 Unicode strings) or (on platforms, such as Windows, where it is a 16-bit type) wchar_t.

QStringView is designed as an interface type; its main use-case is as a function parameter type. When QStringViews are used as automatic variables or data members, care must be taken to ensure that the referenced string data (for example, owned by a QString) outlives the QStringView on all code paths, lest the string view ends up referencing deleted data.

When used as an interface type, QStringView allows a single function to accept a wide variety of UTF-16 string data sources. One function accepting QStringView thus replaces three function overloads (taking QString, QStringRef, and (const QChar*, int)), while at the same time enabling even more string data sources to be passed to the function, such as u"Hello World", a char16_t string literal.

QStringViews should be passed by value, not by reference-to-const:

void myfun1(QStringView sv); // preferred void myfun2(const QStringView &sv); // compiles and works, but slower

If you want to give your users maximum freedom in what strings they can pass to your function, accompany the QStringView overload with overloads for

  • QChar: this overload can delegate to the QStringView version:

    void fun(QChar ch) { fun(QStringView(&ch, 1)); }

    even though, for technical reasons, QStringView cannot provide a QChar constructor by itself.

  • QString: if you store an unmodified copy of the string and thus would like to take advantage of QString's implicit sharing.
  • QLatin1String: if you can implement the function without converting the QLatin1String to UTF-16 first; users expect a function overloaded on QLatin1String to perform strictly less memory allocations than the semantically equivalent call of the QStringView version, involving construction of a QString from the QLatin1String.

QStringView can also be used as the return value of a function. If you call a function returning QStringView, take extra care to not keep the QStringView around longer than the function promises to keep the referenced string data alive. If in doubt, obtain a strong reference to the data by calling toString() to convert the QStringView into a QString.

QStringView is a Literal Type, but since it stores data as char16_t, iteration is not constexpr (casts from const char16_t* to const QChar*, which is not allowed in constexpr functions). You can use an indexed loop and/or utf16() in constexpr contexts instead.

Note: We strongly discourage the use of QList<QStringView>, because QList is a very inefficient container for QStringViews (it would heap-allocate every element). Use QVector (or std::vector) to hold QStringViews instead.

source

pub unsafe fn data(&self) -> Ptr<QChar>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns a const pointer to the first character in the string.

Calls C++ function: const QChar* QStringView::data() const.

C++ documentation:

Returns a const pointer to the first character in the string.

Note: The character array represented by the return value is not null-terminated.

See also begin(), end(), and utf16().

source

pub unsafe fn empty(&self) -> bool

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns whether this string view is empty - that is, whether size() == 0.

Calls C++ function: bool QStringView::empty() const.

C++ documentation:

Returns whether this string view is empty - that is, whether size() == 0.

This function is provided for STL compatibility.

See also isEmpty(), isNull(), size(), and length().

source

pub unsafe fn end(&self) -> Ptr<QChar>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns a const STL-style iterator pointing to the imaginary character after the last character in the list.

Calls C++ function: const QChar* QStringView::end() const.

C++ documentation:

Returns a const STL-style iterator pointing to the imaginary character after the last character in the list.

This function is provided for STL compatibility.

See also begin(), cend(), and rend().

source

pub unsafe fn ends_with_q_string_view_case_sensitivity( &self, s: impl CastInto<Ref<QStringView>>, cs: CaseSensitivity ) -> bool

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Calls C++ function: bool QStringView::endsWith(QStringView s, Qt::CaseSensitivity cs = …) const.

source

pub unsafe fn ends_with_q_latin1_string_case_sensitivity( &self, s: impl CastInto<Ref<QLatin1String>>, cs: CaseSensitivity ) -> bool

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Calls C++ function: bool QStringView::endsWith(QLatin1String s, Qt::CaseSensitivity cs = …) const.

source

pub unsafe fn ends_with_q_char(&self, c: impl CastInto<Ref<QChar>>) -> bool

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Calls C++ function: bool QStringView::endsWith(QChar c) const.

source

pub unsafe fn ends_with_q_char_case_sensitivity( &self, c: impl CastInto<Ref<QChar>>, cs: CaseSensitivity ) -> bool

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Calls C++ function: bool QStringView::endsWith(QChar c, Qt::CaseSensitivity cs) const.

source

pub unsafe fn ends_with_q_string_view( &self, s: impl CastInto<Ref<QStringView>> ) -> bool

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Calls C++ function: bool QStringView::endsWith(QStringView s) const.

source

pub unsafe fn ends_with_q_latin1_string( &self, s: impl CastInto<Ref<QLatin1String>> ) -> bool

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Calls C++ function: bool QStringView::endsWith(QLatin1String s) const.

source

pub unsafe fn first(&self) -> CppBox<QChar>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns the first character in the string. Same as front().

Calls C++ function: QChar QStringView::first() const.

C++ documentation:

Returns the first character in the string. Same as front().

This function is provided for compatibility with other Qt containers.

Warning: Calling this function on an empty string view constitutes undefined behavior.

See also front(), back(), and last().

source

pub unsafe fn front(&self) -> CppBox<QChar>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns the first character in the string. Same as first().

Calls C++ function: QChar QStringView::front() const.

C++ documentation:

Returns the first character in the string. Same as first().

This function is provided for STL compatibility.

Warning: Calling this function on an empty string view constitutes undefined behavior.

See also back(), first(), and last().

source

pub unsafe fn index(&self, n: c_longlong) -> CppBox<QChar>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns the character at position n in this string view.

Calls C++ function: QChar QStringView::operator[](long long n) const.

C++ documentation:

Returns the character at position n in this string view.

The behavior is undefined if n is negative or not less than size().

See also at(), front(), and back().

source

pub unsafe fn index_of_q_char_longlong_case_sensitivity( &self, c: impl CastInto<Ref<QChar>>, from: c_longlong, cs: CaseSensitivity ) -> c_longlong

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: long long QStringView::indexOf(QChar c, long long from = …, Qt::CaseSensitivity cs = …) const.

source

pub unsafe fn index_of_q_string_view_longlong_case_sensitivity( &self, s: impl CastInto<Ref<QStringView>>, from: c_longlong, cs: CaseSensitivity ) -> c_longlong

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: long long QStringView::indexOf(QStringView s, long long from = …, Qt::CaseSensitivity cs = …) const.

source

pub unsafe fn index_of_q_latin1_string_longlong_case_sensitivity( &self, s: impl CastInto<Ref<QLatin1String>>, from: c_longlong, cs: CaseSensitivity ) -> c_longlong

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: long long QStringView::indexOf(QLatin1String s, long long from = …, Qt::CaseSensitivity cs = …) const.

source

pub unsafe fn index_of_q_char_longlong( &self, c: impl CastInto<Ref<QChar>>, from: c_longlong ) -> c_longlong

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: long long QStringView::indexOf(QChar c, long long from = …) const.

source

pub unsafe fn index_of_q_char(&self, c: impl CastInto<Ref<QChar>>) -> c_longlong

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: long long QStringView::indexOf(QChar c) const.

source

pub unsafe fn index_of_q_string_view_longlong( &self, s: impl CastInto<Ref<QStringView>>, from: c_longlong ) -> c_longlong

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: long long QStringView::indexOf(QStringView s, long long from = …) const.

source

pub unsafe fn index_of_q_string_view( &self, s: impl CastInto<Ref<QStringView>> ) -> c_longlong

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: long long QStringView::indexOf(QStringView s) const.

source

pub unsafe fn index_of_q_latin1_string_longlong( &self, s: impl CastInto<Ref<QLatin1String>>, from: c_longlong ) -> c_longlong

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: long long QStringView::indexOf(QLatin1String s, long long from = …) const.

source

pub unsafe fn index_of_q_latin1_string( &self, s: impl CastInto<Ref<QLatin1String>> ) -> c_longlong

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: long long QStringView::indexOf(QLatin1String s) const.

source

pub unsafe fn is_empty(&self) -> bool

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns whether this string view is empty - that is, whether size() == 0.

Calls C++ function: bool QStringView::isEmpty() const.

C++ documentation:

Returns whether this string view is empty - that is, whether size() == 0.

This function is provided for compatibility with other Qt containers.

See also empty(), isNull(), size(), and length().

source

pub unsafe fn is_null(&self) -> bool

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns whether this string view is null - that is, whether data() == nullptr.

Calls C++ function: bool QStringView::isNull() const.

C++ documentation:

Returns whether this string view is null - that is, whether data() == nullptr.

This functions is provided for compatibility with other Qt containers.

See also empty(), isEmpty(), size(), and length().

source

pub unsafe fn is_right_to_left(&self) -> bool

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns true if the string is read right to left.

Calls C++ function: bool QStringView::isRightToLeft() const.

C++ documentation:

Returns true if the string is read right to left.

This function was introduced in Qt 5.11.

See also QString::isRightToLeft().

source

pub unsafe fn last(&self) -> CppBox<QChar>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns the last character in the string. Same as back().

Calls C++ function: QChar QStringView::last() const.

C++ documentation:

Returns the last character in the string. Same as back().

This function is provided for compatibility with other Qt containers.

Warning: Calling this function on an empty string view constitutes undefined behavior.

See also back(), front(), and first().

source

pub unsafe fn last_index_of_q_char_longlong_case_sensitivity( &self, c: impl CastInto<Ref<QChar>>, from: c_longlong, cs: CaseSensitivity ) -> c_longlong

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: long long QStringView::lastIndexOf(QChar c, long long from = …, Qt::CaseSensitivity cs = …) const.

source

pub unsafe fn last_index_of_q_string_view_longlong_case_sensitivity( &self, s: impl CastInto<Ref<QStringView>>, from: c_longlong, cs: CaseSensitivity ) -> c_longlong

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: long long QStringView::lastIndexOf(QStringView s, long long from = …, Qt::CaseSensitivity cs = …) const.

source

pub unsafe fn last_index_of_q_latin1_string_longlong_case_sensitivity( &self, s: impl CastInto<Ref<QLatin1String>>, from: c_longlong, cs: CaseSensitivity ) -> c_longlong

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: long long QStringView::lastIndexOf(QLatin1String s, long long from = …, Qt::CaseSensitivity cs = …) const.

source

pub unsafe fn last_index_of_q_char_longlong( &self, c: impl CastInto<Ref<QChar>>, from: c_longlong ) -> c_longlong

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: long long QStringView::lastIndexOf(QChar c, long long from = …) const.

source

pub unsafe fn last_index_of_q_char( &self, c: impl CastInto<Ref<QChar>> ) -> c_longlong

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: long long QStringView::lastIndexOf(QChar c) const.

source

pub unsafe fn last_index_of_q_string_view_longlong( &self, s: impl CastInto<Ref<QStringView>>, from: c_longlong ) -> c_longlong

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: long long QStringView::lastIndexOf(QStringView s, long long from = …) const.

source

pub unsafe fn last_index_of_q_string_view( &self, s: impl CastInto<Ref<QStringView>> ) -> c_longlong

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: long long QStringView::lastIndexOf(QStringView s) const.

source

pub unsafe fn last_index_of_q_latin1_string_longlong( &self, s: impl CastInto<Ref<QLatin1String>>, from: c_longlong ) -> c_longlong

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: long long QStringView::lastIndexOf(QLatin1String s, long long from = …) const.

source

pub unsafe fn last_index_of_q_latin1_string( &self, s: impl CastInto<Ref<QLatin1String>> ) -> c_longlong

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: long long QStringView::lastIndexOf(QLatin1String s) const.

source

pub unsafe fn left(&self, n: c_longlong) -> CppBox<QStringView>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns the substring of length length starting at position 0 in this object.

Calls C++ function: QStringView QStringView::left(long long n) const.

C++ documentation:

Returns the substring of length length starting at position 0 in this object.

Note: The behavior is undefined when length < 0 or length > size().

See also mid(), right(), chopped(), chop(), and truncate().

source

pub unsafe fn length(&self) -> c_int

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Same as size(), except returns the result as an int.

Calls C++ function: int QStringView::length() const.

C++ documentation:

Same as size(), except returns the result as an int.

This function is provided for compatibility with other Qt containers.

Warning: QStringView can represent strings with more than 231 characters. Calling this function on a string view for which size() returns a value greater than INT_MAX constitutes undefined behavior.

See also empty(), isEmpty(), isNull(), and size().

source

pub unsafe fn mid_1a(&self, pos: c_longlong) -> CppBox<QStringView>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns the substring starting at position start in this object, and extending to the end of the string.

Calls C++ function: QStringView QStringView::mid(long long pos) const.

C++ documentation:

Returns the substring starting at position start in this object, and extending to the end of the string.

Note: The behavior is undefined when start < 0 or start > size().

See also left(), right(), chopped(), chop(), and truncate().

source

pub unsafe fn mid_2a( &self, pos: c_longlong, n: c_longlong ) -> CppBox<QStringView>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

This is an overloaded function.

Calls C++ function: QStringView QStringView::mid(long long pos, long long n) const.

C++ documentation:

This is an overloaded function.

Returns the substring of length length starting at position start in this object.

Note: The behavior is undefined when start < 0, length < 0, or start + length > size().

See also left(), right(), chopped(), chop(), and truncate().

source

pub unsafe fn new() -> CppBox<QStringView>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Constructs a null string view.

Calls C++ function: [constructor] void QStringView::QStringView().

C++ documentation:

Constructs a null string view.

See also isNull().

source

pub unsafe fn new_copy( other: impl CastInto<Ref<QStringView>> ) -> CppBox<QStringView>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

The QStringView class provides a unified view on UTF-16 strings with a read-only subset of the QString API.

Calls C++ function: [constructor] void QStringView::QStringView(const QStringView& other).

C++ documentation:

The QStringView class provides a unified view on UTF-16 strings with a read-only subset of the QString API.

A QStringView references a contiguous portion of a UTF-16 string it does not own. It acts as an interface type to all kinds of UTF-16 string, without the need to construct a QString first.

The UTF-16 string may be represented as an array (or an array-compatible data-structure such as QString, std::basic_string, etc.) of QChar, ushort, char16_t (on compilers that support C++11 Unicode strings) or (on platforms, such as Windows, where it is a 16-bit type) wchar_t.

QStringView is designed as an interface type; its main use-case is as a function parameter type. When QStringViews are used as automatic variables or data members, care must be taken to ensure that the referenced string data (for example, owned by a QString) outlives the QStringView on all code paths, lest the string view ends up referencing deleted data.

When used as an interface type, QStringView allows a single function to accept a wide variety of UTF-16 string data sources. One function accepting QStringView thus replaces three function overloads (taking QString, QStringRef, and (const QChar*, int)), while at the same time enabling even more string data sources to be passed to the function, such as u"Hello World", a char16_t string literal.

QStringViews should be passed by value, not by reference-to-const:

void myfun1(QStringView sv); // preferred void myfun2(const QStringView &sv); // compiles and works, but slower

If you want to give your users maximum freedom in what strings they can pass to your function, accompany the QStringView overload with overloads for

  • QChar: this overload can delegate to the QStringView version:

    void fun(QChar ch) { fun(QStringView(&ch, 1)); }

    even though, for technical reasons, QStringView cannot provide a QChar constructor by itself.

  • QString: if you store an unmodified copy of the string and thus would like to take advantage of QString's implicit sharing.
  • QLatin1String: if you can implement the function without converting the QLatin1String to UTF-16 first; users expect a function overloaded on QLatin1String to perform strictly less memory allocations than the semantically equivalent call of the QStringView version, involving construction of a QString from the QLatin1String.

QStringView can also be used as the return value of a function. If you call a function returning QStringView, take extra care to not keep the QStringView around longer than the function promises to keep the referenced string data alive. If in doubt, obtain a strong reference to the data by calling toString() to convert the QStringView into a QString.

QStringView is a Literal Type, but since it stores data as char16_t, iteration is not constexpr (casts from const char16_t* to const QChar*, which is not allowed in constexpr functions). You can use an indexed loop and/or utf16() in constexpr contexts instead.

Note: We strongly discourage the use of QList<QStringView>, because QList is a very inefficient container for QStringViews (it would heap-allocate every element). Use QVector (or std::vector) to hold QStringViews instead.

source

pub unsafe fn right(&self, n: c_longlong) -> CppBox<QStringView>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns the substring of length length starting at position size() - length in this object.

Calls C++ function: QStringView QStringView::right(long long n) const.

C++ documentation:

Returns the substring of length length starting at position size() - length in this object.

Note: The behavior is undefined when length < 0 or length > size().

See also mid(), left(), chopped(), chop(), and truncate().

source

pub unsafe fn size(&self) -> c_longlong

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns the size of this string view, in UTF-16 code points (that is, surrogate pairs count as two for the purposes of this function, the same as in QString and QStringRef).

Calls C++ function: long long QStringView::size() const.

C++ documentation:

Returns the size of this string view, in UTF-16 code points (that is, surrogate pairs count as two for the purposes of this function, the same as in QString and QStringRef).

See also empty(), isEmpty(), isNull(), and length().

source

pub unsafe fn starts_with_q_string_view_case_sensitivity( &self, s: impl CastInto<Ref<QStringView>>, cs: CaseSensitivity ) -> bool

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Calls C++ function: bool QStringView::startsWith(QStringView s, Qt::CaseSensitivity cs = …) const.

source

pub unsafe fn starts_with_q_latin1_string_case_sensitivity( &self, s: impl CastInto<Ref<QLatin1String>>, cs: CaseSensitivity ) -> bool

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Calls C++ function: bool QStringView::startsWith(QLatin1String s, Qt::CaseSensitivity cs = …) const.

source

pub unsafe fn starts_with_q_char(&self, c: impl CastInto<Ref<QChar>>) -> bool

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Calls C++ function: bool QStringView::startsWith(QChar c) const.

source

pub unsafe fn starts_with_q_char_case_sensitivity( &self, c: impl CastInto<Ref<QChar>>, cs: CaseSensitivity ) -> bool

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Calls C++ function: bool QStringView::startsWith(QChar c, Qt::CaseSensitivity cs) const.

source

pub unsafe fn starts_with_q_string_view( &self, s: impl CastInto<Ref<QStringView>> ) -> bool

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Calls C++ function: bool QStringView::startsWith(QStringView s) const.

source

pub unsafe fn starts_with_q_latin1_string( &self, s: impl CastInto<Ref<QLatin1String>> ) -> bool

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Calls C++ function: bool QStringView::startsWith(QLatin1String s) const.

source

pub unsafe fn to_latin1(&self) -> CppBox<QByteArray>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns a Latin-1 representation of the string as a QByteArray.

Calls C++ function: QByteArray QStringView::toLatin1() const.

C++ documentation:

Returns a Latin-1 representation of the string as a QByteArray.

The behavior is undefined if the string contains non-Latin1 characters.

See also toUtf8(), toLocal8Bit(), and QTextCodec.

source

pub unsafe fn to_local8_bit(&self) -> CppBox<QByteArray>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns a local 8-bit representation of the string as a QByteArray.

Calls C++ function: QByteArray QStringView::toLocal8Bit() const.

C++ documentation:

Returns a local 8-bit representation of the string as a QByteArray.

QTextCodec::codecForLocale() is used to perform the conversion from Unicode. If the locale's encoding could not be determined, this function does the same as toLatin1().

The behavior is undefined if the string contains characters not supported by the locale's 8-bit encoding.

See also toLatin1(), toUtf8(), and QTextCodec.

source

pub unsafe fn to_string(&self) -> CppBox<QString>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns a deep copy of this string view's data as a QString.

Calls C++ function: QString QStringView::toString() const.

C++ documentation:

Returns a deep copy of this string view’s data as a QString.

The return value will be the null QString if and only if this string view is null.

Warning: QStringView can store strings with more than 230 characters while QString cannot. Calling this function on a string view for which size() returns a value greater than INT_MAX / 2 constitutes undefined behavior.

source

pub unsafe fn to_ucs4(&self) -> CppBox<QVectorOfUint>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns a UCS-4/UTF-32 representation of the string as a QVector<uint>.

Calls C++ function: QVector<unsigned int> QStringView::toUcs4() const.

C++ documentation:

Returns a UCS-4/UTF-32 representation of the string as a QVector<uint>.

UCS-4 is a Unicode codec and therefore it is lossless. All characters from this string will be encoded in UCS-4. Any invalid sequence of code units in this string is replaced by the Unicode replacement character (QChar::ReplacementCharacter, which corresponds to U+FFFD).

The returned vector is not 0-terminated.

See also toUtf8(), toLatin1(), toLocal8Bit(), and QTextCodec.

source

pub unsafe fn to_utf8(&self) -> CppBox<QByteArray>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns a UTF-8 representation of the string as a QByteArray.

Calls C++ function: QByteArray QStringView::toUtf8() const.

C++ documentation:

Returns a UTF-8 representation of the string as a QByteArray.

UTF-8 is a Unicode codec and can represent all characters in a Unicode string like QString.

See also toLatin1(), toLocal8Bit(), and QTextCodec.

source

pub unsafe fn to_w_char_array(&self, array: *mut wchar_t) -> c_int

Available on cpp_lib_version="5.14.0" only.

Transcribes this string into the given array.

Calls C++ function: int QStringView::toWCharArray(wchar_t* array) const.

C++ documentation:

Transcribes this string into the given array.

The caller is responsible for ensuring array is large enough to hold the wchar_t encoding of this string (allocating the array with the same length as the string is always sufficient). The array is encoded in UTF-16 on platforms where wchar_t is 2 bytes wide (e.g. Windows); otherwise (Unix systems), wchar_t is assumed to be 4 bytes wide and the data is written in UCS-4.

Note: This function writes no null terminator to the end of array.

Returns the number of wchar_t entries written to array.

This function was introduced in Qt 5.14.

See also QString::toWCharArray().

source

pub unsafe fn trimmed(&self) -> CppBox<QStringView>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Strips leading and trailing whitespace and returns the result.

Calls C++ function: QStringView QStringView::trimmed() const.

C++ documentation:

Strips leading and trailing whitespace and returns the result.

Whitespace means any character for which QChar::isSpace() returns true. This includes the ASCII characters '\t', '\n', '\v', '\f', '\r', and ' '.

source

pub unsafe fn truncate(&self, n: c_longlong)

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Truncates this string view to length length.

Calls C++ function: void QStringView::truncate(long long n).

C++ documentation:

Truncates this string view to length length.

Same as *this = left(length).

Note: The behavior is undefined when length < 0 or length > size().

See also mid(), left(), right(), chopped(), and chop().

source

pub unsafe fn utf16(&self) -> *const char16_t

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns a const pointer to the first character in the string.

Calls C++ function: const char16_t* QStringView::utf16() const.

C++ documentation:

Returns a const pointer to the first character in the string.

storage_type is char16_t.

Note: The character array represented by the return value is not null-terminated.

See also begin(), end(), and data().

Trait Implementations§

source§

impl Begin for QStringView

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.
source§

unsafe fn begin(&self) -> Ptr<QChar>

Returns a const STL-style iterator pointing to the first character in the string.

Calls C++ function: const QChar* QStringView::begin() const.

C++ documentation:

Returns a const STL-style iterator pointing to the first character in the string.

This function is provided for STL compatibility.

See also end(), cbegin(), rbegin(), and data().

§

type Output = Ptr<QChar>

Output type.
source§

impl CppDeletable for QStringView

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.
source§

unsafe fn delete(&self)

The QStringView class provides a unified view on UTF-16 strings with a read-only subset of the QString API.

Calls C++ function: [destructor] void QStringView::~QStringView().

C++ documentation:

The QStringView class provides a unified view on UTF-16 strings with a read-only subset of the QString API.

A QStringView references a contiguous portion of a UTF-16 string it does not own. It acts as an interface type to all kinds of UTF-16 string, without the need to construct a QString first.

The UTF-16 string may be represented as an array (or an array-compatible data-structure such as QString, std::basic_string, etc.) of QChar, ushort, char16_t (on compilers that support C++11 Unicode strings) or (on platforms, such as Windows, where it is a 16-bit type) wchar_t.

QStringView is designed as an interface type; its main use-case is as a function parameter type. When QStringViews are used as automatic variables or data members, care must be taken to ensure that the referenced string data (for example, owned by a QString) outlives the QStringView on all code paths, lest the string view ends up referencing deleted data.

When used as an interface type, QStringView allows a single function to accept a wide variety of UTF-16 string data sources. One function accepting QStringView thus replaces three function overloads (taking QString, QStringRef, and (const QChar*, int)), while at the same time enabling even more string data sources to be passed to the function, such as u"Hello World", a char16_t string literal.

QStringViews should be passed by value, not by reference-to-const:

void myfun1(QStringView sv); // preferred void myfun2(const QStringView &sv); // compiles and works, but slower

If you want to give your users maximum freedom in what strings they can pass to your function, accompany the QStringView overload with overloads for

  • QChar: this overload can delegate to the QStringView version:

    void fun(QChar ch) { fun(QStringView(&ch, 1)); }

    even though, for technical reasons, QStringView cannot provide a QChar constructor by itself.

  • QString: if you store an unmodified copy of the string and thus would like to take advantage of QString's implicit sharing.
  • QLatin1String: if you can implement the function without converting the QLatin1String to UTF-16 first; users expect a function overloaded on QLatin1String to perform strictly less memory allocations than the semantically equivalent call of the QStringView version, involving construction of a QString from the QLatin1String.

QStringView can also be used as the return value of a function. If you call a function returning QStringView, take extra care to not keep the QStringView around longer than the function promises to keep the referenced string data alive. If in doubt, obtain a strong reference to the data by calling toString() to convert the QStringView into a QString.

QStringView is a Literal Type, but since it stores data as char16_t, iteration is not constexpr (casts from const char16_t* to const QChar*, which is not allowed in constexpr functions). You can use an indexed loop and/or utf16() in constexpr contexts instead.

Note: We strongly discourage the use of QList<QStringView>, because QList is a very inefficient container for QStringViews (it would heap-allocate every element). Use QVector (or std::vector) to hold QStringViews instead.

source§

impl Data for QStringView

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.
source§

unsafe fn data(&self) -> Ptr<QChar>

Returns a const pointer to the first character in the string.

Calls C++ function: const QChar* QStringView::data() const.

C++ documentation:

Returns a const pointer to the first character in the string.

Note: The character array represented by the return value is not null-terminated.

See also begin(), end(), and utf16().

§

type Output = Ptr<QChar>

Return type of data() function.
source§

impl End for QStringView

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.
source§

unsafe fn end(&self) -> Ptr<QChar>

Returns a const STL-style iterator pointing to the imaginary character after the last character in the list.

Calls C++ function: const QChar* QStringView::end() const.

C++ documentation:

Returns a const STL-style iterator pointing to the imaginary character after the last character in the list.

This function is provided for STL compatibility.

See also begin(), cend(), and rend().

§

type Output = Ptr<QChar>

Output type.
source§

impl Ge<Ref<QChar>> for QStringView

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.
source§

unsafe fn ge(&self, rhs: &Ref<QChar>) -> bool

Returns true if the numeric Unicode value of c1 is greater than or equal to that of c2; otherwise returns false.

Calls C++ function: bool operator>=(QStringView lhs, QChar rhs).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator>=(QChar c1, QChar c2):

Returns true if the numeric Unicode value of c1 is greater than or equal to that of c2; otherwise returns false.

source§

impl Ge<Ref<QLatin1String>> for QStringView

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.
source§

unsafe fn ge(&self, rhs: &Ref<QLatin1String>) -> bool

Returns true if the numeric Unicode value of c1 is greater than or equal to that of c2; otherwise returns false.

Calls C++ function: bool operator>=(QStringView lhs, QLatin1String rhs).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator>=(QChar c1, QChar c2):

Returns true if the numeric Unicode value of c1 is greater than or equal to that of c2; otherwise returns false.

source§

impl Ge<Ref<QStringView>> for QStringView

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.
source§

unsafe fn ge(&self, rhs: &Ref<QStringView>) -> bool

Returns true if the numeric Unicode value of c1 is greater than or equal to that of c2; otherwise returns false.

Calls C++ function: bool operator>=(QStringView lhs, QStringView rhs).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator>=(QChar c1, QChar c2):

Returns true if the numeric Unicode value of c1 is greater than or equal to that of c2; otherwise returns false.

source§

impl Gt<Ref<QChar>> for QStringView

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.
source§

unsafe fn gt(&self, rhs: &Ref<QChar>) -> bool

Calls C++ function: bool operator>(QStringView lhs, QChar rhs).

source§

impl Gt<Ref<QLatin1String>> for QStringView

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.
source§

unsafe fn gt(&self, rhs: &Ref<QLatin1String>) -> bool

Calls C++ function: bool operator>(QStringView lhs, QLatin1String rhs).

source§

impl Gt<Ref<QStringView>> for QStringView

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.
source§

unsafe fn gt(&self, rhs: &Ref<QStringView>) -> bool

Calls C++ function: bool operator>(QStringView lhs, QStringView rhs).

source§

impl Le<Ref<QChar>> for QStringView

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.
source§

unsafe fn le(&self, rhs: &Ref<QChar>) -> bool

Returns true if the numeric Unicode value of c1 is less than or equal to that of c2; otherwise returns false.

Calls C++ function: bool operator<=(QStringView lhs, QChar rhs).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator<=(QChar c1, QChar c2):

Returns true if the numeric Unicode value of c1 is less than or equal to that of c2; otherwise returns false.

source§

impl Le<Ref<QLatin1String>> for QStringView

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.
source§

unsafe fn le(&self, rhs: &Ref<QLatin1String>) -> bool

Returns true if the numeric Unicode value of c1 is less than or equal to that of c2; otherwise returns false.

Calls C++ function: bool operator<=(QStringView lhs, QLatin1String rhs).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator<=(QChar c1, QChar c2):

Returns true if the numeric Unicode value of c1 is less than or equal to that of c2; otherwise returns false.

source§

impl Le<Ref<QStringView>> for QStringView

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.
source§

unsafe fn le(&self, rhs: &Ref<QStringView>) -> bool

Returns true if the numeric Unicode value of c1 is less than or equal to that of c2; otherwise returns false.

Calls C++ function: bool operator<=(QStringView lhs, QStringView rhs).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator<=(QChar c1, QChar c2):

Returns true if the numeric Unicode value of c1 is less than or equal to that of c2; otherwise returns false.

source§

impl Lt<Ref<QChar>> for QStringView

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.
source§

unsafe fn lt(&self, rhs: &Ref<QChar>) -> bool

Calls C++ function: bool operator<(QStringView lhs, QChar rhs).

source§

impl Lt<Ref<QLatin1String>> for QStringView

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.
source§

unsafe fn lt(&self, rhs: &Ref<QLatin1String>) -> bool

Calls C++ function: bool operator<(QStringView lhs, QLatin1String rhs).

source§

impl Lt<Ref<QStringView>> for QStringView

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.
source§

unsafe fn lt(&self, rhs: &Ref<QStringView>) -> bool

Calls C++ function: bool operator<(QStringView lhs, QStringView rhs).

source§

impl PartialEq<Ref<QChar>> for QStringView

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.
source§

fn eq(&self, rhs: &Ref<QChar>) -> bool

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

Calls C++ function: bool operator==(QStringView lhs, QChar rhs).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator==(QChar c1, QChar c2):

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<Ref<QLatin1String>> for QStringView

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.
source§

fn eq(&self, rhs: &Ref<QLatin1String>) -> bool

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

Calls C++ function: bool operator==(QStringView lhs, QLatin1String rhs).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator==(QChar c1, QChar c2):

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<Ref<QStringView>> for QStringView

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.
source§

fn eq(&self, rhs: &Ref<QStringView>) -> bool

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

Calls C++ function: bool operator==(QStringView lhs, QStringView rhs).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator==(QChar c1, QChar c2):

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Size for QStringView

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.
source§

unsafe fn size(&self) -> usize

Returns the size of this string view, in UTF-16 code points (that is, surrogate pairs count as two for the purposes of this function, the same as in QString and QStringRef).

Calls C++ function: long long QStringView::size() const.

C++ documentation:

Returns the size of this string view, in UTF-16 code points (that is, surrogate pairs count as two for the purposes of this function, the same as in QString and QStringRef).

See also empty(), isEmpty(), isNull(), and length().

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.