summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstringview.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QStringView/QLatin1String: add trimmed()Marc Mutz2017-05-161-0/+12
| | | | | | | | | | | | | | | | | | | ... using the same qt_trimmed(), qTrimmed(), Q..::trimmed() split we've been using for all other out-of-line string-view member functions to avoid forcing string-view objects onto the stack for the passing of 'this'. In the test, had to fix nullness not being propagated from a QByteArray to the QLatin1String constructed from it. Probably worth fixing in QLatin1String(QByteArray), too. [ChangeLog][QtCore] Added qTrimmed() free functions. [ChangeLog][QtCore][QLatin1String] Added trimmed() function. Change-Id: I73c18ef87e203f30f7552c10dd5c84223bcfae0e Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QStringView: add constructor from pointer pairMarc Mutz2017-05-161-0/+20
| | | | | | | | | This is often more natural than (ptr, len), and I need it in the implementation of QStringView::trimmed(). Change-Id: I1d99b5ddaf76eee0582150b0233ef6ce9c37d25d Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* [doc] QStringView: remove documentation of removed constructorMarc Mutz2017-05-061-9/+0
| | | | | Change-Id: I3b5ad8deabd67f2327c45fe8aa914c0e7883513c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QStringView: add startsWith(), endsWith()Marc Mutz2017-04-281-0/+32
| | | | | Change-Id: I72aef9236daedc3013c62d3f1d737159f85572b8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QStringView: add internal qToStringViewIgnoringNull()Marc Mutz2017-04-191-0/+15
| | | | | | | | | | | | | | | | | | As long as a null QString still returns non-null data(), QStringView's QString constructor needs to call isNull(). That's a branch we often can do without, so add an internal function that bypasses this correctness check. It's internal, since we might have a Q6String that returns nullptr data() when null, which will remove the need for this function. What the QStringView(QString) ctor does will also have to be re-evaluated come Qt 6, but for now, keep the public QString- QStringView conversion correct. Change-Id: I35dc7383bc3bd018f46aeec429185135a38ddcef Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QStringView: add chopped(), chop(), and truncate()Marc Mutz2017-04-181-4/+41
| | | | | | Change-Id: I33925f5b2b3e0904f47f18f3cbab480d7f844734 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add qConvertTo{Utf8,Latin1,Local8Bit,Ucs4}() and corresponding QStringView ↵Marc Mutz2017-04-071-0/+51
| | | | | | | | | | | | | | | | | methods Like the qt_compare_strings()/qCompareStrings() split, distinguish between the internal and exported functions. Because of the circular dependency between qstring.h and qvector.h, the inline toUcs4() function has to be in qvector.h. At some point, we need to refactor the headers so qvector.h is lower in the dependency chain than qstring.h. It's not the first time this bites. Change-Id: Ief9f3bd92c83cdd1f31c51c700f42e146916eefd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QStringView: use qssize_t as size_typeMarc Mutz2017-04-061-10/+10
| | | | | | | | | | Nothing changes, we've just given 'QIntegerForSizeof<size_t>::Signed' a better name in qglobal.h and now use it in QStringView API and users. Change-Id: Ibea1ae26e95b3a96708400fd4b0cd120459d57b6 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Fix some issues with the QStringView docsMarc Mutz2017-04-051-6/+4
| | | | | Change-Id: Ibb6fed18c6b7aa23ffc259dc66d22d4ff0372ca0 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QStringView: add an array ctorMarc Mutz2017-04-041-3/+27
| | | | | | | | | With sufficient enable_if magic, the array ctor can overload the pointer ctor and statically determine the size of the array passed. Consequently, remove the sizeof in QStringViewLiteral again. Change-Id: I486baa3cafefde60ccc5f2b47eb94ee53cefe63c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QStringView: add mid(), left(), right()Marc Mutz2017-03-311-0/+46
| | | | | | | | Change-Id: If1d2cf175d51b3c02881e21937b0a2d33b78aadd Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QStringView: document utf16() and why it's the way it isMarc Mutz2017-03-281-2/+20
| | | | | Change-Id: If141308f4a35a10ff86b0c5259bc4df849bba36a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Long live QStringView!Marc Mutz2017-03-241-0/+533
QStringView is a simple container for (const QChar*, int) and (const char16_t*, size_t). It acts as a replacement interface type for const QString and const QStringRef, and enables passing all kinds of string-like types to functions otherwise expecting const QString& - without the need to convert to QString first. The use of this new class is guarded by a macro that enables three levels of QStringView support: 1. offer QStringView, overload some functions taking QString with QStringView 2. like 1, but remove all overloads of functions taking QStringRef, leaving only the function taking QStringView. Do this only where QStringRef overloads tradionally existed. 3. like 2, but replace functions taking QString, too. This is done in order to measure the impact of QStringView on code size and execution speed, and to help guide the decision of which level to choose for Qt 6. This first patch adds QStringView with most of its planned constructors, but not much more than iterators and isNull()/isEmpty(). Further patches will add support for QStringView to QStringBuilder, add QStringView overloads of functions taking QString, and add the complete API of const QString to QStringView. [ChangeLog][QtCore][QStringView] New class, superseding const QString and QStringRef as function parameters, accepting a wide variety of UTF-16 string data sources, e.g. u"string", std::u16string{,_view}, and, on Windows, L"string", std::wstring{,_view} without converting to QString first. Change-Id: Iac273e46b2c61ec2c31b3dacebb29500599d6898 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>