summaryrefslogtreecommitdiffstats
path: root/src/corelib/text
Commit message (Collapse)AuthorAgeFilesLines
* Remove deprecated APILars Knoll2020-09-152-8/+0
| | | | | | | And replace it's few remaining usages Change-Id: I2dfbbaa5259acfece028606bef1e872c5692f9fe Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Purge Q_{STDLIB,COMPILER}_UNICODE_STRINGSEdward Welbourne2020-09-143-11/+1
| | | | | | | | | These were now always defined, hence redundant. Leave the #define in place so that we can verify we actually do always define it, in a #else of an existing #if check on it. Change-Id: Iea4c3dbc8f9982268bcf81da5ef17fe2ebf5c462 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QString: use QCommonArrayOps::erase instead of custom logicAndrei Golubev2020-09-141-4/+2
| | | | | | | | | | With 6e8985e3576a4439bd66c0767f9912d1e124682c merged we can now use generic erase logic provided by array operations. This commit aligns QString with QList/QByteArray Task-number: QTBUG-84320 Change-Id: I83e9349e2461afd98737df25613aa2d0fd817a71 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use universal C++20 bit operations when availableAllan Sandfeld Jensen2020-09-131-0/+8
| | | | | | | Avoids using compiler builtins, and can in future replace them. Change-Id: I3f0afe7d28b6ba05bcd1c1132b44a8db7b182d8a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make QStringList an alias to QList<QString>Lars Knoll2020-09-124-220/+84
| | | | | | | | | | | | | | | | | | Fix our API, so that QStringList and QList<QString> are the same thing. This required a bit of refactoring in QList and moving the indexOf(), lastIndexOf() and contains() method into QListSpecialMethods. In addition, we need to ensure that the QStringList(const QString&) constructor is still available for compatibility with Qt 5. Once those two are done, all methods in QStringList can be moved into QListSpecialMethods<QString>. Change-Id: Ib8afbf5b6d9df4d0d47051252233506f62335fa3 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QString/QBA: change realloc*Data signatures to use qsizetypeAndrei Golubev2020-09-104-26/+26
| | | | | | | | | | Changed reallocData, reallocGrowData signatures to use qsizetype instead of size_t Change-Id: Iebe7def5430d3d3f4660e19cb6c12612543c5abc Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Remove '\0' space reservation logic in QStringAndrei Golubev2020-09-102-32/+43
| | | | | | | | | Changed QString to use implicit element reserved by QArrayData Task-number: QTBUG-84320 Change-Id: If517500b3f0e71bb8d2989c64815a634aa8dd554 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove '\0' space reservation logic in QByteArrayAndrei Golubev2020-09-102-25/+39
| | | | | | | | | Changed QByteArray to use implicit element reserved by QArrayData Task-number: QTBUG-84320 Change-Id: I2a0091c814a47a5c052da7a83d10cb641834c7bd Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix a number of MSVC integer conversion warningsFriedemann Kleint2020-09-102-3/+3
| | | | | | | | Mostly related to qstrlen(). Change-Id: I69e2052c83766e4fc466ed398d0d0eac011a77ec Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Initialize "uc1" variableWang Wei2020-09-081-1/+1
| | | | | | | remove warning for -Wmaybe-uninitialized. Change-Id: Ib17200eb86ee443875a9059b62762b2dc2100634 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QList/QString/QByteArray: no prepend optimized allocation when emptyAndrei Golubev2020-09-072-3/+3
| | | | | | | | | | | | | | | | | | Scoped prepend optimized allocation to only work when prepending into a non-empty container. Otherwise, even appends would be considered prepends since d.size == 0 when container is empty This is, of course, not good for prepend cases but we prefer appends over prepends. My proposal is to figure out what's the best strategy based on use cases and performance measurements. For now, let's just make sure appends are not additionally pessimized Anyhow, this is an implementation detail and should not be considered behavior change (at least not the one that is user noticeable) Task-number: QTBUG-84320 Change-Id: Ibed616a2afa9bc24f78252f15a617bf92e2c6ea3 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Clean up QTextBoundaryFinder and qunicodetoolsLars Knoll2020-09-074-195/+185
| | | | | | | | | | | Make QTBF ready for Qt6 by using qsizetype in the API and use QStringView where it makes sense. Change the exported API of qunicodetools to use QStringView as well and use char16_t internally. Change-Id: I853537bcabf40546a8e60fdf2ee7d751bc371761 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Make QStringMatcher ready for Qt 6Lars Knoll2020-09-072-48/+31
| | | | | | | | | | Use qsizetype for string indices everywhere. Clean up the data structures and remove some Qt 3 or Qt 4 left-overs. This reduces the size of the QStringMatcher from 1056 to 288 bytes. Change-Id: Icc351da8e3aad10a6c940196f52c39f8d2f5bf80 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove some comments that are no longer relevantEdward Welbourne2020-09-051-3/+2
| | | | | | | Task-number: QTBUG-85700 Change-Id: I5ce368e8edca2b9483a0f0ef34bc9eb6b4e44574 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add QByteArrayView overloads for push_back and push_frontLars Knoll2020-09-032-18/+30
| | | | | | | | Change-Id: If70f3ac6764958d92dcbab44432b4f4994d20405 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Clean up the QByteArray API and implementationLars Knoll2020-09-032-271/+139
| | | | | | | | | | | | | | Add overloads using a QByteArrayView where it makes sense, and call those inline from the other overloads. Remove overloads that are not required anymore (due to implicit conversion of a const char * to a QByteArrayView). Guard all implementations against passing this object to them. Change-Id: I930156f8b05ce72c32cb8201c70513f2e6e19d3e Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QList/QByteArray/QString: Base GrowsBackwards heuristic on old sizeMårten Nordheim2020-09-032-4/+4
| | | | | | | | | | | If you grow from 10 to 100 characters then even if the point of insertion was the end then it will get the GrowsBackwards option on realloc. By basing it on the oldSize the intention of the position to insert at is better clarified. Change-Id: Ia73f4902e8356d94709556de5704cbfa0e1a3a56 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QString/QList: disregard space at front during reserve()Andrei Golubev2020-09-021-1/+1
| | | | | | | | | | Aligned QString, QList to the new agreed upon behavior Aligned QList::resize() along the way to be consistent with QString/QBA Task-number: QTBUG-84320 Change-Id: Ie9d7b4b6ebe54bd373af78d92906144b383bbfe2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QByteArray: Disregard space at front during ::reserve(...)Mårten Nordheim2020-09-021-1/+1
| | | | | | | | | | | | Traditionally when calling reserve it's because you expect to append up to X amount of bytes. We should keep that behavior the same. With another patch still in the works current behavior caused an issue with QStringBuilder in QNAM, as mirrored in the testcase attached. Change-Id: I9792a8f158fc9235e3de48ac8b06ac2c10e7f3dc Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Long live Q{Any,Utf8}StringView!Marc Mutz2020-08-319-29/+1957
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need to add these two classes at the same time, because QAnyStringView makes all QUtf8StringView relational operators moot. We might want to add some later, esp. for UTF-8/UTf-8 comparisons, to avoid the pessimization that we can't early-out on size() mismatch in QAnyStringView equality operators, but that's an optimization, not a correctness issue, and can be fixed in a source-compatible way even after Qt 6 is released. To deal with the char8_t problem in C++20, make QUtf8StringView a class template out of which two UTF-8 views can be instantiated: the Qt 7 version, which depends on C++20 char8_t as value_type, and the Qt 6 version where value_type is a char. Use inline namespaces to map the QUtf8StringView identifier to one or the other, depending on the C++ version used to compile the user code. The inline namespace names must needs be a bit ugly, as their inline'ness depends on __cpp_char8_t. If we simply used q_v1/q_v2 we'd be blocking these names for Qt inline namespaces forever, because it's likely that inline'ness of other users of inline namespaces in Qt depends on things other than __cpp_char8_t. While inline'ness of namespaces is, theoretically speaking, a compile-time-only property, at least Clang warns about mixed use of inline on a given namespace, so we need to bite the bullet here. This is also the reason for the QT_BEGIN_..._NAMESPACE macros: GCC is ok with the first declaration making a namespace inline, while Clang warns upon re-opening an inline namespace as a non-inline one. [ChangeLog][QtCore][QUtf8StringView] New class. [ChangeLog][QtCore][QAnyStringView] New class. Change-Id: Ia7179760fca0e0b67d52f5accb0a62e389b17913 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Inline some methods that only forward to another overloadLars Knoll2020-08-292-24/+16
| | | | | Change-Id: Iba74962d20c00de8996834f0a003f38c2d2cc3e8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use checked string iteration in case conversionsEdward Welbourne2020-08-294-7/+11
| | | | | | | | | | | | | | | | | | The Unicode table code can only be safely called on valid code-points. So code that calls it must only pass it valid Unicode data. The string iterator's Unchecked Unchecked methods only provide this guarantee when the string being iterated is guaranteed to be valid UTF-16; while client code should only use QString, QStringView and friends on valid UTF-16 data, we have no way to be sure they have respected that. So take the few extra cycles to actually check validity in the course of iterating strings, when the resulting code-points are to be passed to the Unicode table look-ups. Add tests that case mapping doesn't access Unicode tables out of range (it'll trigger the new assertion). Added some comments to qchar.h that helped me understand surrogates. Change-Id: Iec2c3106bf1a875bdaa1d622f6cf94d7007e281e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Prepend optimize QStringAndrei Golubev2020-08-292-59/+100
| | | | | | | | Added prepend optimization to QString Task-number: QTBUG-84320 Change-Id: Iaa8df790a10c56ecceb06f7143718fb94874ce76 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Support GrowsBackwards in QByteArrayAndrei Golubev2020-08-292-57/+92
| | | | | | | | | | | | | | | Updated main QByteArray operations to support prepend-optimization path There are still many things to consider especially algorithms that use QByteArray::data() or do raw memory operations (e.g. memcpy) regardless of the underlying memory layout, which was somewhat valid before but will likely break now given free space > 0 at the beginning of the byte array memory. Looked at existing cases in the scope of QByteArray, they seem to be OK. Hopefully, CI would find missed violations if any Task-number: QTBUG-84320 Change-Id: I7990cda165b8e77a397e41df4e145468e7a86be0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove QUnicodeTools::DefaultOptionsCompatEdward Welbourne2020-08-281-2/+1
| | | | | | | | | | Used in only one place, declared in a private header with a comment saying to remove it. All callers of the one function that had it as default parameter value are passing a value for the parameter. Task-number: QTBUG-85700 Change-Id: Ic72e4df730740a4023b0a43be6bf7acf33a3166b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Convert QStringView::toWCharArray() to return qsizetypeEdward Welbourne2020-08-282-4/+4
| | | | | | | | As requested in a ### Qt6 comment. Task-number: QTBUG-85700 Change-Id: I28a02bf49f4a6455a21a6032179318ce2915b8ca Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Inline QString's conversions to integral types, except long long onesEdward Welbourne2020-08-282-39/+18
| | | | | | | | As requested by a ### Qt6 comment. Task-number: QTBUG-85700 Change-Id: I7c2813c0d8fbc38bcd2f7229de3a9d8e1b8b1f03 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLatin1String: finish up the qsizetype conversionEdward Welbourne2020-08-281-2/+2
| | | | | | | | | Correct one QString::lastIndexOf() whose return and parameter had been changed, but body and comment hadn't. Task-number: QTBUG-85700 Change-Id: Icbcd049f72346f0e696e6b22fe0893f6de5a2646 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use qsizetype for the size of QByteArray's raw data methodsEdward Welbourne2020-08-281-7/+2
| | | | | | | | | A ### comment said to use int in setRawData(), which took a uint; but the underlying QArrayDataPointer::fromRawData() takes a qsizetype, so propagate that all the way. Change-Id: Iba1f8d020c509b33f5c202c22c6a9bf85b3bab7f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use char32_t for QLocaleData::zeroUcs() and friendsEdward Welbourne2020-08-284-30/+27
| | | | | | | | | | Also catch some stray ushort that should be char16_t by now, use unicode character values for some constants and rename a UCS2 variable to not claim it's UCS4. Change-Id: I374b791947f5c965eaa22ad5b16060b475081c9d Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Don't second-guess strcoll()Edward Welbourne2020-08-281-8/+3
| | | | | | | | | It's defective on Android, but no worse so than the fall-back we were using; and we can't remember why we had that fall-back anyway. Task-number: QTBUG-63518 Change-Id: I28e9b5c7cc64963c9e3941eb1bad85aced280a9b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Use qsizetype in QRegularExpressionMarcel Krems2020-08-282-43/+43
| | | | | | | PCRE2 already uses size_t which we can now make full use of. Change-Id: Icb5efd5c6ef27f2e31a9780bf62f5671ddc603cd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* macOS: fix standaloneMonthName implementation for system localeVolker Hilsheimer2020-08-271-5/+23
| | | | | | | | | | | | macOS has specific formatters for the standalone month names, so use them. Change-Id: Ic4ad547c7d1c29d71c85f60301acd5a5f0f263d2 Fixes: QTBUG-86191 Pick-to: 5.15 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Evgeniy Dushistov <dushistov@mail.ru> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Pass QByteArrayView by valueLars Knoll2020-08-272-5/+5
| | | | | | Change-Id: I65df03e7781bac63d98b8d3b59568841601d8f25 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Inline the equality operatorLars Knoll2020-08-272-13/+8
| | | | | | | There's no reason to have this out of line. Change-Id: I52aa2ba941f9c81c2194865b156dbc0a2104363b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change QByteArray to handle large arraysLars Knoll2020-08-273-208/+201
| | | | | | | | | | Use qsizetype throughout. Change-Id: I787af7fcfa17e1be87decb64c41c609cc24be117 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add back QByteArray's relational operators taking QStringSona Kurazyan2020-08-263-0/+105
| | | | | | | | | | | | | QString still has the overloads of relational operators taking QByteArray. Add back QByteArray's relational operators taking QString for symmetry. See also the comments of d7ccd8cb4565c8643b158891c9de3187c1586dc9 for more details. [ChangeLog][EDITORIAL] Remove the changelog about QString/QByteArray operators being removed. They're back. Change-Id: I22c95e727285cf8a5ef79b3a4f9d45cb66319252 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRegularExpression: code tidiesGiuseppe D'Angelo2020-08-261-6/+2
| | | | | | | | Given QList-is-QVector, remove an historical piece of code. Change-Id: I7a8876be8ade6dbaa1822d773b092ddb3c4182d4 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRegularExpression: do not assume QStringViews are NUL terminatedGiuseppe D'Angelo2020-08-251-3/+18
| | | | | | | | | | | The convenience API used to look up the index of a named capturing group expects NUL terminated strings. Therefore, we can't just use it together with QStringViews, which may be not. Use the non-convenience API instead. Pick-to: 5.15 Change-Id: I25ca14de49b13ee1764525f8b19f2550c30c1afa Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QStringList: inherit the constructors from QListGiuseppe D'Angelo2020-08-252-28/+1
| | | | | | | Otherwise it would be missing some, e.g. QStringList(qsizetype). Change-Id: I5214672e62c98514b37b09d283e6035c799eda99 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QByteDataBuffer: add readPointer functionality using QByteArrayViewMårten Nordheim2020-08-241-0/+49
| | | | | | | | While it could be done before it's nice to not have a custom "local" struct or the size in an out-parameter. Change-Id: Ie910f7060b1dadf037312d45e922f8e2deafe3ec Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QStringTokenizer: use sliced() instead of mid()Marc Mutz2020-08-231-2/+2
| | | | | | | | The code was developed against the narrow-contract version of mid(), but not updated when mid() became wide-contract. Change-Id: I038054fb3f5acc0085c48fbf36af13dd14c917b8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Port QLatin1String to qsizetype and add narrow-contract substring functionsMarc Mutz2020-08-233-67/+147
| | | | | | | | | | | | | | | | | | | | | | QLatin1String::mid() etc were changed from narrow to wide contract, but the narrow-contract replacements weren't added. This blocks using the narrow-contract functions in QStringTokenizer. As a drive-by, Q_REQUIRED_RESULT -> [[nodiscard]] and Q_DECL_CONSTEXPR -> constexpr. Also centralize most Q_ASSERT()s in a single function, verify(), in an attempt to reduce the amount of string data generated from the asserts in assertive builds. [ChangeLog][QtCore][QLatin1String] Added from(), sliced(), first(n), last(n) functions. [ChangeLog][QtCore][QLatin1String] size_type/size() is now qsizetype (was: int). This makes QLatin1String(ptr, 0) ambiguous now between the (ptr, ptr) and (ptr, qsizetype) constructors. Change-Id: Ie195f66ae1974eb0752c058aa9f3b0853ed92477 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix a number of qdoc warningsFriedemann Kleint2020-08-201-1/+1
| | | | | | | | | | | - Remove obsolete functions and enumeration values - Remove QObject * parameter from QMetaProperty accessors - Fix renamed enumerations in QSsl - Fix list items to be \li - Fix function signatures and variable names Change-Id: I37c7e6bf2c8ff92bc7b82620bae0a27796f866ab Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Move QStringRef and remains to Qt5CompatKarsten Heimrich2020-08-2010-2260/+42
| | | | | | | | | Export some private functions from QUtf8 to resolve undefined symbols in Qt5Compat after moving QStringRef. Task-number: QTBUG-84437 Change-Id: I9046dcb14ed520d8868a511d79da6e721e26f72b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Refactor QXmlStreamStringRefKarsten Heimrich2020-08-191-0/+1
| | | | | | | | | | | | | Use a QStringPrivate inside the implementation. This saves two pointers, and actually makes this a safe replacement for QStringRef inside the implementation of QXmlStreamReader. Unexport the class as all members are inline, and move it into the QtPrivate namespace as class QXmlString. Change-Id: I43fa4684f569514c8c621838dcc346657ac1a915 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Remove binary compat sources for qbytearray and qstringAllan Sandfeld Jensen2020-08-194-137/+2
| | | | | | | No longer needed in Qt6. Change-Id: I29567e175e07cc3658f0619acfd604abf64f6459 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace Qt CONSTEXPR defines with constexprAllan Sandfeld Jensen2020-08-149-158/+158
| | | | | | | | Both normal and relaxed constexpr are required by our new minimum of C++17. Change-Id: Ic028b88a2e7a6cb7d5925f3133b9d54859a81744 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Drop qunicodecharGiuseppe D'Angelo2020-08-141-6/+1
| | | | | | | | | It's unused except in the definition of QStringLiteral, where we can just use char16_t. The static_assert can also go as it's already checked in qglobal.cpp. Change-Id: I06e8a87b4dea1582cd84957efca1b8ad0d2e0266 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Inline two macros in the unicode tablesEdward Welbourne2020-08-121-10/+6
| | | | | | | | They were only used by one function each, in unicodetables.cpp, so don't need to be macros. Change-Id: I3e7f9f661568862d0a0d265bb8f657a8e0782b13 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>