summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qstring.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2019-12-111-1/+1
|\ | | | | | | | | | | | | Conflicts: tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp Change-Id: I6b82507bf9a80a374c40393e72f4843f1557de89
| * Don't wrap feature detection macros with QT_HAS_FOO() variantsTor Arne Vestbø2019-12-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using wrappers for these macros is problematic when for example passing the -frewrite-includes flag to preprocess sources before shipping off to distcc or Icecream. It will also start producing warnings when compilers implement http://eel.is/c++draft/cpp.cond#7.sentence-2. See for example https://reviews.llvm.org/D49091 Both https://clang.llvm.org/docs/LanguageExtensions.html and the SD-6 document at https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations recommend defining '__has_foo(x) 0' as a fallback for compilers without the macros, so that's what we go for. Change-Id: I0298cd3b4a6ff6618821e34642a5ddd6728be767 Reviewed-by: Alex Richardson <arichardson.kde@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Use QString::DataPointer instead of QStringPrivateLars Knoll2019-12-081-6/+7
| | | | | | | | | | | | | | | | Preparations to move QString over to use QArrayDataPointer instead of it's own private struct. Change-Id: I7796a595393394083f6a85863e3c710ebbdea149 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Get rid of QCharRef and QByteRefLars Knoll2019-12-081-131/+7
| | | | | | | | | | | | | | | | | | | | We already detach immediately since change c2d2757bccc68e1b981df059786c2e76f2969530. That basically removes the main purpose of having QChar/ByteRef, and we can just as well get rid of those classes for Qt 6. Change-Id: I8dc566a1948ddc29c0cb8a77ec7310654a7219a4 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Inline the size and data pointers in QByteArrayThiago Macieira2019-12-081-5/+5
| | | | | | | | | | Change-Id: I82feeb2c9bd2900f421fc0c8d78698b1e83db043 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Inline the size and data pointer members in QStringThiago Macieira2019-12-081-54/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'd have preferred to use QArrayDataPointer<ushort> for QString, but that option wasn't the best one. QArrayDataPointer try to do some operations using QArrayDataOps and that would expand to unnecessary code. What's more, the existing code expected to be able to modify and access the d pointer. Instead, this commit introduces QStringPrivate (named differently from QStringData to catch potential users), which contains the three members. This POD class is also used in QJsonValue to store the "inlined" QString. QHashedString in qtdeclarative will need a similar solution. Change-Id: I33f072158e6e2cd031d4d2ffc81f4a8dbaf4e616 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Get rid of the operator[](uint) overloadsLars Knoll2019-12-081-6/+0
| | | | | | | | | | | | | | | | Those make no sense and where probably only there to workaround bugs in some old compilers. Change-Id: I5b196cc5306ac1c6307257b70179278d82d383c1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Add reference-count manipulation functions to QArrayData and hide refThiago Macieira2019-12-081-4/+4
| | | | | | | | | | | | | | | | The next change will stop using some values in the reference counter as settings from the data. Change-Id: I94df1fe643896373fac2f000fff55bc7708fc807 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Introduce the Mutable flag and move QArrayDataPointer::needsDetachThiago Macieira2019-12-081-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Mutable flag now contains the information on whether the data this QArrayData points to is mutable. This decouples the mutability / immutability setting from the allocation and from the type of data, opening the way for mutable raw or foreign data. There are still plenty of places in the source code that check the size of the allocation when it actually wants d->isMutable(). Fixing this will require reviewing all the code, so is left for later. The needsDetach() function is moved to QArrayData and de-constified. It returns true when a reallocation is necessary if the data is to be modified. Change-Id: I17e2bc5a3f6ef1f3eba8a205acd9852b95524f57 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Introduce flags to indicate the QArrayData typeThiago Macieira2019-12-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These flags allow us to determine what type of data QArrayData is carrying. There are currently only two supported types: - raw data type: constructed via fromRawData or static data - allocated data type: regular data done via heap allocation The QArrayData object is usually allocated on the heap, unless its own reference count is -1 (indicating static const QArrayData). Such object should have a type of RawDataType, since we can't call free(). Add GrowsBackward for completeness as well as the StaticDataFlags default for static data. Change-Id: Icc915a468a2acf2eae91a94e82451f852d382c92 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Introduce QArrayData::allocatedCapacity() and use it instead of d->allocThiago Macieira2019-12-071-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In almost all cases, use d->allocatedCapacity() or d->constAllocatedCapacity() instead of d->alloc, since they do the same thing (right now). In the future, the functions will be changed. There is a separate const version because most const code should not need to know the allocation size -- only mutating code should need to know that There are a few cases where d->alloc was replaced with a better alternative, like d->size. The one case that remains in the code will be replaced by a different test when it's available. Change-Id: I48135469db4caf150f82df93fff42d2309b23719 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Replace QArrayData::capacityReserved with a full flags fieldThiago Macieira2019-12-071-9/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Instead of stealing one bit from the alloc field, let's use a full 32-bit for the flags. The first flag to be in the field is the CapacityReserved (even though the allocate() function will store some others there, not relevant for now). This is done in preparation for the need for more flags necessary anyway. Change-Id: I4c997d14743495e0d4558a6fb0a6042eb3d4975d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Remove redundant overloads in QStringFrederik Gladhorn2019-11-131-6/+5
|/ | | | | | | | These were added since we couldn't add default parameters in the Qt 5 lifetime. Change-Id: Idf04df78cc7f56c6c1dc1fe6c07e30003350ed0d Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Vitaly Fanaskov <vitaly.fanaskov@qt.io>
* Make sure QLatin1Literal fwd header is generatedKevin Funk2019-09-021-1/+2
| | | | | | | | | | | | | | | | | | | | This broke when QLatin1Literal got deprecated in change 45373c19243aea335897ba0f371a1dd53ae8f079 Both hunks in this patch are needed. The hunk in syncqt.pl removes the QT_DEPRECATED_X(...) macro if it appears solely on a line in source code, the second hunk inserts a newline after the QT_DEPRECATED_X(...) macro usage to trigger that code path in the Perl script. Before/after comparison of the headers generated in include/QtCore: ``` % diff ~/old.txt ~/new.txt 105a106 > QLatin1Literal ``` Change-Id: I468dd2dd54bf115521ed82c6182236905556f568 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Android: Update clang mkspecsBogDan Vatra2019-08-221-9/+0
| | | | | | | | | | | Follow Google's BuildSystemMaintainers doc to simplify (a lot) the clang support It is needed to support future NDK releases painlessly. Also remove old workarounds. [ChangeLog][Android] Android depends on NDK r20+ Change-Id: Ib4c07fc71e0f5a264d804b0b3baa18ff79d07630 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* qstringalgorithms.h: add pure, noexcept, constexprMarc Mutz2019-07-291-1/+1
| | | | | | | ... where they were missing. Change-Id: I58c32e57675b5d5ee500722933ef4a356a679e46 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QStringView: two fixes for newly-added toWCharArray()Marc Mutz2019-07-291-1/+13
| | | | | | | | | | | | | | | | | | | | Amends e89fbd8c3aa50a24e5fc02ab710ccca67fce98e2. - While QString::data() never returns nullptr, QStringView::data() may, which makes calling QStringView{}.toWCharArray() UB on Windows (since memcpy's 2nd argument must never be nullptr, even if the size is zero). Fix by protecting the memcpy call. - QStringView, by design, does not use out-of-line member functions, because calling these forces the QStringView object onto the stack. Fix by making inline. Also use the more efficient qToStringViewIgnoringNull(), as the result does not depend on QString::isNull() (no characters are written either way), and add a missing article to the function's docs. Change-Id: I5d6b31361522812b0db8303b93c43d4b9ed11933 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Extend QString::arg(QString, ..., QString) to more than 9 argumentsMarc Mutz2019-07-241-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | Now that we have QStringView::arg(), we can use it to implement a similarly flexible QString::arg(). It's not as straight-forward as in QStringView, though: QString has existing arg() overloads that all become worse matches with the introduction of the new, perfectly-forwarding overload. So in order to allow calling of the other arg() functions, first constrain the new arg() function to arguments that are convertible to QString, QStringView, or QLatin1String, and then delegate to the QStringView version. To stay compatible with the previous overloads, which accepted anything that implicitly converts to QString (in particular, QStringBuilder expressions), add a new overload of qStringLikeToView, taking const QString &. This benefits the existing QStringView and QLatin1View versions, too. [ChangeLog][QtCore][QString] QString::arg(QString, ..., QString) can now be called with more than nine arguments, as well as with QStringViews. Change-Id: I1e717a1bc696346808bcae45dc47762a492c8714 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Move text-related code out of corelib/tools/ to corelib/text/Edward Welbourne2019-07-101-0/+2043
This includes byte array, string, char, unicode, locale, collation and regular expressions. Change-Id: I8b125fa52c8c513eb57a0f1298b91910e5a0d786 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>