QLatin1String: add chopped(), chop(), and truncate()
[ChangeLog][QtCore][QLatin1String] Added chopped(), chop(), truncate(). Change-Id: I69b31aae560e94a120d7e8a36e06ea957ccd2003 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
fc8cc2573c
commit
a21a9efacb
@ -8961,7 +8961,7 @@ QString &QString::setRawData(const QChar *unicode, int size)
|
||||
\note This function performs no error checking.
|
||||
The behavior is undefined when \a start < 0 or \a start > size().
|
||||
|
||||
\sa left(), right()
|
||||
\sa left(), right(), chopped(), chop(), truncate()
|
||||
*/
|
||||
|
||||
/*! \fn QLatin1String QLatin1String::mid(int start, int length) const
|
||||
@ -8975,7 +8975,7 @@ QString &QString::setRawData(const QChar *unicode, int size)
|
||||
The behavior is undefined when \a start < 0, \a length < 0,
|
||||
or \a start + \a length > size().
|
||||
|
||||
\sa left(), right()
|
||||
\sa left(), right(), chopped(), chop(), truncate()
|
||||
*/
|
||||
|
||||
/*! \fn QLatin1String QLatin1String::left(int length) const
|
||||
@ -8987,7 +8987,7 @@ QString &QString::setRawData(const QChar *unicode, int size)
|
||||
\note This function performs no error checking.
|
||||
The behavior is undefined when \a length < 0 or \a length > size().
|
||||
|
||||
\sa mid(), right()
|
||||
\sa mid(), right(), chopped(), chop(), truncate()
|
||||
*/
|
||||
|
||||
/*! \fn QLatin1String QLatin1String::right(int length) const
|
||||
@ -8999,7 +8999,47 @@ QString &QString::setRawData(const QChar *unicode, int size)
|
||||
\note This function performs no error checking.
|
||||
The behavior is undefined when \a length < 0 or \a length > size().
|
||||
|
||||
\sa mid(), left()
|
||||
\sa mid(), left(), chopped(), chop(), truncate()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QLatin1String QLatin1String::chopped(int length) const
|
||||
\since 5.10
|
||||
|
||||
Returns the substring of length size() - \a length starting at the
|
||||
beginning of this object.
|
||||
|
||||
Same as \c{left(size() - length)}.
|
||||
|
||||
\note The behavior is undefined when \a length < 0 or \a length > size().
|
||||
|
||||
\sa mid(), left(), right(), chop(), truncate()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QLatin1String::truncate(int length)
|
||||
\since 5.10
|
||||
|
||||
Truncates this string to length \a length.
|
||||
|
||||
Same as \c{*this = left(length)}.
|
||||
|
||||
\note The behavior is undefined when \a length < 0 or \a length > size().
|
||||
|
||||
\sa mid(), left(), right(), chopped(), chop()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QLatin1String::chop(int length)
|
||||
\since 5.10
|
||||
|
||||
Truncates this string by \a length characters.
|
||||
|
||||
Same as \c{*this = left(size() - length)}.
|
||||
|
||||
\note The behavior is undefined when \a length < 0 or \a length > size().
|
||||
|
||||
\sa mid(), left(), right(), chopped(), truncate()
|
||||
*/
|
||||
|
||||
/*! \fn bool QLatin1String::operator==(const QString &other) const
|
||||
|
@ -152,6 +152,13 @@ public:
|
||||
{ return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QLatin1String(m_data, n); }
|
||||
Q_DECL_CONSTEXPR QLatin1String right(int n) const
|
||||
{ return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QLatin1String(m_data + m_size - n, n); }
|
||||
Q_DECL_CONSTEXPR QLatin1String chopped(int n) const Q_REQUIRED_RESULT
|
||||
{ return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QLatin1String(m_data, m_size - n); }
|
||||
|
||||
Q_DECL_RELAXED_CONSTEXPR void chop(int n)
|
||||
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); m_size -= n; }
|
||||
Q_DECL_RELAXED_CONSTEXPR void truncate(int n)
|
||||
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); m_size = n; }
|
||||
|
||||
inline bool operator==(const QString &s) const Q_DECL_NOTHROW;
|
||||
inline bool operator!=(const QString &s) const Q_DECL_NOTHROW;
|
||||
|
@ -238,6 +238,8 @@ private Q_SLOTS:
|
||||
void chop_QStringRef() { chop_impl<QStringRef>(); }
|
||||
void chop_QStringView_data() { chop_data(); }
|
||||
void chop_QStringView() { chop_impl<QStringView>(); }
|
||||
void chop_QLatin1String_data() { chop_data(); }
|
||||
void chop_QLatin1String() { chop_impl<QLatin1String>(); }
|
||||
void chop_QByteArray_data() { chop_data(); }
|
||||
void chop_QByteArray() { chop_impl<QByteArray>(); }
|
||||
|
||||
@ -247,6 +249,8 @@ private Q_SLOTS:
|
||||
void truncate_QStringRef() { truncate_impl<QStringRef>(); }
|
||||
void truncate_QStringView_data() { truncate_data(); }
|
||||
void truncate_QStringView() { truncate_impl<QStringView>(); }
|
||||
void truncate_QLatin1String_data() { truncate_data(); }
|
||||
void truncate_QLatin1String() { truncate_impl<QLatin1String>(); }
|
||||
void truncate_QByteArray_data() { truncate_data(); }
|
||||
void truncate_QByteArray() { truncate_impl<QByteArray>(); }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user