summaryrefslogtreecommitdiff
path: root/src/corelib/tools/qtools_p.h
Commit message (Collapse)AuthorAgeFilesLines
* QtMiscUtils: add isAsciiPrintable() helperAhmad Samir2023-03-181-0/+5
| | | | | | | | | | | | | | | | | | | | | | - isAsciiPrintable: borrowed the logic from isPrintable(uchar) in qdebug.cpp, now isPrintable(uchar) calls isAsciiPrintable - Replace ::isspace() with ascii_isspace() from qlocale_p.h Functions from ctype.h have a couple of issues: - they're locale-dependent, which isn't what's required here, the code is only interested in ASCII - their args should be representable as uchar or EOF otherwise it's undefined behavior An Early-Warning could use something like: grep -rP "\b(isalnum|isalpha|isblank|iscntrl|isdigit|islower|isgraph|\ "isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper)\b" Pick-to: 6.5 Task-number: QTBUG-111262 Change-Id: I1f47f41bd56735297078ff0d0ddc2ebf999abf8b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* q_core_unix: move timspec<->chrono helpers from qtools_p.hAhmad Samir2023-02-251-23/+0
| | | | | | | | | | Where it has a home with its other timespec/chrono siblings. Luckily I only needed to change one place in the code, and that source file already has #include's q_core_unix_p.h. Change-Id: I783383f958ceccfd6f9210f0b76d35b0f82b7cb5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtMiscUtils: add std::chrono::duration <-> timespec helpersAhmad Samir2023-02-201-0/+27
| | | | | | Change-Id: I91f36a3d651fd57443072fde4c3e8f811682328e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtMiscUtils: fix return type of two helpers, should be boolAhmad Samir2023-02-111-2/+2
| | | | | | | | Pointed out by Oswald Buddenhagen. Pick-to: 6.5 Change-Id: I3e38e0aee4555a1f37b8dbade38b6a0b3428f74c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtMiscUtils: add some more character helpersAhmad Samir2023-02-071-4/+36
| | | | | | | | | | | | | isHexDigit, isOctalDigit, isAsciiDigit, isAsciiLower, isAsciiUpper, isAsciiLetterOrNumber. This de-duplicates some code through out. Rename two local lambdas that were called "isAsciiLetterOrNumber" to not conflict with the method in QtMiscUtils. Change-Id: I5b631f95b9f109136d19515f7e20b8e2fbca3d43 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtMiscUtils: replace uint args with char32_tAhmad Samir2023-02-021-6/+6
| | | | | | | | | | | | | | Also change isAsciiDigit() to take a char32_t, so that something like this works: QChar ch; isAsciiDigit(ch.unicode()) casting char16_t to uchar is narrowing, and gives weird results. C.f. QSettingsPrivate::iniEscapedKey() and the QSettings unittests which uses some unicode characters. Task-number: QTBUG-110403 Change-Id: Id978a6b2874bc6869ae3ffb28d1887d932c37782 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtMiscUtils: add isAsciiDigit helperAhmad Samir2023-01-301-0/+5
| | | | | | | This logic is used in various places in qtbase, put it in one place. Change-Id: I731b1ce0c7b38fd42a91799a0565aafa94d4e9d0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtMiscUtils: add missing toAsciiUpper(), use it in mocMarc Mutz2022-12-181-0/+5
| | | | | | | | | | | | | | | | | | | | | | ... to make moc code locale-independent. The C toupper function is locale-dependent. Given the right locale (Türkiye, e.g.), toupper('i') is either - İ (LATIN CAPITAL LETTER I WITH DOT ABOVE; if representable) or - i (unchanged; if it isn't) Both results are wrong for the present use-case. Fix by adding QtMiscTools::toAsciiUpper(), complementing existing toAsciiLower(), and using that. It's private API, but moc.h, despite the name, is not a public header. Pick-to: 6.5 6.4 6.2 5.15 Task-number: QTBUG-109235 Change-Id: Iaf071ba2113b672aa0aed3da6a4e1d47fb659365 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QByteArray: Extract Function QtMiscUtils::caseCompareAscii()Marc Mutz2022-02-191-0/+9
| | | | | | Change-Id: Id9c385f4df4f33792738cd134fabb9cc03cab809 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QColor: avoid Unicode table lookups in fromString()Marc Mutz2022-02-181-0/+5
| | | | | | | | | | | | | | All color names supported by QColor are US-ASCII. Enforce this with a static_assert, then use this fact to perform the case-folding of the input in US-ASCII instead of Unicode. Avoids lookups in the Unicode tables. Add QtMiscUtils::toAsciiLower() to foster sharing. Change-Id: Ie0e123405d772943313dc4be1808667b152770b1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Whitespace cleanup in corelib/toolsAllan Sandfeld Jensen2020-10-211-1/+2
| | | | | Change-Id: Ibe796c398a8e5488b7203abb07aa54740744f1ab Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change QByteArray to handle large arraysLars Knoll2020-08-271-3/+1
| | | | | | | | | | 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>
* Replace Qt CONSTEXPR defines with constexprAllan Sandfeld Jensen2020-08-141-5/+5
| | | | | | | | 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>
* Allow allocating more than 2G items in a vectorLars Knoll2020-07-061-6/+6
| | | | | | | | | | | Also adjust qCalculateBlockSize() to be able to handle large allocations. QVector::length() is currently still limited to 2G items, that will get changed in a later commit. Change-Id: I3a92fbfd7f281d30844c5fafa3b9a474bc347c19 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Improve castingAllan Sandfeld Jensen2020-06-251-1/+1
| | | | | | | Make a handful of narrowing casts explicit Change-Id: I318e9778840f2437963377b6b97f269d569909dc Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Move container block-size calculations to qarraydata.cppEdward Welbourne2019-05-291-2/+2
| | | | | | | | | | | | | | These were in qbytearray.cpp, which doesn't use them, is big and I intend to move it to a different directory than the header, qtools_p.h, that declares them. So move them to a small file that does use them. Change-Id: I5a4684f8c7628e617546019cc3f01d92d829f085 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace Q_DECL_NOEXCEPT with noexcept in corelibAllan Sandfeld Jensen2019-04-031-7/+7
| | | | | | | In preparation of Qt6 move away from pre-C++11 macros. Change-Id: I44126693c20c18eca5620caab4f7e746218e0ce3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make sure all private headers in Qt Core include qglobal_p.hThiago Macieira2016-06-251-1/+1
| | | | | | | | | | | | The rule was: - if the header included qglobal.h, turn that into qglobal_p.h - otherwise, insert the #include after the "We mean it" warning qglobal_p.h currently only includes qglobal.h. Change-Id: Ib056b47dde3341ef9a52ffff13ef677e471674b7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Replace qAllocMore with a pair of more useful functionsThiago Macieira2016-06-091-3/+11
| | | | | | | | | | | | | | The first is "exact", not "more": qCalculateBlockSize. It ensures that there's no overflow in multiplying, adding the header size or when converting back to an int. The second is the replacement for qAllocMore: it calculates the block size like the first, but increases the block size to accommodate future appends. The number of elements that fit in the block is also returned. Task-number: QTBUG-41230 Change-Id: I52dd43c12685407bb9a6ffff13f5da09f816e667 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* 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>
* Fix Intel compiler warning about change of signThiago Macieira2015-02-171-4/+4
| | | | | | | | | | | | | The variable c is unsigned, so the second operand is unsigned, constraing the -1 to be unsigned too and causing a change of sign. Instead, cast the middle operations to int, as that's the return value anyway. error #68: integer conversion resulted in a change of sign Change-Id: I1a800c709d3543699131ffff13c2fd79f14f8b43 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* QtMiscUtils: make toHex*() constexprMarc Mutz2015-02-121-6/+4
| | | | | | | | | | Bring them into a constexpr'able form, by indexing into the string literal directly instead of into a static const char[], which is a declaration not allowed in a C++11 constexpr function, then mark the functions constexpr. Change-Id: I6b32a55bf24f85caeb980c0c855b8db0952f914c Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QtMiscUtils: add to/fromOctMarc Mutz2015-02-121-0/+10
| | | | | | | ...mirroring to/fromHex. Change-Id: Ie06bd3cc636b0afbc97606eadb8980079a7677a3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtMiscUtils: mark hex functions noexcept and fromHex constexprMarc Mutz2015-02-121-10/+7
| | | | | Change-Id: Ia5b63afa88a87ec995d76d48ac6c185168773369 Reviewed-by: Thiago Macieira <thiago.macieira@intel.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>
* Merge the multiple implementations of fromHex tooThiago Macieira2014-12-131-0/+11
| | | | | Change-Id: I8c22f784207dd8bffb88e70ac3c867abf0af86af Reviewed-by: Jason McDonald <macadder1@gmail.com>
* Merge the different implementations of toHex in one central placeThiago Macieira2014-12-131-0/+14
| | | | | | | | | It's a simple enough function, but we don't need to duplicate those 17 bytes all over the place. Now they'll be duplicated at most once per library. Change-Id: Ic995e2a934b005e7e996e70f2ee644bfa948eb38 Reviewed-by: Jason McDonald <macadder1@gmail.com>
* Check for integer overflows in places where qAllocMore is usedUlf Hermann2014-10-171-0/+6
| | | | | | | Task-number: QTBUG-41230 Change-Id: I5e932c2540c0bd67f13fab3ae20975d459f82c08 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Mark the QArrayData alloc/dealloc functions as nothrowThiago Macieira2014-02-191-1/+1
| | | | | | | Throwing is handled at a higher level. Change-Id: I573e4ded135b61e35fbe6e188be09acf449911fc Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.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>
* 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>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@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
* Initial import from the monolithic Qt.Qt by Nokia2011-04-271-0/+65
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