[Development] Feature Freeze Exception: QStringView
Marc Mutz
marc.mutz at kdab.com
Tue Jan 31 12:24:02 CET 2017
On Tuesday 31 January 2017 10:55:52 Иван Комиссаров wrote:
> What about toInt/toDouble/etc, toLower/toUpper, right/left/mid (aka
> std::string_view::remove_prefix/suffix), find and other QString methods
> that doesn't modify the string? Do you plan to add them later or support
> only small subset of operations (similar to std::string_view?)
> Or maybe i miss some commits?
As I wrote multiple times before, the end game is that QStringView carries all
of the const QString API, as much as is possible. Hopefully, that will be the
state going into 5.10.0.
If it goes into 5.9, it will only provide a very limited subset, but even so
it allows full use of the type in APIs since many parsing tasks quickly
delegate to something working on QChar*, anyway.
ATM, I try to strike a balance between adding new functions and adding new
users. Adding new functions is a lot of work, since I write comprehensive
tests that test a function across all string-like classes in Qt and that tend
to find bugs in other implementations, too, cf. QStringRef::toLatin1(). Adding
new users is comparatively easy, and more rewarding work.
As for toInt() etc, they need QStringView support in QLocale, which is what
I'm focusing on atm, with several patches already up on Gerrit. Stuff like
toLower() has less priority, since toString().toLower() is just as efficient
(non-shared QString returned invoking rvalue-overload of toLower(), reusing
the internal buffer). But they will come, too, but I'm not sure about the
form. They could return QString, of course, or they could take any container,
toStdBasicString-style, so you could pass a QVarLengthArray or a static
buffer.
> What about QByteArrayView? Do you plan to use std::string_view instead?
QByteArrayView will also come. Come Qt 6, QStringView, QLatin1String,
QByteArrayView should all be represented by the same template. Until then,
tst_qstringapisymmetry ensures equally-named functions have a subset of
operations between them that behave identical (the views have stricter
preconditions for some functions, thus "subset").
Thanks,
Marc
--
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt, C++ and OpenGL Experts
More information about the Development
mailing list