summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstringview.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2017-04-05 08:53:15 +0200
committerMarc Mutz <marc.mutz@kdab.com>2017-04-18 09:43:18 +0000
commitd176808eef61d27a6536f268125dab4088a248d3 (patch)
tree91b8155c55e092bbf9a8976fa77d5be2adbcb6b3 /src/corelib/tools/qstringview.h
parent6d3c4833c26cced876ed57e9f158fbade5b2679c (diff)
QByteArray, QString, QStringRef: Add chopped()
We have two functions to get a substring without doing some calculations involving size(): - mid(p): mid(p, size() - p) - right(n) : mid(size() - n, n) (left does not involve size(), so isn't in that set). What was missing was a name for - f(n): mid(0, size() - n) As an action, it's called chop(), so call the transformation version chopped(). I made chopped(n), n < 0 or n > size(), undefined, because QString(Ref) ::left() is broken[1], while the QByteArray implementation is not. This is the only way to get consistent behavior among the three classes. I's also the correct thing to do. [1] instead of returning the empty string for negative indexes, it returns the whole string. [ChangeLog][QtCore][QString/QStringRef/QByteArray] Added chopped(n), a const version of chop(n). Change-Id: I6c2c5b16e0060fa924ced5860f21f2d0f23bd023 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Diffstat (limited to 'src/corelib/tools/qstringview.h')
0 files changed, 0 insertions, 0 deletions