summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qstringview
Commit message (Collapse)AuthorAgeFilesLines
* QString: towards QStringView::arg() pt.3: Long live ↵Marc Mutz2019-06-201-0/+43
| | | | | | | | | | | | | | | | | | QStringView/QLatin1String::arg() This version of arg(), unlike its QString counterpart, transparently accepts views without conversion to QString, and is also extensible to further argument types, say a future QFormattedNumber. [ChangeLog][QtCore][QStringView/QLatin1String] Added arg(), taking arbitrarily many strings. Change-Id: If40ef3c445f63383e32573f3f515fdda84c7fe3a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QStringView: Add compare() member functionFriedemann Kleint2018-07-131-0/+20
| | | | | | | | | | There was no public API for doing case-insensitive comparisons of QStringView. Task-number: QTBUG-69389 Change-Id: I1b021eefec35e135b97fb87704c8dc137232d83d Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix license headersJani Heikkinen2018-01-111-17/+12
| | | | | | | | Remove usage of outdated header.LGPL21 and replace those with proper one (header.LGPL in src, header.GPL-EXCEPT in tests) Change-Id: Ia4d1c0d84b77f09787fe7c30670747a1fe2aff29 Reviewed-by: Liang Qi <liang.qi@qt.io>
* Improve readability of code that uses the Qt signed size typev5.10.0-rc2Simon Hausmann2017-11-281-2/+2
| | | | | | | | | | | | | | | | | During the container BoF session at the Qt Contributor Summit 2017 the name of the signed size type became a subject of discussion in the context of readability of code using this type and the intention of using it for all length, size and count properties throughout the entire framework in future versions of Qt. This change proposes qsizetype as new name for qssize_t to emphasize the readability of code over POSIX compatibility, the former being potentially more relevant than the latter to the majority of users of Qt. Change-Id: Idb99cb4a8782703c054fa463a9e5af23a918e7f3 Reviewed-by: Samuel Gaist <samuel.gaist@edeltech.ch> Reviewed-by: David Faure <david.faure@kdab.com>
* Improve qustrlen further by avoiding the alignment prologueThiago Macieira2017-09-261-6/+31
| | | | | | | | | | | This avoids looping prior to the main 16-byte loop, by performing one load that may include bytes prior to the start of the string. This is guaranteed not to fault, since str points to a valid character, but it may cause Valgrind to print warnings. Change-Id: I6e9274c1e7444ad48c81fffd14dcae854bba24b2 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QStringView: De-inline the length calculation so we can use SSE2Thiago Macieira2017-09-131-0/+44
| | | | | | | | | | | | | | | | | | Performance is more important in this case than the theoretical benefit of constexpr. This commit implements the SSE2 search for 16-bit null and it might be possible to implement the equivalent for AArch64 (investigation required). It also adds a fallback to wcslen() for systems where wchar_t is short (non-x86 Windows or 32-bit x86 build with -no-sse2). We can re-add the constexpr loop once the C++ language has a way of overloading constexpr and non-constexpr. GCC has a non-standard way to do that with __builtin_constant_p, which is also implemented in this commit, but note that the inline function is still not constexpr. Change-Id: I6e9274c1e7444ad48c81fffd14dcaacafda5ebdc Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QStringView: add constructor from pointer pairMarc Mutz2017-05-161-0/+75
| | | | | | | | | 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>
* QtTest: add support for printing QStringViewsMarc Mutz2017-04-241-6/+8
| | | | | | | | | [ChangeLog][QtTest][QCOMPARE] Now supports printing QStringViews in case of test failures. Change-Id: I4dc2542cd1013fd63c094c249e721d7102387bde Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use new Q_STDLIB_UNICODE_STRINGS and Q_COMPILER_UNICODE_STRINGSMarc Mutz2017-04-201-4/+4
| | | | | | | | | ... instead of the combination with Q_OS_WIN we used so far. This patch adapts ocurrences that are new in 5.10. Change-Id: If392df481713e56c776c2326e0e02324a3a80c89 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QStringView: use qssize_t as size_typeMarc Mutz2017-04-061-2/+2
| | | | | | | | | | 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>
* QStringView: add an array ctorMarc Mutz2017-04-041-0/+41
| | | | | | | | | 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 tests for relational operatorsMarc Mutz2017-03-311-52/+26
| | | | | | | | | | | | | Remove most of the std::equal() tests that were used to determine equality in pre-relational-operator-times again. Amends a1421e47871448718fd54e83f0106a38722bdfe4. Change-Id: Iff64808f5ac60861caee899d594b512b58046636 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QStringView: improve manual overload managementMarc Mutz2017-03-291-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We want to prevent QStringView(QChar|QLatin1String|QByteArray|const char*) from compiling as QStringView(QString(...)), so I added = delete'ed ctors for these types to QStringView. However, that makes QStringView participate in overload resolution for these types. Even if the QStringView ctor will always fail to compile, the presence of these ctors alone makes calls to functions overloaded on QString and QStringView ambiguous: f(QStringView); f(QString); f(foo); // ambiguous f(QChar('f')) // ambiguous f(QLatin1String(foo)); // ambiguous f(QByteArray(foo)); // ambiguous Fix by making the QString and QStringRef constructors templates constrained to accept only these two types. This should also help to move the QStringView definition to before the QString one (as soon as we get rid of or start to ignore QString::Null), simplifying a lot of code in qstring.h down the line. This should also fix MSVC's accepting of two user-defined conversions which caused static non-compile-tests to fail in the initial QStringView patch, and which were therefore removed. This patch brings them back. Change-Id: I95ac38c0d31cd8c726f7e952017569d32e484413 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Long live QStringView!Marc Mutz2017-03-243-0/+453
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>