From fc8cc2573c75b2cb81493dba67b2a9e24699c1ec Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 5 Apr 2017 08:55:19 +0200 Subject: QStringView: add chopped(), chop(), and truncate() Change-Id: I33925f5b2b3e0904f47f18f3cbab480d7f844734 Reviewed-by: Anton Kudryavtsev Reviewed-by: Lars Knoll --- src/corelib/tools/qstringview.cpp | 45 +++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) (limited to 'src/corelib/tools/qstringview.cpp') diff --git a/src/corelib/tools/qstringview.cpp b/src/corelib/tools/qstringview.cpp index 65f76965f6..1dc01e321b 100644 --- a/src/corelib/tools/qstringview.cpp +++ b/src/corelib/tools/qstringview.cpp @@ -578,7 +578,7 @@ QT_BEGIN_NAMESPACE \note The behavior is undefined when \a start < 0 or \a start > size(). - \sa left(), right() + \sa left(), right(), chopped(), chop(), truncate() */ /*! @@ -591,7 +591,7 @@ QT_BEGIN_NAMESPACE \note 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() */ /*! @@ -602,7 +602,7 @@ QT_BEGIN_NAMESPACE \note The behavior is undefined when \a length < 0 or \a length > size(). - \sa mid(), right() + \sa mid(), right(), chopped(), chop(), truncate() */ /*! @@ -613,7 +613,44 @@ QT_BEGIN_NAMESPACE \note The behavior is undefined when \a length < 0 or \a length > size(). - \sa mid(), left() + \sa mid(), left(), chopped(), chop(), truncate() +*/ + +/*! + \fn QStringView QStringView::chopped(qssize_t length) const + + 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 QStringView::truncate(qssize_t length) + + Truncates this string view 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 QStringView::chop(qssize_t length) + + Truncates this string view 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() */ /*! -- cgit v1.2.3