summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstring.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-12-30 17:39:21 +0100
committerLars Knoll <lars.knoll@qt.io>2018-01-02 09:58:44 +0100
commit0f315adf9199efcfafa44371464ab6d1fc866774 (patch)
tree35b67591255624c670aff0579e45b2973f56fd81 /src/corelib/tools/qstring.cpp
parent2b0eb3fac319a17dd92903106d501f0f06df871f (diff)
parent52b85212a2ec8ec5bf187f6cd00b669a45bcf0bd (diff)
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts: .qmake.conf sc/corelib/io/qfsfileengine_p.h src/corelib/io/qstorageinfo_unix.cpp src/platformsupport/eglconvenience/qeglpbuffer_p.h src/platformsupport/input/libinput/qlibinputkeyboard.cpp src/platformsupport/input/libinput/qlibinputpointer.cpp src/plugins/platforms/cocoa/qcocoamenu.mm src/plugins/platforms/ios/qiosscreen.h src/plugins/platforms/ios/qioswindow.h src/plugins/platforms/ios/quiview.mm src/printsupport/dialogs/qpagesetupdialog_unix_p.h src/printsupport/dialogs/qprintpreviewdialog.cpp src/printsupport/widgets/qcupsjobwidget_p.h src/widgets/widgets/qmenu.cpp tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp Change-Id: Iecb4883122efe97ef0ed850271e6c51bab568e9c
Diffstat (limited to 'src/corelib/tools/qstring.cpp')
-rw-r--r--src/corelib/tools/qstring.cpp86
1 files changed, 45 insertions, 41 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 78b7e69d9c..8093a26f7d 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -160,9 +160,9 @@ static inline bool qt_ends_with(QStringView haystack, QStringView needle, Qt::Ca
static inline bool qt_ends_with(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs);
static inline bool qt_ends_with(QStringView haystack, QChar needle, Qt::CaseSensitivity cs);
-qssize_t QtPrivate::qustrlen(const ushort *str) Q_DECL_NOTHROW
+qsizetype QtPrivate::qustrlen(const ushort *str) Q_DECL_NOTHROW
{
- qssize_t result = 0;
+ qsizetype result = 0;
#ifdef __SSE2__
// find the 16-byte alignment immediately prior or equal to str
@@ -769,8 +769,6 @@ static int qt_compare_strings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSens
Case-sensitive comparison is based exclusively on the numeric Unicode values
of the characters and is very fast, but is not what a human would expect.
Consider sorting user-visible strings with QString::localeAwareCompare().
-
- \snippet qstring/main.cpp qCompareStrings-QSV-QSV
*/
int QtPrivate::compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
{
@@ -4837,7 +4835,7 @@ static QByteArray qt_convert_to_local_8bit(QStringView string);
locale, the returned byte array is undefined. Those characters may be
suppressed or replaced by another.
- \sa fromLocal8Bit(), toLatin1(), toUtf8(), QTextCodec, qConvertToLocal8Bit()
+ \sa fromLocal8Bit(), toLatin1(), toUtf8(), QTextCodec
*/
QByteArray QString::toLocal8Bit_helper(const QChar *data, int size)
@@ -4871,8 +4869,7 @@ static QByteArray qt_convert_to_local_8bit(QStringView string)
The behavior is undefined if \a string contains characters not
supported by the locale's 8-bit encoding.
- \sa QString::toLocal8Bit(), QStringView::toLocal8Bit(), QtPrivate::vonvertToLatin1(),
- QtPrivate::convertToUtf8(), QtPrivate::convertToUcs4()
+ \sa QString::toLocal8Bit(), QStringView::toLocal8Bit()
*/
QByteArray QtPrivate::convertToLocal8Bit(QStringView string)
{
@@ -4915,8 +4912,7 @@ static QByteArray qt_convert_to_utf8(QStringView str)
UTF-8 is a Unicode codec and can represent all characters in a Unicode
string like QStringView.
- \sa QString::toUtf8(), QStringView::toUtf8(), QtPrivate::convertToLatin1(),
- QtPrivate::convertToLocal8Bit(), QtPrivate::convertToUcs4()
+ \sa QString::toUtf8(), QStringView::toUtf8()
*/
QByteArray QtPrivate::convertToUtf8(QStringView string)
{
@@ -5279,8 +5275,8 @@ namespace {
}
/*!
- \fn QStringView qTrimmed(QStringView s)
- \fn QLatin1String qTrimmed(QLatin1String s)
+ \fn QStringView QtPrivate::trimmed(QStringView s)
+ \fn QLatin1String QtPrivate::trimmed(QLatin1String s)
\internal
\relates QStringView
\since 5.10
@@ -5521,14 +5517,9 @@ QString& QString::fill(QChar ch, int size)
Returns the number of characters in this string.
- The last character in the string is at position size() - 1. In
- addition, QString ensures that the character at position size()
- is always '\\0', so that you can use the return value of data()
- and constData() as arguments to functions that expect
- '\\0'-terminated strings.
+ The last character in the string is at position size() - 1.
Example:
-
\snippet qstring/main.cpp 58
\sa isEmpty(), resize()
@@ -6046,10 +6037,13 @@ int QString::localeAwareCompare_helper(const QChar *data1, int length1,
/*!
\fn const QChar *QString::unicode() const
- Returns a '\\0'-terminated Unicode representation of the string.
+ Returns a Unicode representation of the string.
The result remains valid until the string is modified.
- \sa utf16()
+ \note The returned string may not be '\\0'-terminated.
+ Use size() to determine the length of the array.
+
+ \sa utf16(), fromRawData()
*/
/*!
@@ -7250,6 +7244,16 @@ static ResultList splitString(const StringSource &source, const QChar *sep,
\snippet qstring/main.cpp 62
+ If \a sep is empty, split() returns an empty string, followed
+ by each of the string's characters, followed by another empty string:
+
+ \snippet qstring/main.cpp 62-empty
+
+ To understand this behavior, recall that the empty string matches
+ everywhere, so the above is qualitatively the same as:
+
+ \snippet qstring/main.cpp 62-slashes
+
\sa QStringList::join(), section()
*/
QStringList QString::split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
@@ -7259,15 +7263,10 @@ QStringList QString::split(const QString &sep, SplitBehavior behavior, Qt::CaseS
/*!
Splits the string into substring references wherever \a sep occurs, and
- returns the list of those strings. If \a sep does not match
- anywhere in the string, splitRef() returns a single-element vector
- containing this string reference.
+ returns the list of those strings.
- \a cs specifies whether \a sep should be matched case
- sensitively or case insensitively.
-
- If \a behavior is QString::SkipEmptyParts, empty entries don't
- appear in the result. By default, empty entries are kept.
+ See QString::split() for how \a sep, \a behavior and \a cs interact to form
+ the result.
\note All references are valid as long this string is alive. Destroying this
string will cause all references be dangling pointers.
@@ -7298,15 +7297,10 @@ QVector<QStringRef> QString::splitRef(QChar sep, SplitBehavior behavior, Qt::Cas
/*!
Splits the string into substrings references wherever \a sep occurs, and
- returns the list of those strings. If \a sep does not match
- anywhere in the string, split() returns a single-element vector
- containing this string reference.
+ returns the list of those strings.
- \a cs specifies whether \a sep should be matched case
- sensitively or case insensitively.
-
- If \a behavior is QString::SkipEmptyParts, empty entries don't
- appear in the result. By default, empty entries are kept.
+ See QString::split() for how \a sep, \a behavior and \a cs interact to form
+ the result.
\note All references are valid as long this string is alive. Destroying this
string will cause all references be dangling pointers.
@@ -8519,7 +8513,10 @@ bool QString::isRightToLeft() const
Returns a pointer to the data stored in the QString. The pointer
can be used to access and modify the characters that compose the
- string. For convenience, the data is '\\0'-terminated.
+ string.
+
+ Unlike constData() and unicode(), the returned data is always
+ '\\0'-terminated.
Example:
@@ -8535,18 +8532,25 @@ bool QString::isRightToLeft() const
/*! \fn const QChar *QString::data() const
\overload
+
+ \note The returned string may not be '\\0'-terminated.
+ Use size() to determine the length of the array.
+
+ \sa fromRawData()
*/
/*! \fn const QChar *QString::constData() const
Returns a pointer to the data stored in the QString. The pointer
- can be used to access the characters that compose the string. For
- convenience, the data is '\\0'-terminated.
+ can be used to access the characters that compose the string.
Note that the pointer remains valid only as long as the string is
not modified.
- \sa data(), operator[]()
+ \note The returned string may not be '\\0'-terminated.
+ Use size() to determine the length of the array.
+
+ \sa data(), operator[](), fromRawData()
*/
/*! \fn void QString::push_front(const QString &other)
@@ -8996,7 +9000,7 @@ QString &QString::setRawData(const QChar *unicode, int size)
If \a cs is Qt::CaseSensitive (the default), the search is case-sensitive;
otherwise the search is case-insensitive.
- \sa endsWith(), qStartsWith()
+ \sa endsWith()
*/
/*!
@@ -9016,7 +9020,7 @@ QString &QString::setRawData(const QChar *unicode, int size)
If \a cs is Qt::CaseSensitive (the default), the search is case-sensitive;
otherwise the search is case-insensitive.
- \sa startsWith(), qEndsWith()
+ \sa startsWith()
*/
/*!