summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qbytearray.h
Commit message (Collapse)AuthorAgeFilesLines
* Move text-related code out of corelib/tools/ to corelib/text/Edward Welbourne2019-07-101-754/+0
| | | | | | | | This includes byte array, string, char, unicode, locale, collation and regular expressions. Change-Id: I8b125fa52c8c513eb57a0f1298b91910e5a0d786 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QCharRef/QByteRef: schedule for Qt 7 removalGiuseppe D'Angelo2019-07-011-1/+1
| | | | | | | | With all of their special behavior deprecated, QCharRef and QByteRef can simply be removed. Add a comment. Change-Id: I8bad95424207ae281b5edf348b9ad81c6807dc12 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* QString/QByteArray: detach immediately in operator[]Giuseppe D'Angelo2019-05-191-7/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unlike any other implicitly shared container, QString/QByteArray have a "lazy detach" mechanism: their operator[] returns a special object; assignment into that object will actually detach. In other words: QString a("Hello"); QCharRef c = a[0]; // does not detach c = 'J'; // detach happens here This allows this behavior: QString a("Hello"); QCharRef c = a[0]; QString b = a; c = 'J'; // detach happens here assert(a == "Jello"); assert(b == "Hello"); Note that this happens only with operator[] -- the mutating iterator APIs instead detach immediately, making the above code have visible side effects in b (at the end, b == "Jello"). The reasons for this special behavior seems to have been lost in the dawn of time: this is something present all the way back since Qt 2, maybe even Qt 1. Holding on to a "reference" while taking copies of a container is documented [1] to be a bad idea, so we shouldn't double check that the users don't do it. This patch: 1) adds an immediate detach in operator[], just like all other containers; 2) adds a warning in debug builds in case QByteRef/QCharRef is going to cause a detach; 3) marks operator[] as [[nodiscard]] to warn users not using Clazy about the (unintended) detach now happening in their code. This paves the way for removal of QCharRef/QByteRef, likely in Qt 7. [1] https://doc.qt.io/qt-5/containers.html#implicit-sharing-iterator-problem [ChangeLog][QtCore][QString] QString::operator[] detaches immediately. Previously, the detach was delayed until a modification was made to the string through the returned QCharRef. [ChangeLog][QtCore][QByteArray] QByteArray::operator[] detaches immediately. Previously, the detach was delayed until a modification was made to the byte array through the returned QByteRef. Change-Id: I9f77ae36759d80dc3202426a798f5b1e5fb2c2c5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCharRef/QByteRef: warn when triggering the resizing operator= behaviorGiuseppe D'Angelo2019-05-191-5/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The whole reason of QCharRef/QByteRef existence is to have a magic operator=. This operator= delays the actual detach up to the moment something is written into the Ref, thus avoiding spurious detaches to the underlying string/byte array. operator= has also an extra feature, it allows this code to succeed: QString s("abc"); s[10] = 'z'; assert(s == "abc z"); This last behavior is *extremely* surprising. The problem with all of this is that this extra convenience is outweighted by the massive pessimization in the codegen for operator[]; by the maintenance burden (QChar APIs need to be mirrored in QCharRef, etc.), and, for the automatic resize, by the fact that it's an super-niche use case. Cherry on top, std::basic_string does not do that, and no Qt or std container does that. In other words: any other container-like class exhibits UB for out of bounds access. We can't just go and change behavior, though. This is something coming all the way back from Qt 2 (maybe even Qt 1), which means we can't deprecate it at short notice. This patch simply adds a warning in debug builds in case the special resizing behavior is triggered. While at it, removes some code duplication in QByteRef. [ChangeLog][QtCore][QString] The behavior of operator[] to allow implicit resizing of the string has been deprecated, and will be removed in a future version of Qt. [ChangeLog][QtCore][QByteArray] The behavior of operator[] to allow implicit detaching and resizing of the byte array has been deprecated, and will be removed in a future version of Qt. Change-Id: I3b5c5191167f12a606bcf6e513e6f304b220d675 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Qt 6: unexport QCharRef / QByteRefGiuseppe D'Angelo2019-05-181-1/+5
| | | | | | | They're fully inlined classes. Change-Id: Id9e5f1a1a0b3d8ee49ba45ad2157ffa38fe265cd Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Remove handling of missing Q_COMPILER_RVALUE_REFSAllan Sandfeld Jensen2019-04-081-2/+0
| | | | | Change-Id: I7bc6c455fbae4cdad584c76773299a6d8cd40c82 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace Q_DECL_NOEXCEPT with noexcept in corelibAllan Sandfeld Jensen2019-04-031-26/+26
| | | | | | | In preparation of Qt6 move away from pre-C++11 macros. Change-Id: I44126693c20c18eca5620caab4f7e746218e0ce3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QByteArray: add compare() with case sensitivity optionsThiago Macieira2018-06-221-0/+14
| | | | | | | | | | | | | Need to do the same for startsWith() and endsWith(). indexOf() is a lot harder. [ChangeLog][QtCore][QByteArray] Added compare(), which takes Qt::CaseSensitivity as one of the parameters. This function is more efficient than using toLower() or toUpper() and then comparing. Change-Id: Ib48364abee9f464c96c6fffd152e69bde4194df7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QByteArray: Add functions isUpper() and isLower() for Latin1 byte arraysAndre Hartmann2018-02-171-0/+3
| | | | | | | | | [ChangeLog][QtCore][QByteArray] Added QByteArray::isUpper() and QByteArray::isLower() to check if a byte array contains only uppercase or only lowercase Latin1 letters. Change-Id: I7ab3c775bc714138d4be259ac6fa2cfc70467ed4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.10' into devLiang Qi2017-10-171-8/+8
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/network/fortuneclient/client.cpp examples/network/fortuneserver/server.cpp src/platformsupport/platformcompositor/qopenglcompositorbackingstore_p.h src/plugins/platforms/cocoa/qcocoabackingstore.h src/plugins/platforms/cocoa/qcocoaintegration.h src/plugins/platforms/cocoa/qcocoascreen.h src/plugins/platforms/ios/qiosbackingstore.h src/plugins/sqldrivers/oci/qsql_oci.cpp src/widgets/kernel/qwidgetwindow.cpp Change-Id: Ia6dd2c52d4a691b671cf9a2ffca70deccece8f10
| * Remove Q_ALWAYS_INLINE from frequently-used functionsThiago Macieira2017-09-291-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | MSVC is too stupid for them. Not only will it not inline those functions if they are in a __declspec(dllimport) class, it will also print an annoying Level 4 warning: function 'function' marked as __forceinline not inlined Task-number: QTBUG-57811 Task-number: QTBUG-55042 Change-Id: I0b48fc8e90304e0dacc3fffd14e8a346d18a9e0c Reviewed-by: Kai Koehne <kai.koehne@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Replace Q_NULLPTR with nullptr where possibleKevin Funk2017-09-191-10/+10
|/ | | | | | | | | | | | | Remaining uses of Q_NULLPTR are in: src/corelib/global/qcompilerdetection.h (definition and documentation of Q_NULLPTR) tests/manual/qcursor/qcursorhighdpi/main.cpp (a test executable compilable both under Qt4 and Qt5) Change-Id: If6b074d91486e9b784138f4514f5c6d072acda9a Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Merge "Merge remote-tracking branch 'origin/5.9' into dev" into refs/staging/devLiang Qi2017-06-201-1/+1
|\
| * Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-06-191-1/+1
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qprocess_unix.cpp src/corelib/io/qprocess_win.cpp src/plugins/platforms/android/qandroidplatformintegration.h src/plugins/platforms/windows/qwindowscontext.cpp src/plugins/platforms/windows/windows.pri src/tools/uic/cpp/cppwriteinitialization.cpp src/widgets/doc/src/widgets-and-layouts/gallery.qdoc Change-Id: I8d0834c77f350ea7540140c2c7f372814afc2d0f
| | * Use the C++ [[nodiscard]] attributeThiago Macieira2017-06-071-1/+1
| | | | | | | | | | | | | | | | | | Change-Id: I7814054a102a407d876ffffd14b6a285c70b21de Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Move Q_REQUIRED_RESULT to its correct positionThiago Macieira2017-06-201-4/+4
|/ / | | | | | | | | | | | | | | This commit complements commit 3dcc075f4a5efce348a6fa00cf5a0adef97b1089 for Qt 5.10. Change-Id: I7814054a102a407d876ffffd14b6a16182f159e2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Disentangle string-related headersMarc Mutz2017-04-251-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's starting to hinder QStringView development (QString::append(QStringView), e.g.). - qbytearray.h includes qstring.h, but is included by qstring.h -> remove qstring.h include from qbytearray.h - the QStringLiteral definition is used from both qstring.h and qstringview.h -> extract into its own header, move QStringViewLiteral definition there, too - the qCompareStrings(), qConvertTo*() functions are used by QString and QStringView -> also extract into own header, included from qstring.h and qstringview.h - QStringView::toString() depends on QString, which depends on QStringView -> move QStringView::toString() definition to qstring.h, after the definition of QString -> move qstringview.h up to all the other includes in qstring.h This is starting to look like a DAG again, and allows to remove the unholy #ifndef QSTRING_H # include <qstring.h> #endif hack from qstringview.h. [ChangeLog][Potentially Source-Incompatible Changes][QByteArray] qbytearray.h no longer includes qstring.h. In particular, this means that in order to use QStringBuilder with QByteArray, you need to include both qbytearray.h and qstring.h now (or <QByteArray> and <QString>, resp.). Change-Id: I7f8acf9c11bc1731266cd25c6eda9fb36723f364 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-04-201-30/+30
|\| | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/tools/qbytearray.h src/corelib/tools/qdatetime.h src/corelib/tools/qstring.h src/corelib/tools/qversionnumber.h src/plugins/platforms/android/qandroidplatformintegration.cpp tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp Change-Id: Iefd92a435e687a76cd593099e40d9a9620a1454d
| * Move Q_REQUIRED_RESULT to its correct positionThiago Macieira2017-04-201-28/+28
| | | | | | | | | | | | | | | | | | | | | | That's before the return type or static, inline, constexpr or such keywords (if any). Perl Script: s/^(\s+)(.*) Q_REQUIRED_RESULT(;)?(\s*\/\/.*)?$/\1Q_REQUIRED_RESULT \2\3\4/ Change-Id: I7814054a102a407d876ffffd14b6a16182f159e2 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
| * Don't disable Q_REQUIRED_RESULT with Clang and ICCThiago Macieira2017-04-201-1/+1
| | | | | | | | | | | | | | They're not affected by the GCC bug noted in the comment. Change-Id: I7814054a102a407d876ffffd14b69e8a8e2527f1 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | QByteArray, QString, QStringRef: Add chopped()Marc Mutz2017-04-181-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have two functions to get a substring without doing some calculations involving size(): - mid(p): mid(p, size() - p) - right(n) : mid(size() - n, n) (left does not involve size(), so isn't in that set). What was missing was a name for - f(n): mid(0, size() - n) As an action, it's called chop(), so call the transformation version chopped(). I made chopped(n), n < 0 or n > size(), undefined, because QString(Ref) ::left() is broken[1], while the QByteArray implementation is not. This is the only way to get consistent behavior among the three classes. I's also the correct thing to do. [1] instead of returning the empty string for negative indexes, it returns the whole string. [ChangeLog][QtCore][QString/QStringRef/QByteArray] Added chopped(n), a const version of chop(n). Change-Id: I6c2c5b16e0060fa924ced5860f21f2d0f23bd023 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
* | Array-backed containers: add shrink_to_fit for STL compatibilityGiuseppe D'Angelo2017-04-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Side note: QHash has squeeze(), but there's no shrink_to_fit on std::unordered_map. [ChangeLog][QtCore][QByteArray] Added shrink_to_fit(). [ChangeLog][QtCore][QString] Added shrink_to_fit(). [ChangeLog][QtCore][QVarLengthArray] Added shrink_to_fit(). [ChangeLog][QtCore][QVector] Added shrink_to_fit(). Change-Id: Ifd7d28c9bed70727be6308f0191a188201784f61 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | QByteArray: add missing inline keywordsMarc Mutz2017-04-111-38/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Inline member functions that are not defined in the class body must be marked with the inline keyword. Otherwise, MinGW complains about any use of such functions before they are defined with its infamous error message: 'char QByteArray::at(int) const' redeclared without dllimport attribute after being referenced with dll linkage Fix it for all such functions. Change-Id: Iae76a7ed18e7b2d5cb5e217e154f647be4a2d9c1 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Add front()/back() to QString, QStringRef, QByteArray and QLatin1StringMarc Mutz2017-04-071-0/+6
|/ | | | | | | | | | | These STL-compatibility functions are present on our generic containers, but not on the string classes. [ChangeLog][QtCore][QString/QStringRef/QByteArray/QLatin1String] Added front() and back() for STL compatibility. Change-Id: I536019396b319abd1e2daf9c64ebab4e7a35b334 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Clean up QByteArrayLiteral definitionMarc Mutz2017-02-241-10/+0
| | | | | | | | Remove the dead QByteArray(data, size) fall-back. We've been requiring lambdas since Qt 5.7. Change-Id: I4d9023ab4583f2ee80a74a828fba0d95c2fdb0df Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Extend qChecksum calculationLars Schmertmann2016-12-251-2/+2
| | | | | | | | | | | | | | ISO 14443-3 is for nfc communication and uses 2 different checksums. The existing one is from ISO 3309 and the other one is from ITU-V.41. Both are needed to implement an own transport layer defined in ISO 14443-4 to allow nfc commands with a length above 250 byte independent from the smartphone. This change will avoid code duplication in QNearFieldTarget. The private function qNfcChecksum is a copy of qChecksum. Change-Id: I790ffec8e2ea46f88b2db6f48b64fdcb140e7b70 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QByteArray: Overload toHex() with separator characterAndre Hartmann2016-12-241-0/+1
| | | | | | | | | | | | | The separator character is inserted in the resulting array after every byte and is useful for MAC address output like 01:23:45:ab:cd:ef, Hash fingerprints, or low level data debug output. [ChangeLog][QtCore][QByteArray] Added toHex() overload to insert a separator character between the hex bytes. Change-Id: Ibe436094badc02f3ade7751aa8b5d690599941d4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* qdoc: Ignore Q_COMPILER_REF_QUALIFIERS for nowMartin Smith2016-12-041-1/+1
| | | | | | | | | | | | | | | | | Q_COMPILER_REF_QUALIFIERS is not yet supported on all platforms, so clangqdoc must ignore functions that are defined only when it is defined. This change adds && !defined(Q_CLANG_QDOC) to some #if defined(Q_COMPILER_REF_QUALIFIERS) tests to allow clangqdoc to use old declarations. Note that Q_CLANG_QDOC should also be used instead of Q_QDOC from now on, so that we know that uses of Q_QDOC have been examined to see if they are still required for clangqdoc. Change-Id: I910be70df63eca09985728c7b9eba473aed141ba Reviewed-by: Martin Smith <martin.smith@qt.io>
* Properly forward-declare the Apple types with Q_QDOCOlivier Goffart2016-05-311-2/+2
| | | | | | | | | They are needed for the header to be parsed properly with clang based qdoc. While we are at it, change the condition from Q_OS_MAC to Q_OS_DARWIN Change-Id: I2a2f9c1159f47795d9811023d67c86fec1866846 Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* Merge "Merge remote-tracking branch 'origin/5.7' into dev" into refs/staging/devFriedemann Kleint2016-05-031-18/+18
|\
| * Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-05-031-18/+18
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: configure src/3rdparty/double-conversion/include/double-conversion/utils.h src/corelib/global/qnamespace.qdoc src/corelib/tools/qsimd_p.h tests/auto/corelib/io/qfile/tst_qfile.cpp Change-Id: I3ca1007bab5355d251c13002a18e93d81c254d34
| | * Mark some QByteArray relational operators nothrowMarc Mutz2016-04-131-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically, those that compare UTF-8 octet-streams: - QByteArray <-> QByteArray - QByteArray <-> const char* For more, Qt first needs to gain a nothrow UTF-8 <-> UTF-16 comparator. Change-Id: Ibccbdcdc3ebed5b1ac0e65c971f6f7d1bd15b6da Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | darwin: Simplify conversion function declarations in headersTor Arne Vestbø2016-05-031-5/+1
|/ / | | | | | | | | | | | | | | | | | | | | We don't need to include Q_QDOC in the forward-declarations of the native types, and Q_FORWARD_DECLARE_OBJC_CLASS works in non-Objective-C mode as well, which means we can declare the Objective-C versions of the functions without guards. Change-Id: I32089c496b4f7ce47f0388ba3f65e0b091d1e9ee Reviewed-by: Martin Smith <martin.smith@theqtcompany.com> Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* | Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-04-051-1/+1
|\| | | | | | | | | | | | | | | | | Conflicts: examples/corelib/ipc/ipc.pro src/plugins/platforms/xcb/qxcbbackingstore.cpp tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp Change-Id: Ia006e10ff1732fe78f90138c41f05b59b49486cf
| * Merge remote-tracking branch 'origin/5.6' into 5.7Simon Hausmann2016-03-241-1/+1
| |\ | | | | | | | | | Change-Id: I13c7ea6a74eb98606cf45702ae068101943bec6a
| | * Hide mixed comparisons with QT_RESTRICTED_CAST_FROM_ASCIIhjk2016-03-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While the implementation of the QByteArray::operatorX(const QString &s2) for X \in { ==, !=, <, <=, >, >=} was already inavailable when QT_RESTRICTED_CAST_FROM_ASCII was defined, the declaration was still visible, leading effectively to a linking error. This change hides the declaration, too, creating a compiler error as intended, and as present with the QString::operatorX(const QByteArray &s2) functions. Change-Id: Ifdb0b85b7423b3b9c69212639b1512b0808a7983 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | | Forward declare the Objective C types for the documentation.Olivier Goffart2016-03-181-2/+2
|/ / | | | | | | | | | | | | Required for clang doc parsing. Change-Id: Ia00717377e9524efae1266d1a01b2ef0e064b11e Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
* | Add Intel copyright to files that Intel has had non-trivial contributionThiago Macieira2016-01-211-0/+1
| | | | | | | | | | | | | | | | | | I wrote a script to help find the files, but I reviewed the contributions manually to be sure I wasn't claiming copyright for search & replace, adding Q_DECL_NOTHROW or adding "We mean it" headers. Change-Id: I7a9e11d7b64a4cc78e24ffff142b506368fc8842 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | | | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Mark ref-qualified members as always inlineThiago Macieira2015-10-071-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | MSVC and ICC on Windows always make calls to the dllexport'ed out-of- line copy of an inline function when compiling in debug mode. This creates an incompatibility when a compiler that understands ref- qualified member functions (such as ICC) is used to compile code using a DLL that was compiled with a compiler that doesn't understand (such as MSVC 2013). Task-number: QTBUG-48349 Change-Id: I42e7ef1a481840699a8dffff14053b7998a2a6bb Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | QByteArray: Add append/prepend/insert overloadKevin Funk2015-08-271-0/+7
|/ | | | | | | | | | Use-case is fast insertion of copies of a character, avoiding any temporary heap allocations Change-Id: Ie5517d88429fbd4c58dbe5729de7c468d5d9a279 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Sérgio Martins <sergio.martins@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QByteArray: add {const_,reverse_iterator}, {c,}r{begin,end}()Marc Mutz2015-07-071-8/+17
| | | | | | | | | | | | Had to mark {,c,const}{begin,end}() inline, since they are, and mingw complains about inconsistent dllimport attributes. [ChangeLog][QtCore][QByteArray] Added rbegin(), crbegin(), rend(), crend(), and reverse_iterator and const_reverse_iterator typedefs. Task-number: QTBUG-25919 Change-Id: Id5aefb52635f029305135afcd99db0b036a7af82 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtCore: Use Q_NULLPTR instead of 0 in all public headersMarc Mutz2015-07-011-10/+10
| | | | | | | | | This is in preparation of adding -Wzero-as-null-pointer-constant (or similar) to the headers check. Task-number: QTBUG-45291 Change-Id: I0cc388ef9faf45cbcf425ad0dc77db3060c104a8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Unify QByteArray::MaxSize and MaxAllocSizeUlf Hermann2015-06-161-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | We have established the maximum size qAllocMore can deal with in commit 880986be2357a1f80827d038d770dc2f80300201 and we should use it. The maximum size for byte arrays is reduced by one byte as with the previous code we could make qAllocMore produce ((1 << 31) - extra) by passing (1 << 30). That is not a problem for qAllocMore itself (as long as extra > 0) but it's hard to verify that no related code casts the total sum back to signed int, which would overflow to -1. To make the compiler inline access to the maximum size, a private enum MaxByteArraySize is provided, which can be used in internal code. This fixes the merge of commits 880986be2357a1f80827d038d770dc2f80300201 and c70658d301e274c3aaa1fb6cebe2a5e56db12779 Change-Id: Idb04856f7c2e53ef383063e7555d3083020ff2b7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove support for some very old compilersAllan Sandfeld Jensen2015-02-151-11/+0
| | | | | | | Remove code supporting gcc 4.0 and earlier, and MSVC 2005 and earlier. Change-Id: I3304e11bb38c101f113c124e8e533c5578badf34 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* QtCore: add some more Q_DECL_NOTHROWMarc Mutz2015-01-211-5/+5
| | | | | | | | | | | QtCore now builds with no -Wnoexcept warnings (that doesn't mean there aren't tons of functions that should be marked noexcept, just that all conditionally noexcept functions aren't noexcept(false) just because of a forgotten noexcept elsewhere). Change-Id: I10dacb6b9c9d41d3595fe2f306356d62d3d91c76 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtCore: mark some operations nothrowMarc Mutz2015-01-101-3/+4
| | | | | | | | | | | | This shotgun-surgery approach is motivated by trying to get a clean(er) build for -Wnoexcept on GCC, so it is expected that for any class touched here, there will be more operations that can be marked nothrow. But they don't show up in conditional noexcept clauses, yet, so they are deferred to some later commit. Change-Id: I0eb10d75a26c361fb22cf785399e83b434bdf233 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.4' into devFrederik Gladhorn2014-12-291-0/+3
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/tools/qbytearray.cpp src/gui/kernel/qplatformsystemtrayicon.cpp src/gui/kernel/qplatformsystemtrayicon.h src/plugins/platforms/xcb/xcb-plugin.pro Change-Id: I00355d3908b678af8a61c38f9e814a63df808c79
| * Make sure we don't try to ask QByteArray to allocate too muchThiago Macieira2014-12-201-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | QFile::readAll could be asked to read a file that is over 1 GB in size and thus cause an assertion: ASSERT failure in qAllocMore: "Requested size is too large!", ... The idea behind the existing code was correct, but the value was wrong. It prevented overflow of the integer size request, but didn't prevent overflowing the storage size. Change-Id: I072e6e419f47b639454f3fd96deb0f88d03e960c Reviewed-by: Martin Smith <martin.smith@digia.com>