CopperSpice API
1.9.2
|
The QStringView class provides a string view class. More...
Inherits CsBasicStringView< S >
Public Typedefs | |
using | const_iterator = typename S::const_iterator |
using | const_reverse_iterator = typename S::const_reverse_iterator |
using | difference_type = typename S::difference_type |
using | iterator = typename S::const_iterator |
using | reverse_iterator = typename S::const_reverse_iterator |
using | size_type = typename S::difference_type |
using | value_type = typename S::value_type |
Public Methods | |
QStringView () = default | |
QStringView (const QStringView &other) = default | |
QStringView (const S &str) | |
QStringView (const_iterator begin, const_iterator end) | |
QStringView (QStringView &&other) = default | |
QStringView (S &&str) = delete | |
value_type | at (size_type n) const |
value_type | back () const |
iterator | begin () |
const_iterator | begin () const |
const_iterator | cbegin () const |
const_iterator | cend () const |
const S::storage_type * | charData () const |
void | chop (size_type numOfChars) |
int | compare (QStringView str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
const_iterator | constBegin () const |
const_iterator | constEnd () const |
bool | contains (const QRegularExpression< S > ®Exp) const |
bool | contains (const S &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
bool | contains (QStringView str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
bool | contains (value_type ch, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
size_type | count () const |
size_type | count (const QRegularExpression< S > ®Exp) const |
size_type | count (const S &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
size_type | count (QStringView str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
size_type | count (value_type ch, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
const_reverse_iterator | crbegin () const |
const_reverse_iterator | crend () const |
bool | empty () const |
iterator | end () |
const_iterator | end () const |
bool | endsWith (QStringView str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
bool | endsWith (S str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
template<typename C = value_type> | |
bool | endsWith (value_type ch, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
value_type | first () const |
value_type | front () const |
const_iterator | indexOfFast (const S &str) const |
const_iterator | indexOfFast (const S &str, const_iterator from, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
const_iterator | indexOfFast (QStringView< S > str, const_iterator from, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
const_iterator | indexOfFast (value_type ch) const |
const_iterator | indexOfFast (value_type ch, const_iterator from, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
bool | isEmpty () const |
value_type | last () const |
const_iterator | lastIndexOfFast (const S &str) const |
const_iterator | lastIndexOfFast (const S &str, const_iterator from, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
const_iterator | lastIndexOfFast (QStringView< S > str, const_iterator from, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
const_iterator | lastIndexOfFast (value_type ch) const |
const_iterator | lastIndexOfFast (value_type ch, const_iterator from, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
QStringView< S > | left (size_type numOfChars) const |
size_type | length () const |
QStringView< S > | mid (size_type indexStart, size_type numOfChars=-1) const |
QStringView & | operator= (const QStringView &other) = default |
QStringView & | operator= (QStringView &&other) = default |
value_type | operator[] (size_type n) const |
reverse_iterator | rbegin () |
const_reverse_iterator | rbegin () const |
reverse_iterator | rend () |
const_reverse_iterator | rend () const |
QStringView< S > | right (size_type numOfChars) const |
size_type | size () const |
size_type | size_storage () const |
bool | startsWith (QStringView< S > str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
bool | startsWith (S str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
template<typename C = value_type> | |
bool | startsWith (value_type ch, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
S | toCaseFolded () const |
template<typename SP = QStringParser> | |
double | toDouble (bool *ok=nullptr) const |
template<typename SP = QStringParser> | |
float | toFloat (bool *ok=nullptr) const |
template<typename R , typename SP = QStringParser> | |
R | toInteger (bool *ok=nullptr, int base=10) const |
QByteArray | toLatin1 () const |
S | toLower () const |
S | toString () const |
S | toUpper () const |
QByteArray | toUtf8 () const |
QStringView< S > | trimmed () const |
Related Functions | |
These are not member functions | |
QStringView16 | make_view (QString16 &&str) |
QStringView8 | make_view (QString8 &&str) |
The QStringView class provides a view into a QString8 or a QString16 with a read only subset of the QString API.
QStringView is implemented as a pair of iterators which define the start and end of a contiguous range in an existing string. Since QStringView does not own the data it refers to, it is only valid while the original string is valid. If the original string is destroyed or modified the view is invalid. A QStringView should be passed by value, not by reference.
QStringView can also be used as the return value of a method or function. If you need access to the return value and the original string might go out of scope or change, it may be necessary to copy the data into a new QString8. A QStringView can should be treated with the same care that iterators to the original string would be.
Since this is a templated class any string data type can be passed as the template argument S. The template argument must be a string class which provides const iterators.
QStringView< S >::const_iterator |
Provides an STL style const iterator for QStringView.
QStringView< S >::const_reverse_iterator |
Provides an STL style const reverse iterator for QStringView.
QStringView< S >::difference_type |
Typedef for an integer type representing the distance between two elements in a QStringView.
QStringView< S >::iterator |
Provides an STL style const iterator for QStringView.
QStringView< S >::reverse_iterator |
Provides an STL style non-const reverse iterator for QStringView.
QStringView< S >::size_type |
Typedef for an integer type representing sizes in a QStringView.
QStringView< S >::value_type |
Typedef for the elements stored in a QStringView.
|
default |
Constructs an empty QStringView.
|
inline |
Constructs a QStringView using the specified iterator range.
|
default |
Constructs a QStringView by making a copy of other. The string other must remain valid for the lifetime of this string view.
|
default |
Move constructs a QStringView from other.
|
inline |
Constructs a QStringView using the specified string str. The string must remain valid for the lifetime of this string view.
|
delete |
This constructor has been marked deleted to ensure a string view is not created from a temporary string unintentionally. In order to pass a temporary string to a function which expects a QStringView, use the function make_view().
|
inline |
Returns the code point at position n in this string view. The behavior of this method is undefined if n is negative or if n is equal to or greater than the size() of the string view.
|
inline |
|
inline |
Returns an STL style iterator pointing to the first code point in the string view.
|
inline |
Returns a const STL style iterator pointing to the first code point in the string view.
|
inline |
Returns a const STL style iterator pointing to the first code point in the string view.
|
inline |
Returns a const STL style iterator pointing to the imaginary code point after the last code point in the string view.
|
inline |
Returns a pointer to the first character in the string view.
void QStringView< S >::chop | ( | size_type | numOfChars | ) |
|
inline |
Compares this string view with the string view str. If cs is Qt::CaseSensitive the comparison is case sensitive, otherwise the comparison is case insensitive.
|
inline |
Returns a const STL style iterator pointing to the first code point in the string view.
|
inline |
Returns a const STL style iterator pointing to the imaginary code point after the last code point in the string view.
|
inline |
Returns true if this string contains an occurrence of the regular expression regExp, otherwise it returns false.
bool QStringView< S >::contains | ( | const S & | str, |
Qt::CaseSensitivity | cs = Qt::CaseSensitive |
||
) | const |
Returns true if this string contains an occurrence of the string str, otherwise it returns false. If cs is Qt::CaseSensitive the search is case sensitive, otherwise the search is case insensitive.
bool QStringView< S >::contains | ( | QStringView< S > | str, |
Qt::CaseSensitivity | cs = Qt::CaseSensitive |
||
) | const |
Returns true if this string contains an occurrence of the string view str, otherwise it returns false. If cs is Qt::CaseSensitive the search is case sensitive, otherwise the search is case insensitive.
bool QStringView< S >::contains | ( | value_type | ch, |
Qt::CaseSensitivity | cs = Qt::CaseSensitive |
||
) | const |
Returns true if this string contains an occurrence of the character ch, otherwise returns false. If cs is Qt::CaseSensitive the search is case sensitive, otherwise the search is case insensitive.
|
inline |
Returns the same as size().
QStringView< S >::size_type QStringView< S >::count | ( | const QRegularExpression< S > & | regExp | ) | const |
Returns the number of occurrences of the regular expression regExp in the string.
QStringView< S >::size_type QStringView< S >::count | ( | const S & | str, |
Qt::CaseSensitivity | cs = Qt::CaseSensitive |
||
) | const |
Returns the number of (potentially overlapping) occurrences of the string str in this string. If cs is Qt::CaseSensitive the search is case sensitive, otherwise the search is case insensitive.
QStringView< S >::size_type QStringView< S >::count | ( | QStringView< S > | str, |
Qt::CaseSensitivity | cs = Qt::CaseSensitive |
||
) | const |
Returns the number of occurrences of the string view str in this string. If cs is Qt::CaseSensitive the search is case sensitive, otherwise the search is case insensitive.
QStringView< S >::size_type QStringView< S >::count | ( | value_type | ch, |
Qt::CaseSensitivity | cs = Qt::CaseSensitive |
||
) | const |
Returns the number of occurrences of character ch in the string. If cs is Qt::CaseSensitive the search is case sensitive, otherwise the search is case insensitive.
|
inline |
Returns an STL style iterator pointing to the last code point in the string view, in reverse order.
|
inline |
Returns an STL style iterator pointing to one past the first code point in the string view, in reverse order.
|
inline |
|
inline |
Returns an STL style iterator pointing to the imaginary code point after the last code point in the string view.
|
inline |
Returns a const STL style iterator pointing to the imaginary code point after the last code point in the string view.
bool QStringView< S >::endsWith | ( | QStringView< S > | str, |
Qt::CaseSensitivity | cs = Qt::CaseSensitive |
||
) | const |
Returns true if this string view ends with the string view str, otherwise returns false. If cs is Qt::CaseSensitive the search is case sensitive, otherwise the search is case insensitive.
|
inline |
Returns true if this string view ends with the string str, otherwise returns false. If cs is Qt::CaseSensitive the search is case sensitive, otherwise the search is case insensitive.
bool QStringView< S >::endsWith | ( | value_type | ch, |
Qt::CaseSensitivity | cs = Qt::CaseSensitive |
||
) | const |
Returns true if this string view ends with the code point ch, otherwise returns false. If cs is Qt::CaseSensitive the search is case sensitive, otherwise the search is case insensitive.
|
inline |
|
inline |
|
inline |
Returns an iterator to the first occurrence of str in this string. Returns the end iterator if str is not found.
|
inline |
Returns an iterator to the first occurrence of str in this string, searching forward from iterator from. Returns the end iterator if str is not found.
If cs is Qt::CaseSensitive the search is case sensitive, otherwise the search is case insensitive.
|
inline |
Returns the iterator position of the first occurrence of the string view str in the string, searching forward from iterator position from. Returns the end iterator if str is not found.
If cs is Qt::CaseSensitive the search is case sensitive, otherwise the search is case insensitive.
|
inline |
Returns an iterator to the first occurrence of ch in this string. Returns the end iterator if ch is not found.
|
inline |
Returns an iterator to the first occurrence of ch in this string, searching forward from iterator from. Returns the end iterator if ch is not found.
If cs is Qt::CaseSensitive the search is case sensitive, otherwise the search is case insensitive.
|
inline |
|
inline |
|
inline |
Returns an iterator to the last occurrence of str in this string. Returns the end iterator if str is not found.
|
inline |
Returns an iterator to the first occurrence of str in this string, searching backward from iterator from. Returns the end iterator if str is not found.
If cs is Qt::CaseSensitive the search is case sensitive, otherwise the search is case insensitive.
|
inline |
Returns the iterator position of the last occurrence of the string view str in this string, searching backward from iterator position from. Returns the end iterator if str is not found.
If cs is Qt::CaseSensitive the search is case sensitive, otherwise the search is case insensitive.
|
inline |
Returns an iterator to the last occurrence of ch in this string. Returns the end iterator if ch is not found.
|
inline |
Returns an iterator to the last occurrence of ch in this string, searching backward from iterator from. Returns the end iterator if ch is not found.
If cs is Qt::CaseSensitive the search is case sensitive, otherwise the search is case insensitive.
QStringView< S > QStringView< S >::left | ( | size_type | numOfChars | ) | const |
|
inline |
|
default |
Copy assigns from other and returns a reference to this object. The string view other must remain valid for the lifetime of this string view object.
|
default |
Move assigns from other and returns a reference to this object.
QStringView< S >::value_type QStringView< S >::operator[] | ( | size_type | n | ) | const |
|
inline |
Returns an STL style iterator pointing to the first last code point in the string view, in reverse order.
|
inline |
Returns an STL style iterator pointing to the first last code point in the string view, in reverse order.
|
inline |
Returns an STL style iterator pointing to one past the last code point in the string view, in reverse order.
|
inline |
Returns an STL style iterator pointing to one past the last code point in the string view, in reverse order.
QStringView< S > QStringView< S >::right | ( | size_type | numOfChars | ) | const |
|
inline |
|
inline |
Returns the number of storage units in this string view. The storage size is the actual bytes required in the underlying container for a string. This value will usually be larger than size().
It is normally only used when passing a string view to a C API which expects a pointer and a length.
bool QStringView< S >::startsWith | ( | QStringView< S > | str, |
Qt::CaseSensitivity | cs = Qt::CaseSensitive |
||
) | const |
Returns true if this string view starts with the string view str, otherwise returns false. If cs is Qt::CaseSensitive the search is case sensitive, otherwise the search is case insensitive.
|
inline |
Returns true if this string view starts with the string str, otherwise returns false. If cs is Qt::CaseSensitive the search is case sensitive, otherwise the search is case insensitive.
bool QStringView< S >::startsWith | ( | value_type | ch, |
Qt::CaseSensitivity | cs = Qt::CaseSensitive |
||
) | const |
Returns true if this string view starts with the code point ch, otherwise returns false. If cs is Qt::CaseSensitive the search is case sensitive, otherwise the search is case insensitive.
|
nodiscard |
Returns the case folded equivalent of the string. For most Unicode characters this is the same as toLower().
|
inline |
Wrapper for QStringParser::toDouble(). In order to use this method in your application include the <QStringParser> header file.
|
inline |
Wrapper for QStringParser::toFloat(). In order to use this method in your application include the <QStringParser> header file.
|
inline |
Wrapper for QStringParser::toInteger(). In order to use this method in your application include the <QStringParser> header file.
This method replaces the following set of methods: toInt, toUInt, toLong, toULong, toLongLong, toULongLong, toShort, toUShort. The required data type is passed as the template parameter to this method.
QByteArray QStringView< S >::toLatin1 | ( | ) | const |
Returns a Latin-1 representation of the string view as a QByteArray. Any code points which can not be represented in Latin-1 will be replaced by a question mark.
|
nodiscard |
Returns a lowercase copy of the string. The case conversion will always happen in the 'C' locale. For locale dependent lower casing use QLocale::toLower().
|
inline |
Return this string view as a string of type S.
|
nodiscard |
Returns an uppercase copy of the string. The case conversion will always happen in the 'C' locale. For locale dependent upper casing use QLocale::toUpper().
QByteArray QStringView< S >::toUtf8 | ( | ) | const |
Returns a UTF-8 string as a QByteArray.
QStringView< S > QStringView< S >::trimmed | ( | ) | const |
Strips leading and trailing whitespace from this string view and returns the result.
Whitespace means any code point for which QChar32::isSpace() returns true. This includes the ASCII characters '\t', '\n', '\v', '\f', '\r', and ' '.
|
related |
Constructs a string view from the temporary string str. This function returns a QStringView16 which is only valid for the lifetime of str.
If the string view is passed to another function, verify that the called function does not attempt to save a copy of the view. As per the C++ standard, accessing a view after the lifetime of the temporary string has expired, is undefined behavior.
|
related |
Constructs a string view from the temporary string str. This function returns a QStringView8 which is only valid for the lifetime of str.
If the string view is passed to another function, verify that the called function does not attempt to save a copy of the view. As per the C++ standard, accessing a view after the lifetime of the temporary string has expired, is undefined behavior.