Member Function Documentation
QStringRef::QStringRef()
Constructs an empty string reference.
QStringRef::QStringRef(const QString * string, int position, int length)
Constructs a string reference to the range of characters in the given string specified by the starting position and length in characters.
Warning: This function exists to improve performance as much as possible, and performs no bounds checking. For program correctness, position and length must describe a valid substring of string.
This means that the starting position must be positive or 0 and smaller than string's length, and length must be positive or 0 but smaller than the string's length minus the starting position; i.e, 0 <= position < string->length() and 0 <= length <= string->length() - position must both be satisfied.
QStringRef::QStringRef(const QString * string)
Constructs a string reference to the given string.
QStringRef::QStringRef(const QStringRef & other)
Constructs a copy of the other string reference.
QStringRef::~QStringRef()
Destroys the string reference.
Since this class is only used to refer to string data, and does not take ownership of it, no memory is freed when instances are destroyed.
QStringRef QStringRef::appendTo(QString * string) const
Appends the string reference to string, and returns a new reference to the combined string data.
const QChar QStringRef::at(int position) const
Returns the character at the given index position in the string reference.
The position must be a valid index position in the string (i.e., 0 <= position < size()).
void QStringRef::clear()
Clears the contents of the string reference by making it null and empty.
See also isEmpty() and isNull().
int QStringRef::compare(const QStringRef & s1, const QString & s2, Qt::CaseSensitivity cs = Qt::CaseSensitive) [static]
Compares the string s1 with the string s2 and returns an integer less than, equal to, or greater than zero if s1 is less than, equal to, or greater than s2.
If cs is Qt::CaseSensitive, the comparison is case sensitive; otherwise the comparison is case insensitive.
This function was introduced in Qt 4.5.
int QStringRef::compare(const QStringRef & s1, const QStringRef & s2, Qt::CaseSensitivity cs = Qt::CaseSensitive) [static]
This is an overloaded function.
Compares the string s1 with the string s2 and returns an integer less than, equal to, or greater than zero if s1 is less than, equal to, or greater than s2.
If cs is Qt::CaseSensitive, the comparison is case sensitive; otherwise the comparison is case insensitive.
This function was introduced in Qt 4.5.
int QStringRef::compare(const QStringRef & s1, QLatin1String s2, Qt::CaseSensitivity cs = Qt::CaseSensitive) [static]
This is an overloaded function.
Compares the string s1 with the string s2 and returns an integer less than, equal to, or greater than zero if s1 is less than, equal to, or greater than s2.
If cs is Qt::CaseSensitive, the comparison is case sensitive; otherwise the comparison is case insensitive.
This function was introduced in Qt 4.5.
int QStringRef::compare(const QString & other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
This is an overloaded function.
Compares this string with the other string and returns an integer less than, equal to, or greater than zero if this string is less than, equal to, or greater than the other string.
If cs is Qt::CaseSensitive, the comparison is case sensitive; otherwise the comparison is case insensitive.
Equivalent to compare(*this, other, cs).
This function was introduced in Qt 4.5.
See also QString::compare().
int QStringRef::compare(const QStringRef & other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
This is an overloaded function.
Compares this string with the other string and returns an integer less than, equal to, or greater than zero if this string is less than, equal to, or greater than the other string.
If cs is Qt::CaseSensitive, the comparison is case sensitive; otherwise the comparison is case insensitive.
Equivalent to compare(*this, other, cs).
This function was introduced in Qt 4.5.
See also QString::compare().
int QStringRef::compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
This is an overloaded function.
Compares this string with the other string and returns an integer less than, equal to, or greater than zero if this string is less than, equal to, or greater than the other string.
If cs is Qt::CaseSensitive, the comparison is case sensitive; otherwise the comparison is case insensitive.
Equivalent to compare(*this, other, cs).
This function was introduced in Qt 4.5.
See also QString::compare().
const QChar * QStringRef::constData() const
Same as unicode().
bool QStringRef::contains(const QString & str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
Returns true if this string reference contains an occurrence of the string str; otherwise returns false.
If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.
This function was introduced in Qt 4.8.
See also indexOf() and count().
bool QStringRef::contains(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
This function overloads contains().
Returns true if this string contains an occurrence of the character ch; otherwise returns false.
If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.
This function was introduced in Qt 4.8.
bool QStringRef::contains(const QStringRef & str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
This function overloads contains().
Returns true if this string reference contains an occurrence of the string reference str; otherwise returns false.
If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.
This function was introduced in Qt 4.8.
See also indexOf() and count().
bool QStringRef::contains(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
This function overloads contains().
Returns true if this string reference contains an occurrence of the string str; otherwise returns false.
If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.
This function was introduced in Qt 4,8.
See also indexOf() and count().
int QStringRef::count() const
Returns the number of characters referred to by the string reference. Equivalent to size() and length().
See also position() and string().
int QStringRef::count(const QString & str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
Returns the number of (potentially overlapping) occurrences of the string str in this string reference.
If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.
This function was introduced in Qt 4.8.
See also QString::count(), contains(), and indexOf().
int QStringRef::count(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
This function overloads count().
Returns the number of occurrences of the character ch in the string reference.
If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.
This function was introduced in Qt 4.8.
See also QString::count(), contains(), and indexOf().
int QStringRef::count(const QStringRef & str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
This function overloads count().
Returns the number of (potentially overlapping) occurrences of the string reference str in this string reference.
If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.
This function was introduced in Qt 4.8.
See also QString::count(), contains(), and indexOf().
const QChar * QStringRef::data() const
Same as unicode().
bool QStringRef::endsWith(const QString & str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
Returns true if the string reference ends with str; otherwise returns false.
If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.
This function was introduced in Qt 4.8.
See also QString::endsWith() and startsWith().
bool QStringRef::endsWith(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
This function overloads endsWith().
Returns true if the string reference ends with ch; otherwise returns false.
If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.
This function was introduced in Qt 4.8.
See also QString::endsWith() and endsWith().
bool QStringRef::endsWith(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
This function overloads endsWith().
This function was introduced in Qt 4.8.
See also QString::endsWith() and endsWith().
bool QStringRef::endsWith(const QStringRef & str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
This function overloads endsWith().
This function was introduced in Qt 4.8.
See also QString::endsWith() and endsWith().
int QStringRef::indexOf(const QString & str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
Returns the index position of the first occurrence of the string str in this string reference, searching forward from index position from. Returns -1 if str is not found.
If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.
If from is -1, the search starts at the last character; if it is -2, at the next to last character and so on.
This function was introduced in Qt 4.8.
See also QString::indexOf(), lastIndexOf(), contains(), and count().
int QStringRef::indexOf(QLatin1String str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
Returns the index position of the first occurrence of the string str in this string reference, searching forward from index position from. Returns -1 if str is not found.
If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.
If from is -1, the search starts at the last character; if it is -2, at the next to last character and so on.
This function was introduced in Qt 4.8.
See also QString::indexOf(), lastIndexOf(), contains(), and count().
int QStringRef::indexOf(QChar ch, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
This function overloads indexOf().
Returns the index position of the first occurrence of the character ch in the string reference, searching forward from index position from. Returns -1 if ch could not be found.
This function was introduced in Qt 4.8.
See also QString::indexOf(), lastIndexOf(), contains(), and count().
int QStringRef::indexOf(const QStringRef & str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
This function overloads indexOf().
Returns the index position of the first occurrence of the string reference str in this string reference, searching forward from index position from. Returns -1 if str is not found.
If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.
This function was introduced in Qt 4.8.
See also QString::indexOf(), lastIndexOf(), contains(), and count().
bool QStringRef::isEmpty() const
Returns true if the string reference has no characters; otherwise returns false.
A string reference is empty if its size is zero.
See also size().
bool QStringRef::isNull() const
Returns true if string() returns a null pointer or a pointer to a null string; otherwise returns true.
See also size().
int QStringRef::lastIndexOf(const QString & str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
Returns the index position of the last occurrence of the string str in this string reference, searching backward from index position from. If from is -1 (default), the search starts at the last character; if from is -2, at the next to last character and so on. Returns -1 if str is not found.
If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.
This function was introduced in Qt 4.8.
See also QString::lastIndexOf(), indexOf(), contains(), and count().
int QStringRef::lastIndexOf(QChar ch, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
This function overloads lastIndexOf().
Returns the index position of the last occurrence of the character ch, searching backward from position from.
This function was introduced in Qt 4.8.
See also QString::lastIndexOf(), indexOf(), contains(), and count().
int QStringRef::lastIndexOf(QLatin1String str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
This function overloads lastIndexOf().
Returns the index position of the last occurrence of the string str in this string reference, searching backward from index position from. If from is -1 (default), the search starts at the last character; if from is -2, at the next to last character and so on. Returns -1 if str is not found.
If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.
This function was introduced in Qt 4.8.
See also QString::lastIndexOf(), indexOf(), contains(), and count().
int QStringRef::lastIndexOf(const QStringRef & str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
This function overloads lastIndexOf().
Returns the index position of the last occurrence of the string reference str in this string reference, searching backward from index position from. If from is -1 (default), the search starts at the last character; if from is -2, at the next to last character and so on. Returns -1 if str is not found.
If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.
This function was introduced in Qt 4.8.
See also QString::lastIndexOf(), indexOf(), contains(), and count().
int QStringRef::length() const
Returns the number of characters referred to by the string reference. Equivalent to size() and count().
See also position() and string().
int QStringRef::localeAwareCompare(const QStringRef & s1, const QString & s2) [static]
Compares s1 with s2 and returns an integer less than, equal to, or greater than zero if s1 is less than, equal to, or greater than s2.
The comparison is performed in a locale- and also platform-dependent manner. Use this function to present sorted lists of strings to the user.
On Mac OS X, this function compares according the "Order for sorted lists" setting in the International prefereces panel.
This function was introduced in Qt 4.5.
See also compare() and QTextCodec::locale().
int QStringRef::localeAwareCompare(const QStringRef & s1, const QStringRef & s2) [static]
This is an overloaded function.
Compares s1 with s2 and returns an integer less than, equal to, or greater than zero if s1 is less than, equal to, or greater than s2.
The comparison is performed in a locale- and also platform-dependent manner. Use this function to present sorted lists of strings to the user.
This function was introduced in Qt 4.5.
int QStringRef::localeAwareCompare(const QString & other) const
This is an overloaded function.
Compares this string with the other string and returns an integer less than, equal to, or greater than zero if this string is less than, equal to, or greater than the other string.
The comparison is performed in a locale- and also platform-dependent manner. Use this function to present sorted lists of strings to the user.
This function was introduced in Qt 4.5.
int QStringRef::localeAwareCompare(const QStringRef & other) const
This is an overloaded function.
Compares this string with the other string and returns an integer less than, equal to, or greater than zero if this string is less than, equal to, or greater than the other string.
The comparison is performed in a locale- and also platform-dependent manner. Use this function to present sorted lists of strings to the user.
This function was introduced in Qt 4.5.
int QStringRef::position() const
Returns the starting position in the referenced string that is referred to by the string reference.
See also size() and string().
int QStringRef::size() const
Returns the number of characters referred to by the string reference. Equivalent to length() and count().
See also position() and string().
bool QStringRef::startsWith(const QString & str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
Returns true if the string reference starts with str; otherwise returns false.
If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.
This function was introduced in Qt 4.8.
See also QString::startsWith() and endsWith().
bool QStringRef::startsWith(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
This function overloads startsWith().
This function was introduced in Qt 4.8.
See also QString::startsWith() and endsWith().
bool QStringRef::startsWith(const QStringRef & str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
This function overloads startsWith().
This function was introduced in Qt 4.8.
See also QString::startsWith() and endsWith().
bool QStringRef::startsWith(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
This function overloads startsWith().
Returns true if the string reference starts with ch; otherwise returns false.
If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.
This function was introduced in Qt 4.8.
See also QString::startsWith() and endsWith().
const QString * QStringRef::string() const
Returns a pointer to the string referred to by the string reference, or 0 if it does not reference a string.
See also unicode().
QByteArray QStringRef::toAscii() const
This function is deprecated.
Returns an 8-bit representation of the string as a QByteArray.
This function does the same as toLatin1().
Note that, despite the name, this function does not necessarily return an US-ASCII (ANSI X3.4-1986) string and its result may not be US-ASCII compatible.
This function was introduced in Qt 4.8.
See also toLatin1(), toUtf8(), toLocal8Bit(), and QTextCodec.
QByteArray QStringRef::toLocal8Bit() const
Returns the local 8-bit representation of the string as a QByteArray. The returned byte array is undefined if the string contains characters not supported by the local 8-bit encoding.
QTextCodec::codecForLocale() is used to perform the conversion from Unicode. If the locale encoding could not be determined, this function does the same as toLatin1().
If this string contains any characters that cannot be encoded in the locale, the returned byte array is undefined. Those characters may be suppressed or replaced by another.
This function was introduced in Qt 4.8.
See also toLatin1(), toUtf8(), and QTextCodec.
QString QStringRef::toString() const
Returns a copy of the string reference as a QString object.
If the string reference is not a complete reference of the string (meaning that position() is 0 and size() equals string()->size()), this function will allocate a new string to return.
See also string().
QVector<uint> QStringRef::toUcs4() const
Returns a UCS-4/UTF-32 representation of the string as a QVector<uint>.
UCS-4 is a Unicode codec and is lossless. All characters from this string can be encoded in UCS-4.
This function was introduced in Qt 4.8.
See also toUtf8(), toLatin1(), toLocal8Bit(), and QTextCodec.
QByteArray QStringRef::toUtf8() const
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.
However, in the Unicode range, there are certain codepoints that are not considered characters. The Unicode standard reserves the last two codepoints in each Unicode Plane (U+FFFE, U+FFFF, U+1FFFE, U+1FFFF, U+2FFFE, etc.), as well as 16 codepoints in the range U+FDD0..U+FDDF, inclusive, as non-characters. If any of those appear in the string, they may be discarded and will not appear in the UTF-8 representation, or they may be replaced by one or more replacement characters.
This function was introduced in Qt 4.8.
See also toLatin1(), toLocal8Bit(), and QTextCodec.
const QChar * QStringRef::unicode() const
Returns a Unicode representation of the string reference. Since the data stems directly from the referenced string, it is not null-terminated unless the string reference includes the string's null terminator.
See also string().
bool QStringRef::operator!=(const char * s) const
bool QStringRef::operator<(const char * s) const
bool QStringRef::operator<=(const char * s) const
QStringRef & QStringRef::operator=(const QStringRef & other)
Assigns the other string reference to this string reference, and returns the result.
QStringRef & QStringRef::operator=(const QString * string)
Constructs a string reference to the given string and assigns it to this string reference, returning the result.
bool QStringRef::operator==(const char * s) const
bool QStringRef::operator>(const char * s) const
bool QStringRef::operator>=(const char * s) const