Rename from() to sliced()
After API discussions, agreement was that from(n) is a bad name for the method. Let's go with sliced(n) instead. Change-Id: I0338cc150148a5008c3ee72bd8fda96fb93e9c35 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
e5fbe10647
commit
9117e3850b
@ -2902,7 +2902,7 @@ QByteArray QByteArray::mid(int pos, int len) const
|
||||
|
||||
\note The behavior is undefined when \a n < 0 or \a n > size().
|
||||
|
||||
\sa last(), sliced(), from(), startsWith(), chopped(), chop(), truncate()
|
||||
\sa last(), sliced(), startsWith(), chopped(), chop(), truncate()
|
||||
*/
|
||||
|
||||
/*!
|
||||
@ -2913,7 +2913,7 @@ QByteArray QByteArray::mid(int pos, int len) const
|
||||
|
||||
\note The behavior is undefined when \a n < 0 or \a n > size().
|
||||
|
||||
\sa first(), sliced(), from(), endsWith(), chopped(), chop(), truncate()
|
||||
\sa first(), sliced(), endsWith(), chopped(), chop(), truncate()
|
||||
*/
|
||||
|
||||
/*!
|
||||
@ -2926,12 +2926,13 @@ QByteArray QByteArray::mid(int pos, int len) const
|
||||
\note The behavior is undefined when \a pos < 0, \a n < 0,
|
||||
or \a pos + \a n > size().
|
||||
|
||||
\sa first(), last(), from(), chopped(), chop(), truncate()
|
||||
\sa first(), last(), chopped(), chop(), truncate()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QByteArray QByteArray::from(qsizetype pos) const
|
||||
\fn QByteArray QByteArray::sliced(qsizetype pos) const
|
||||
\since 6.0
|
||||
\overload
|
||||
|
||||
Returns a byte array containing the bytes starting at position \a pos
|
||||
in this object, and extending to the end of this object.
|
||||
|
@ -226,7 +226,7 @@ public:
|
||||
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return QByteArray(data(), int(n)); }
|
||||
Q_REQUIRED_RESULT QByteArray last(qsizetype n) const
|
||||
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return QByteArray(data() + size() - n, int(n)); }
|
||||
Q_REQUIRED_RESULT QByteArray from(qsizetype pos) const
|
||||
Q_REQUIRED_RESULT QByteArray sliced(qsizetype pos) const
|
||||
{ Q_ASSERT(pos >= 0); Q_ASSERT(pos <= size()); return QByteArray(data() + pos, size() - int(pos)); }
|
||||
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)); }
|
||||
|
@ -4554,7 +4554,7 @@ QString QString::mid(qsizetype position, qsizetype n) const
|
||||
|
||||
\note The behavior is undefined when \a n < 0 or \a n > size().
|
||||
|
||||
\sa last(), sliced(), from(), startsWith(), chopped(), chop(), truncate()
|
||||
\sa last(), sliced(), startsWith(), chopped(), chop(), truncate()
|
||||
*/
|
||||
|
||||
/*!
|
||||
@ -4565,7 +4565,7 @@ QString QString::mid(qsizetype position, qsizetype n) const
|
||||
|
||||
\note The behavior is undefined when \a n < 0 or \a n > size().
|
||||
|
||||
\sa first(), sliced(), from(), endsWith(), chopped(), chop(), truncate()
|
||||
\sa first(), sliced(), endsWith(), chopped(), chop(), truncate()
|
||||
*/
|
||||
|
||||
/*!
|
||||
@ -4582,8 +4582,9 @@ QString QString::mid(qsizetype position, qsizetype n) const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QString::from(qsizetype pos) const
|
||||
\fn QString QString::sliced(qsizetype pos) const
|
||||
\since 6.0
|
||||
\overload
|
||||
|
||||
Returns a string that contains the portion of this string starting at
|
||||
position \a pos and extending to its end.
|
||||
|
@ -441,7 +441,7 @@ public:
|
||||
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return QString(data(), n); }
|
||||
Q_REQUIRED_RESULT QString last(qsizetype n) const
|
||||
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return QString(data() + size() - n, n); }
|
||||
Q_REQUIRED_RESULT QString from(qsizetype pos) const
|
||||
Q_REQUIRED_RESULT QString sliced(qsizetype pos) const
|
||||
{ Q_ASSERT(pos >= 0); Q_ASSERT(pos <= size()); return QString(data() + pos, size() - pos); }
|
||||
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, n); }
|
||||
|
@ -692,8 +692,9 @@ QT_BEGIN_NAMESPACE
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QStringView QStringView::from(qsizetype pos) const
|
||||
\fn QStringView QStringView::sliced(qsizetype pos) const
|
||||
\since 6.0
|
||||
\overload
|
||||
|
||||
Returns a string view starting at position \a pos in this object,
|
||||
and extending to its end.
|
||||
|
@ -280,7 +280,7 @@ public:
|
||||
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return QStringView(m_data, n); }
|
||||
Q_REQUIRED_RESULT constexpr QStringView last(qsizetype n) const
|
||||
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return QStringView(m_data + size() - n, n); }
|
||||
Q_REQUIRED_RESULT constexpr QStringView from(qsizetype pos) const
|
||||
Q_REQUIRED_RESULT constexpr QStringView sliced(qsizetype pos) const
|
||||
{ Q_ASSERT(pos >= 0); Q_ASSERT(pos <= size()); return QStringView(m_data + pos, size() - pos); }
|
||||
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, n); }
|
||||
|
@ -1780,7 +1780,7 @@ void tst_QStringApiSymmetry::sliced_impl()
|
||||
const auto s = make<String>(unicode, latin1, utf8);
|
||||
|
||||
{
|
||||
const auto from = s.from(pos);
|
||||
const auto from = s.sliced(pos);
|
||||
const auto sliced = s.sliced(pos, n);
|
||||
|
||||
QCOMPARE(from, result);
|
||||
@ -1792,7 +1792,7 @@ void tst_QStringApiSymmetry::sliced_impl()
|
||||
QCOMPARE(sliced.isEmpty(), result2.isEmpty());
|
||||
}
|
||||
{
|
||||
const auto from = detached(s).from(pos);
|
||||
const auto from = detached(s).sliced(pos);
|
||||
const auto sliced = detached(s).sliced(pos, n);
|
||||
|
||||
QCOMPARE(from, result);
|
||||
|
Loading…
Reference in New Issue
Block a user