summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2020-06-10 15:00:48 +0200
committerMarc Mutz <marc.mutz@kdab.com>2020-06-11 19:14:03 +0000
commit3f6142f5a1a01f201593f6711930ec77640dea46 (patch)
tree3f6ee88ae701993087454f1193902eb976d1167d /src/corelib
parent7b15417b53ce8c278ab3fcc8c32f8203da4ed697 (diff)
Rename new slice() method sliced()
The recently-added slice() method has the problem that it's a noun as well as a verb in the imperative. Like std::vector::empty, which is both an adjective and a verb in the imperative, this may cause confusion as to what the function does. Using the passive voice form of slice(), sliced(), removes the confusion. While it can be read as an adjective, too, that doesn't change the meaning compared to the verb form. Change-Id: If0aa01acb6cf5dd5eafa8226e3ea7f7a0c9da4f1 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/text/qbytearray.cpp14
-rw-r--r--src/corelib/text/qbytearray.h2
-rw-r--r--src/corelib/text/qstring.cpp14
-rw-r--r--src/corelib/text/qstring.h2
-rw-r--r--src/corelib/text/qstringview.cpp10
-rw-r--r--src/corelib/text/qstringview.h2
6 files changed, 22 insertions, 22 deletions
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp
index 3f83e36d90..31ae063cb1 100644
--- a/src/corelib/text/qbytearray.cpp
+++ b/src/corelib/text/qbytearray.cpp
@@ -2949,7 +2949,7 @@ QByteArray QByteArray::left(int len) const
Example:
\snippet code/src_corelib_text_qbytearray.cpp 28
- \sa endsWith(), last(), first(), slice(), chopped(), chop(), truncate()
+ \sa endsWith(), last(), first(), sliced(), chopped(), chop(), truncate()
*/
QByteArray QByteArray::right(int len) const
{
@@ -2964,7 +2964,7 @@ QByteArray QByteArray::right(int len) const
Returns a byte array containing \a len bytes from this byte array,
starting at position \a pos.
- \obsolete Use slice() instead in new code.
+ \obsolete Use sliced() instead in new code.
If \a len is -1 (the default), or \a pos + \a len >= size(),
returns a byte array containing all bytes starting at position \a
@@ -2973,7 +2973,7 @@ QByteArray QByteArray::right(int len) const
Example:
\snippet code/src_corelib_text_qbytearray.cpp 29
- \sa first(), last(), slice(), chopped(), chop(), truncate()
+ \sa first(), last(), sliced(), chopped(), chop(), truncate()
*/
QByteArray QByteArray::mid(int pos, int len) const
@@ -3007,7 +3007,7 @@ QByteArray QByteArray::mid(int pos, int len) const
\note The behavior is undefined when \a n < 0 or \a n > size().
- \sa last(), slice(), from(), startsWith(), chopped(), chop(), truncate()
+ \sa last(), sliced(), from(), startsWith(), chopped(), chop(), truncate()
*/
/*!
@@ -3018,11 +3018,11 @@ QByteArray QByteArray::mid(int pos, int len) const
\note The behavior is undefined when \a n < 0 or \a n > size().
- \sa first(), slice(), from(), endsWith(), chopped(), chop(), truncate()
+ \sa first(), sliced(), from(), endsWith(), chopped(), chop(), truncate()
*/
/*!
- \fn QByteArray QByteArray::slice(qsizetype pos, qsizetype n) const
+ \fn QByteArray QByteArray::sliced(qsizetype pos, qsizetype n) const
\since 6.0
Returns a byte array containing the \a n bytes of this object starting
@@ -3043,7 +3043,7 @@ QByteArray QByteArray::mid(int pos, int len) const
\note The behavior is undefined when \a pos < 0 or \a pos > size().
- \sa first(), last(), slice(), chopped(), chop(), truncate()
+ \sa first(), last(), sliced(), chopped(), chop(), truncate()
*/
/*!
diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h
index 130509802b..4de7f4ad56 100644
--- a/src/corelib/text/qbytearray.h
+++ b/src/corelib/text/qbytearray.h
@@ -231,7 +231,7 @@ public:
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return QByteArray(data() + size() - n, int(n)); }
Q_REQUIRED_RESULT QByteArray from(qsizetype pos) const
{ Q_ASSERT(pos >= 0); Q_ASSERT(pos <= size()); return QByteArray(data() + pos, size() - int(pos)); }
- Q_REQUIRED_RESULT QByteArray slice(qsizetype pos, qsizetype n) const
+ Q_REQUIRED_RESULT QByteArray sliced(qsizetype pos, qsizetype n) const
{ Q_ASSERT(pos >= 0); Q_ASSERT(n >= 0); Q_ASSERT(size_t(pos) + size_t(n) <= size_t(size())); return QByteArray(data() + pos, int(n)); }
Q_REQUIRED_RESULT QByteArray chopped(int len) const
{ Q_ASSERT(len >= 0); Q_ASSERT(len <= size()); return first(size() - len); }
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index 206d495647..1ccb67203e 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -4516,7 +4516,7 @@ QString QString::left(int n) const
\snippet qstring/main.cpp 48
- \sa endsWith(), last(), first(), slice(), chopped(), chop(), truncate()
+ \sa endsWith(), last(), first(), sliced(), chopped(), chop(), truncate()
*/
QString QString::right(int n) const
{
@@ -4529,7 +4529,7 @@ QString QString::right(int n) const
Returns a string that contains \a n characters of this string,
starting at the specified \a position index.
- \obsolete Use slice() instead in new code.
+ \obsolete Use sliced() instead in new code.
Returns a null string if the \a position index exceeds the
length of the string. If there are less than \a n characters
@@ -4541,7 +4541,7 @@ QString QString::right(int n) const
\snippet qstring/main.cpp 34
- \sa first(), last(), slice(), chopped(), chop(), truncate()
+ \sa first(), last(), sliced(), chopped(), chop(), truncate()
*/
QString QString::mid(int position, int n) const
@@ -4576,7 +4576,7 @@ QString QString::mid(int position, int n) const
\note The behavior is undefined when \a n < 0 or \a n > size().
- \sa last(), slice(), from(), startsWith(), chopped(), chop(), truncate()
+ \sa last(), sliced(), from(), startsWith(), chopped(), chop(), truncate()
*/
/*!
@@ -4587,11 +4587,11 @@ QString QString::mid(int position, int n) const
\note The behavior is undefined when \a n < 0 or \a n > size().
- \sa first(), slice(), from(), endsWith(), chopped(), chop(), truncate()
+ \sa first(), sliced(), from(), endsWith(), chopped(), chop(), truncate()
*/
/*!
- \fn QString QString::slice(qsizetype pos, qsizetype n) const
+ \fn QString QString::sliced(qsizetype pos, qsizetype n) const
\since 6.0
Returns a string that contains \a n characters of this string,
@@ -4612,7 +4612,7 @@ QString QString::mid(int position, int n) const
\note The behavior is undefined when \a pos < 0 or \a pos > size().
- \sa first(), last(), slice(), chopped(), chop(), truncate()
+ \sa first(), last(), sliced(), chopped(), chop(), truncate()
*/
/*!
diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h
index c6ef27c481..bb946b655e 100644
--- a/src/corelib/text/qstring.h
+++ b/src/corelib/text/qstring.h
@@ -454,7 +454,7 @@ public:
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return QString(data() + size() - n, int(n)); }
Q_REQUIRED_RESULT QString from(qsizetype pos) const
{ Q_ASSERT(pos >= 0); Q_ASSERT(pos <= size()); return QString(data() + pos, size() - int(pos)); }
- Q_REQUIRED_RESULT QString slice(qsizetype pos, qsizetype n) const
+ Q_REQUIRED_RESULT QString sliced(qsizetype pos, qsizetype n) const
{ Q_ASSERT(pos >= 0); Q_ASSERT(n >= 0); Q_ASSERT(size_t(pos) + size_t(n) <= size_t(size())); return QString(data() + pos, int(n)); }
Q_REQUIRED_RESULT QString chopped(int n) const
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return first(size() - n); }
diff --git a/src/corelib/text/qstringview.cpp b/src/corelib/text/qstringview.cpp
index 42d18851c7..092f58a90a 100644
--- a/src/corelib/text/qstringview.cpp
+++ b/src/corelib/text/qstringview.cpp
@@ -616,7 +616,7 @@ QT_BEGIN_NAMESPACE
Returns the substring of length \a length starting at position
\a start in this object.
- \obsolete Use slice() instead in new code.
+ \obsolete Use sliced() instead in new code.
Returns an empty string view if \a start exceeds the
length of the string. If there are less than \a length characters
@@ -624,7 +624,7 @@ QT_BEGIN_NAMESPACE
\a length is negative (default), the function returns all characters that
are available from \a start.
- \sa first(), last(), slice(), chopped(), chop(), truncate()
+ \sa first(), last(), sliced(), chopped(), chop(), truncate()
*/
/*!
@@ -638,7 +638,7 @@ QT_BEGIN_NAMESPACE
The entire string is returned if \a length is greater than or equal
to size(), or less than zero.
- \sa first(), last(), slice(), startsWith(), chopped(), chop(), truncate()
+ \sa first(), last(), sliced(), startsWith(), chopped(), chop(), truncate()
*/
/*!
@@ -652,7 +652,7 @@ QT_BEGIN_NAMESPACE
The entire string is returned if \a length is greater than or equal
to size(), or less than zero.
- \sa first(), last(), slice(), endsWith(), chopped(), chop(), truncate()
+ \sa first(), last(), sliced(), endsWith(), chopped(), chop(), truncate()
*/
/*!
@@ -679,7 +679,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QStringView QStringView::slice(qsizetype pos, qsizetype n) const
+ \fn QStringView QStringView::sliced(qsizetype pos, qsizetype n) const
\since 6.0
Returns a string view that points to \a n characters of this string,
diff --git a/src/corelib/text/qstringview.h b/src/corelib/text/qstringview.h
index 6dbec21165..67c4825413 100644
--- a/src/corelib/text/qstringview.h
+++ b/src/corelib/text/qstringview.h
@@ -282,7 +282,7 @@ public:
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return QStringView(m_data + size() - n, int(n)); }
Q_REQUIRED_RESULT constexpr QStringView from(qsizetype pos) const
{ Q_ASSERT(pos >= 0); Q_ASSERT(pos <= size()); return QStringView(m_data + pos, size() - int(pos)); }
- Q_REQUIRED_RESULT constexpr QStringView slice(qsizetype pos, qsizetype n) const
+ Q_REQUIRED_RESULT constexpr QStringView sliced(qsizetype pos, qsizetype n) const
{ Q_ASSERT(pos >= 0); Q_ASSERT(n >= 0); Q_ASSERT(size_t(pos) + size_t(n) <= size_t(size())); return QStringView(m_data + pos, int(n)); }
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView chopped(qsizetype n) const
{ return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QStringView(m_data, m_size - n); }