summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qstring.h
Commit message (Collapse)AuthorAgeFilesLines
* QLatin1String/QStringView: add (missing) member compare()Marc Mutz2020-03-051-0/+11
| | | | | | | | | | | [ChangeLog][QtCore][QLatin1String] Added compare(). [ChangeLog][QtCore][QStringView] Added compare() overloads taking QLatin1String, QChar. Change-Id: Ie2aa400299cb63495e65ce29b2a32133066de826 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QString/QByteArray: make all symmetry-checked member-compare() combinations ↵Marc Mutz2020-03-051-0/+4
| | | | | | | | | | | | | | | | | | | noexcept In QByteArray, they were just not marked as such. In QString and QStringRef, the implicit conversion from QChar to QString would destroy it. Add a QChar overload, delegating to QStringView. Added docs for the new overloads, copying from the nearest neighbor so as to not look out of place. All string classes use different wording for these functions. A cleanup of this state of affairs is out of the scope of this patch. Change-Id: I0b7b1d037aa229bcaf29b793841a18caf977d66b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Deprecate QString::SplitBehavior in favor of Qt::SplitBehaviorEdward Welbourne2020-02-281-33/+66
| | | | | | | | | This requires changing which of the two families of methods gets to take a default argument for its behavior. Task-number: QTBUG-81853 Change-Id: I6759bedd9af364d6e12bb39cd539b5dcba37027e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* De-inline Qt::SplitBehavior splitters of QString and QStringRefEdward Welbourne2020-02-281-21/+17
| | | | | | | | | | | Convert the QString::SplitBehavior variants to call them, rather than the other way round and convert the internal infrastructure to use Qt::SplitBehavior, ready to deprecate the QString::SplitBehavior versions without generating intenal warnings. Task-number: QTBUG-81853 Change-Id: Ia6b78881c3d0e30a7bbd4dfd00cc15a407f448a2 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Liang Qi2020-02-181-1/+1
|\ | | | | | | | | | | | | | | | | Conflicts: src/corelib/tools/qlinkedlist.h src/plugins/platforms/wasm/qwasmintegration.cpp src/plugins/platforms/wasm/qwasmscreen.cpp Change-Id: Iefca7f9f4966bdc20e7052aca736874861055738
| * QStringView: Fix warning about conversion from qsizetype to intThiago Macieira2020-02-131-1/+1
| | | | | | | | | | | | Fixes: QTBUG-81764 Change-Id: If79a52e476594446baccfffd15eecb9d9e578118 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | Introduce QString(View)::isValidUtf16Giuseppe D'Angelo2019-12-201-0/+2
|/ | | | | | | | | | | | | | | | | | | QString(View)s can be built or manipulated in ways that make them contain/refer to improperly encoded UTF-16 data. Problem is, we don't have public APIs to check whether a string contains valid UTF-16. This knowledge is precious if the string is to be fed in algorithms, regular expressions, etc. that expect validated input (e.g. QRegularExpression can be faster if it can assume valid UTF-16, otherwise it has to employ extra checks). Add a function that does the validation. [ChangeLog][QtCore][QStringView] Added QStringView::isValidUtf16. [ChangeLog][QtCore][QString] Added QString::isValidUtf16. Change-Id: Idd699183f6ec08013046c76c6a5a7c524b6c6fbc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* 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>
* 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>