summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstring.h
Commit message (Collapse)AuthorAgeFilesLines
* Fix QString::operator=(QLatin1String) for substringsKent Hansen2012-02-021-1/+1
| | | | | | | | | QLatin1String now has a constructor that takes explicit length, which makes it possible to create a QLatin1String that isn't null-terminated. Made QString::operator=(QLatin1String) work in that case. Change-Id: Ie77eabd2f8f036531d67cd8051a7b6305b386ccf Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Fix QString(QLatin1String) constructor for substringsKent Hansen2012-02-021-1/+1
| | | | | | | | | QLatin1String now has a constructor that takes explicit length, which makes it possible to create a QLatin1String that isn't null-terminated. Made the QString(QLatin1String) constructor work in that case. Change-Id: I4f4f07a956144b7ea4aa9c58a61c755fb99ef1b3 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Fix operator==(QLatin1String, QLatin1String) and friends for substringsKent Hansen2012-02-021-6/+10
| | | | | | | | | QLatin1String now has a constructor that takes explicit length, which makes it possible to create a QLatin1String that isn't null-terminated. Made the QLatin1String comparison operators work in that case. Change-Id: I234ba851e67a6f5cfbb46fb6f0b22623ce40be28 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Fix compilation of Qt apps with -Wshadow -WerrorDavid Faure2012-01-301-1/+1
| | | | | | | qstring.h:648:70: error: declaration of ‘size’ shadows a member of 'this' Change-Id: I96d2a5b1201b53b11d23bf194b89fa8967b9e25d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Remove use of QT_MODULE from libraryGunnar Sletta2012-01-251-1/+0
| | | | | | | | | | These defines were there to aid in the commercial licensing scheme we used long ago, and are no longer needed. Keep a QT_MODULE(x) define so other modules continue compiling. Change-Id: I8fd76cd5270df8f14aee746b6cf32ebf7c23fec7 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Remove QBool and use bool instead.David Faure2012-01-201-23/+23
| | | | | | | | | | | | QBool was introduced with Qt-4.0, to detect Qt3-like code like if (c.contains(d) == 2) and break compilation on such constructs. This isn't necessary anymore, given that such code couldn't possibly compile in Qt4 times. And QBool was confusing developers, and creating compile errors (e.g. QVariant doesn't have support for it), so better remove it for Qt 5. Change-Id: I6642f43f5e12b872f98abb56600186179f072b09 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Add a constructor that explicitly takes a size to QLatin1StringLars Knoll2012-01-181-0/+1
| | | | | | | | | | This is useful in a couple of situations where the size is known at runtime and one wants to avoid a call to strlen. Change-Id: Ic20587b0d365a4573d4636c5853c206b571b8d6b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Remove QT_NO_STL_WCHAR hackHarald Fernengel2011-12-221-18/+3
| | | | | | | We don't support gcc 2.95 any more. Change-Id: I842f1f8ac64b9006516c104add0991830ac9a46a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use strlen() inline whenever possibleHarald Fernengel2011-12-221-33/+45
| | | | | | | This allows us to benefit from compile-time optimization Change-Id: I63dfde3758fcb0ff919fdc0418df1b7586da0b2f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* make QString::fromLatin1 partially inlineHarald Fernengel2011-12-201-1/+5
| | | | | | | | This allows us to benefit from compile time optimizations when calling strlen() Change-Id: If6694117e613a012fce97f8664e6b43005d255de Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix tst_Moc::oldStyleCastsOlivier Goffart2011-11-171-2/+2
| | | | | | | | | This tests that the moc generated file produces no warnings with very pedentic compilation flags. In that case, there was a warning because of the use of the C casts Change-Id: Ie79c6d053ff35c55276a07212c5d60f759f693ee Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* replace 'const QChar &' with 'QChar ' for QChar and QStringRitt Konstantin2011-10-261-25/+25
| | | | | | | | Merge-request: 69 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> Change-Id: I61f5a54b783252029fcad95677958fa6a2130d01 Reviewed-by: Olivier Goffart <ogoffart@kde.org>
* Add Q_DECL_CONSTEXPR to a QChar, QLatin1Char and QLatin1String constructorsThiago Macieira2011-10-221-2/+2
| | | | | | | | These types now technically are trivially-constructible and standard-layout in C++0x. Change-Id: I455bd905fd6e237a1dff517b86dcbe59d571266f Reviewed-by: Olivier Goffart <ogoffart@kde.org>
* make fromWCharArray() and toWCharArray() inlinedKonstantin Ritt2011-10-181-2/+17
| | | | | | | | | because we may have the size of wchar_t varying, we need to know which is the correct encoding: UTF-16 or UCS-4 Merge-request: 49 Change-Id: Ib5a1e7dea51d0cd8394e686634a36aae984fa072 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* Rename Qt::escape to QString::toHtmlEscaped, add compat methodDavid Faure2011-09-291-1/+6
| | | | | | | | | Merge-request: 56 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com> Change-Id: I46bbb2df10968e88b5eb5ef8dae182a651b622b8 Reviewed-on: http://codereview.qt-project.org/5793 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
* Move Qt::escape to QtCoreDavid Faure2011-09-291-0/+3
| | | | | | | | | | Merge-request: 56 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com> Change-Id: I25c5f46cf53a653db26dbeb92865e61f69980bfd Reviewed-on: http://codereview.qt-project.org/5792 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com> Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
* Fix QString and QByteArray reserve() and squeeze()Bradley T. Hughes2011-09-231-2/+24
| | | | | | | | | | | | | | | | | These functions should not take care not to unconditionally set the capacityReserved private member, since the d may be referencing the const shared_null or shared_empty which live in read-only memory. The squeeze() methods check for ref > 1 instead of ref != 1 to prevent detaching from the shared_null/shared_empty unnecessarily; the shared_null/shared_empty ref count is -1, meaning squeeze() will never detach from it. Change-Id: Id3f1725a6f08b3a462343640a47bbe78f08ca7e7 Rubberstamped-by: Lars Knoll Reviewed-on: http://codereview.qt-project.org/5454 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Fix QString/QByteArray literals for MSVC2010 (compilation of tests).Friedemann Kleint2011-08-021-8/+15
| | | | | | | | | | - Specify return type of QByteArrayLiteral/QStringLiteral lambdas. - Define QT_UNICODE_LITERAL instead of QT_UNICODE_MARKER. Change-Id: I8a53506887d2736b093798220b088f645f05e415 Reviewed-on: http://codereview.qt.nokia.com/2514 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
* Make the N parameter to the QXXXLiterals be the actual string lengthThiago Macieira2011-07-211-10/+10
| | | | | | | | | | | | Before, it was the length + 1, to include the ending NUL or U+0000. This avoids mistakes of -1 in QStringBuilder and will allow us simpler code in the User-Defined Literal (future improvement) Change-Id: I75c47d6c44579124888f925e240817229347dc70 Merge-request: 31 Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com> Reviewed-on: http://codereview.qt.nokia.com/1966 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
* Fix more use of C style cast.Olivier Goffart2011-07-211-3/+3
| | | | | | | | | | | Commit 77ed8787ac9ef0f74c2ab6699af3fec434e433e5 was not enough Fix the test tst_Moc::oldStyleCasts() Change-Id: Ia2f98f4e02ba512c3f7fd7cd09b692a1aabd8de0 Reviewed-on: http://codereview.qt.nokia.com/1927 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* Fix use of C style cast.Olivier Goffart2011-07-191-1/+1
| | | | | | | | | | | | | Fix the test tst_Moc::oldStyleCasts() (The test make sure moc do not generate old C cast, by compiling the generated code and testing for gcc warning. But if it is present in the public header, the warning will be shown) Change-Id: I2fd3d01e7d78639d97bea021c200afbe2caae85f Reviewed-on: http://codereview.qt.nokia.com/1772 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* Fix compilation on MSVCLars Knoll2011-07-131-4/+4
| | | | | | | | | | | MSVC apparently doesn't like the way the QString::Data pointers got initialized. Also fixed a few warnings about signed/unsigned conversions. Change-Id: I1267979af7601129e5483f8785d4982a1f2f8182 Reviewed-on: http://codereview.qt.nokia.com/1558 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
* remove unneeded cast operator on QConstStringDataLars Knoll2011-07-121-3/+0
| | | | | | | Change-Id: Ib5f090cd6c716e1d936894be206b78629e70137b Reviewed-on: http://codereview.qt.nokia.com/1487 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com>
* Remove Qt 4.3 binary compatibility for MSVCThiago Macieira2011-07-111-6/+0
| | | | | | | | | | | | | | | When we removed the useless "const" in the return type, we broke compatibility with a few compilers that include the return type in the mangling. We don't need that anymore in Qt 5. This change should have had a ### Qt5 mark everywhere, not just in a comment in qstring.cpp. Change-Id: I8839f8dc540b34e57a3efdb160a1c015f7328422 Merge-request: 13 Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com> Reviewed-on: http://codereview.qt.nokia.com/1385 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
* Use lambdas for generating static data for QStringLiteralThiago Macieira2011-07-111-26/+33
| | | | | | | | | | | This means it will work on C++0x compilers that support lambdas (all of them once they've completed supporting the functionality). Olivier had the idea and the initial code. Change-Id: I11ef7da4058ed18f4ea99ada070891a68ed54f55 Reviewed-on: http://codereview.qt.nokia.com/1380 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com>
* Remove the qs() macro.Olivier Goffart2011-07-081-4/+0
| | | | | | | | | | | There is tootoo many risks of conflicts with existing code. QStringLiteral is not that hard to type. And if users want to use qs they can still define it in their own headers. Change-Id: I7da4772d902033fa163f5177c012b5d0e87332d7 Reviewed-on: http://codereview.qt.nokia.com/1357 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Make the new QStringLiteral produce a non-temporaryThiago Macieira2011-07-081-10/+33
| | | | | | | | | | | | | | | | | This is currently GCC-only code (the __extension ({ }) stuff), but it was the only way I found to create a static variable and return it. I had to add the QConstStringDataPtr container because I had to return a pointer to the data -- it's impossible to return a reference through this extension. I could have returned a naked pointer directly too. This isn't complete. GCC 4.6 is placing the string in the .data section, not .rodata as we wanted. Investigating further. Change-Id: I170030dca3eddbd69f6c879e952f652f7fe5d958 Reviewed-on: http://codereview.qt.nokia.com/1350 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Unify QLatin1String and QLatin1LiteralLars Knoll2011-07-071-5/+8
| | | | | | | | | | | | | Unify the two classes and get rid of one TODO item for Qt 5. Using strlen in the constructor of QLatin1String works, as the compiler can do the calculation at compile time. Change-Id: I59d98c71a34b86d4211fa0d8cfd40b7d612c5a78 Reviewed-on: http://codereview.qt.nokia.com/1219 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com>
* Support for compile time generated QStringsLars Knoll2011-07-071-42/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | use with QString string(QStringLiteral("foo")) or QString string(qs("foo")). qs(...) can in almost all places replace QLatin1String. the Macro qs requires c++0x support or a compiler where sizeof(wchar_t) == 2. In case these conditions are not met, qs simply falls back to QLatin1String. The commit also cleans up the QStringData structure significantly, now using only 16 bytes for the header on 32 bit systems. The bitflags to store unicode directionality of the string and whether the string would require complex text processing to render are removed. They don't really belong here and the result can be calculated very fast in any case. Added an internal QRefCount class the encapsulates the reference counting semantics required where a negative refcount is never changed. This is required to be able to put the string data into a constant POD object. Change-Id: I5b1395213deca48b2d582a036a0e8a8358d26d14 Reviewed-on: http://codereview.qt.nokia.com/1218 Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Remove Qt3 support functionality from parts of QtCoreLars Knoll2011-06-291-129/+2
| | | | | | | Change-Id: I90f391e9bfc412087bd0401e28d2497571f81aa1 Reviewed-on: http://codereview.qt.nokia.com/825 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Liang Qi <liang.qi@nokia.com>
* Update licenseheader text in source files for qtbase Qt moduleJyri Tahtela2011-05-241-17/+17
| | | | | | | Updated version of LGPL and FDL licenseheaders. Apply release phase licenseheaders for all source files. Reviewed-by: Trust Me
* QT_USE_QSTRINGBUILDER to fix source compatibilityOlivier Goffart2011-05-181-5/+3
| | | | | | | | | | | | In 4.8 we added support for using StringBuilder with QByteArray. But this is breaking source compatibility for people that used QT_USE_FAST_OPERATOR_PLUS in Qt 4.7. So we introduce a new macro Notice that QT_USE_FAST_CONCATENATION was not working without QT_USE_FAST_OPERATOR_PLUS, so we remove the checking of that macro. Reviewed-by: joao (cherry picked from commit 8447f5616be731d78081f326bb9cb3f5aa9087a4)
* Revert "Added QStringRef::toLatin1 and QStringRef::toUtf8"Thorbjørn Lindeijer2011-05-101-2/+0
| | | | | | | This reverts commit feabda665de62a0f6a82d831b45926697f30b45b. They were already added by Denis Dzyubenko in commit 2916b074. (cherry picked from commit ffe0a2ec7c1f4412792a977401bdc4dbf6c76acd)
* Fixes warningsOlivier Goffart2011-05-101-2/+2
| | | | | | | | | | | In QString, it would comlain that: assuming signed overflow does not occur when assuming that (X - c) > X is always false Changing to unsigned comparison fix the warning Others are about unused variables Reviewed-by: Thiago (cherry picked from commit 5e5485809e8c6f8339bb9f19ad71ed623a8b23c7)
* Added QStringRef::toLatin1 and QStringRef::toUtf8Thorbjørn Lindeijer2011-05-101-0/+2
| | | | | | | | | | | | | | | | | | | | | | | These helper functions make it convenient to avoid making an unnecessary copy of the string before converting it to a QByteArray. The current most obvious way to do this would be: // QStringRef text QByteArray latin1 = text.toString().toLatin1(); Though the copy can also be avoided by doing: const QString textData = QString::fromRawData(text.unicode(), text.size()); QByteArray latin1 = textData.toLatin1(); Now the faster method can be achieved using the new obvious way: QByteArray latin1 = text.toLatin1(); Reviewed-by: Thiago Macieira Reviewed-by: Robin Burchell (cherry picked from commit feabda665de62a0f6a82d831b45926697f30b45b)
* Initial import from the monolithic Qt.Qt by Nokia2011-04-271-0/+1295
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12