aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/stringutils.h
Commit message (Collapse)AuthorAgeFilesLines
* Utils: Add overloads for joinStringsMarcus Tillmanns2025-10-291-1/+3
| | | | | Change-Id: Ia219c16bfe4ec37b29b50544b4c96cdaa24fb545 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Utils: Add applyJsonPatchMarcus Tillmanns2025-09-031-0/+2
| | | | | Change-Id: Iebfcb605b0d68cb97850ed3f9427089f4d7688fd Reviewed-by: David Schulz <david.schulz@qt.io>
* Utils: Add Utils::cleanJsonMarcus Tillmanns2025-08-211-0/+2
| | | | | | | cleanJson removes all comments and superflous commas from the Input. Change-Id: Ib252f5c402c30305abd13ff9022ec3a0c480eac9 Reviewed-by: hjk <hjk@qt.io>
* GenericProject: Make QStringList insert function reusableAndre Hartmann2025-07-221-0/+3
| | | | | Change-Id: Ie22aed3232e5a5d28f45ab2aadc8399e939fb046 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* Utils: Add stringutils function to remove comments from json filesMarcus Tillmanns2025-05-211-0/+2
| | | | | Change-Id: I1f82fe24e2cc847ce78af05931fa426eeea0718e Reviewed-by: hjk <hjk@qt.io>
* Utils: Introduce a Utils::TextCodec classhjk2025-05-141-4/+0
| | | | | | | | | | | | | Meant as replacement for QTextCodec, which is deprecated. The initial attempt to just use the codec name everywhere turned out to be a bit limited and lead to "non-speaking code" (!isEmpty, ...), so this here is a bit more class-y. For now, the new Utils::TextCodec still uses QTextCodec internally. Change-Id: I001e0769acd4e2a044063dde98ffaca278b1ca03 Reviewed-by: David Schulz <david.schulz@qt.io>
* Utils: Add fromUnicode()/toUnicode() wrappers around QTextCodechjk2025-05-121-0/+2
| | | | | | | Meant to hide QTextCodec use from some user code later. Change-Id: Id59cde921937f22b21bc842da92e577bf0fe9e00 Reviewed-by: David Schulz <david.schulz@qt.io>
* Utils: Add a Utils::codecForLocale()hjk2025-05-121-0/+2
| | | | | | | | ... returning the name of the codec for the current locale and use it in a few places. Change-Id: Id11f2c7b04021a09119020cee3dc723fae6923a3 Reviewed-by: David Schulz <david.schulz@qt.io>
* Utils: optimize emitting single lines for big chunks of inputDavid Schulz2025-05-091-1/+1
| | | | | | | | | | | | | The incomplete line buffer gets split and assigned multiple times if it contains more than one new line and emitSingleLines is true. So this splitting and assigning gets expensive if the buffer contains many new lines. Using a view allows to use the same QString functions without the need to manually handle offsets. Task-number: QTCREATORBUG-32895 Change-Id: I2f7c8eb699c55a11fd3bf1c25239b037ed15c7f7 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: hjk <hjk@qt.io>
* Utils: Add function to normalize lineendings in a QByteArrayhjk2025-04-151-0/+1
| | | | | | | | Replaces "\r\n" by "\n". Also read back-to-front to save some cycles Done-with: David Schulz Change-Id: Ifa5e1ccde2da40e9b18b5ea9d60d580f8429ad19 Reviewed-by: David Schulz <david.schulz@qt.io>
* Utils: Remove AbstractMacroExpanderMarcus Tillmanns2024-10-211-23/+0
| | | | | | | | | | It was only used by its own tests. Instead move the functionality into MacroExpander(Private). The existing unittests are moved into tst_expander. Change-Id: Ia54f659efa7976b17f47a0084900f98acc834939 Reviewed-by: hjk <hjk@qt.io>
* Utils: Move highlight function to textutilsMarcus Tillmanns2024-10-101-4/+0
| | | | | Change-Id: I4c861ba8fa45bf5bf967903451a98c05bc4cb2ae Reviewed-by: hjk <hjk@qt.io>
* Utils: Add simple text highlight functionMarcus Tillmanns2024-10-101-0/+5
| | | | | Change-Id: I0eb740214c975da9f6bea87cef2aee23a63d6125 Reviewed-by: hjk <hjk@qt.io>
* Utils: Pass QColor by &Alessandro Portale2024-05-071-1/+1
| | | | | | | Change-Id: Idef5659934c9de47fd879c73a0fe5dfcb890237c Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Utils: Add function to format colored textMarcus Tillmanns2024-05-071-0/+2
| | | | | Change-Id: I6ae4d113e0aca434e99d9864188187100c24e47d Reviewed-by: Cristian Adam <cristian.adam@qt.io>
* Fix missing overrides and redundant virtualAlessandro Portale2023-11-141-1/+1
| | | | | Change-Id: Id2a247b6032602c2295d928067c2462d3f9b5221 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
* Utils: Turn "Util.asciify" into a plain macroAlessandro Portale2023-11-071-0/+2
| | | | | | | | | | | | | | This monves the asciify function to stringutils and makes it directly available as "asciify:" prefix macro, so that the generation of a default build path does not go through JavaScript. "Util.asciify" remains available as core JavaScript extension for the case that it is used by third party code/wizards. This change also adds a test to tst_stringutils Change-Id: Iba2f20c0415ee8fe757c2f0058a90629b3fbeff0 Reviewed-by: hjk <hjk@qt.io>
* Markdown: Use different background color for codeEike Ziller2023-08-021-0/+3
| | | | | | | | Sets the background color for code blocks and for inline code (actually for any fixed font text). Change-Id: I1365111b38314a8e0a129aca35d754ad3f2f13bb Reviewed-by: Cristian Adam <cristian.adam@qt.io>
* Markdown: Reuse Markdown highlighter from change log viewerEike Ziller2023-04-191-0/+12
| | | | | | Change-Id: Ief1b0c135a34bfd5e9b5220e9fbf93f281d8e95a Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Copilot: Add insert next word actionMarcus Tillmanns2023-04-061-0/+2
| | | | | | Fixes: QTCREATORBUG-28959 Change-Id: Ied53ad5676133e2eb71988ecfcce90c5ad77e3c3 Reviewed-by: David Schulz <david.schulz@qt.io>
* Utils: Add stringutils splitAtFirstMarcus Tillmanns2023-03-131-0/+4
| | | | | Change-Id: I221d6c6086f53ec5f94c1157ea533d862db38d52 Reviewed-by: hjk <hjk@qt.io>
* StringUtils: Add trimFront(), trimBack() and trim() methodsJarek Kobus2023-02-051-1/+3
| | | | | | Change-Id: I900c30111c79bee548c4861b082d7b035a5dc43d Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* StringUtils: Add joinStrings methodJarek Kobus2023-02-031-0/+3
| | | | | | | See QTBUG-110900. In meantime, StringUtils addition. Change-Id: I700321a65d2d00b85daa412c77b573457312ad3c Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* Utils: Move QtcProcess::normalizeNewlines() into StringUtilsJarek Kobus2023-02-011-0/+3
| | | | | | | Change-Id: I515d2554497d5c27fd75e50c80ba373fbbe8dcb5 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Remove GPL-3.0+ from license identifiersKai Köhne2023-01-061-1/+1
| | | | | | | | | | | | | | | Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0, this applies only to a hypothetical newer version of GPL, that doesn't exist yet. If such a version emerges, we can still decide to relicense... While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only Change was done by running find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \; Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Make Utils::withTildeHomePath a FilePath memberhjk2023-01-051-5/+0
| | | | | | | | Gets .osType() right in remote cases. Change-Id: I6397996062d976d7db690c5729dd4faa1f459563 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
* Utils: Drop commonPath(QStringList)hjk2023-01-041-4/+0
| | | | | | | | | There's FileUtils::commonPath(FilePaths) nowadays. Change-Id: I26e30d61eb80cb457458791e9ad049356f18de98 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* Utils: Remove FilePath::operator+()hjk2022-11-301-2/+7
| | | | | | | | | This was a alias for .stringAppended(), but can be used too easily when .pathAppended() is meant. Change-Id: Ia3b64d39828d4074b43d87c923ce3a6a87038948 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* Use SPDX license identifiersLucie Gérard2022-08-261-24/+2
| | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Task-number: QTBUG-67283 Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* FilePath: Fix UNC root/path parsingMarcus Tillmanns2022-08-111-0/+1
| | | | | | | | | * Fixed UNC path parsing to correctly split between root and path * Fixed tst_fileutils to correspond to windows path handling. Change-Id: I2849738696a39e8282068ab164514f806f2c5fcf Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: hjk <hjk@qt.io>
* filesystem: Add QFSEngine for filepathsMarcus Tillmanns2022-07-211-0/+2
| | | | | Change-Id: Ibd0c88c69863c0877138d8cc45541530c359bd9c Reviewed-by: hjk <hjk@qt.io>
* Utils: Add a convenience function to fill clipboard and selectionhjk2022-06-201-0/+8
| | | | | | | | Relieves the user code side from repeated code which then tends to get forgotten. Change-Id: I079f97a658b55f3c79111df1946b8d72863ce513 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Drop [Qt::]SkipEmptyParts from porting.hhjk2022-03-101-2/+0
| | | | | | | | Not needed anymore after 7c942cfd188. Change-Id: I5e6021cb64a399fa3bc3067b2fcd60ab48587daa Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Multilanguage: Add utility to get language names consistentlyTuomo Pelkonen2022-01-121-0/+3
| | | | | | | | | | | | | There are multiple places that language codes are converted to language names each doing it a different way. To make this consistent, we need to have a single implementation for it. Change-Id: I2aeaf5b7c9203e8a41a61420f4c98e1fce491db5 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Add missing includeEike Ziller2020-12-071-0/+2
| | | | | | | | for makeUniquelyNumbered. Amends 48ebaecb524bb1e7320596954b834cb01c3cd898 Change-Id: I52a16068907d012d6d3997464c067a02f92862fa Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* ProjectExplorer: Set unique build directoryChristian Kandeler2020-11-111-4/+12
| | | | | | | | | | ... after cloning a build configuration. It's very unlikely that the user intends to re-use the same build directory in the new build configuration. Fixes: QTCREATORBUG-24831 Change-Id: I39b7839225e973fea4e16b9b686fbbf9207cb5ae Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Fix matching wildcards to full pathsChristian Stenger2020-10-191-0/+7
| | | | | | Fixes: QTCREATORBUG-24792 Change-Id: I82b4edea6260b07e1bdff065b157a4cd044ec629 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Introduce a central porting.h for "simple porting stuff"hjk2020-06-221-6/+2
| | | | | | | | | I figured it might be easier to keep track of active hack here and also recognized includes that only exist for that reasons in user code if it's always the same. Change-Id: I4bf6af493443148cf30a6903d541cd9dc58946da Reviewed-by: David Schulz <david.schulz@qt.io>
* Fix Qt 5.15 deprecation warnings for QString::SkipEmptyPartsChristian Kandeler2020-06-161-0/+6
| | | | | | Task-number: QTCREATORBUG-24098 Change-Id: I03ee6811df4346754bbd652f2c3c97477f9cdb7e Reviewed-by: hjk <hjk@qt.io>
* Deduplicate elapsed time formattingAndre Hartmann2020-02-291-1/+1
| | | | | | | | While it's nice to see my code spreading, I still prefer to have it at one place. Change-Id: I7bdb13c47ed7e96227deeb14b0a8070aa40148de Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* Move Project::makeUnique to UtilsEike Ziller2018-04-111-1/+17
| | | | | | | This is more generic than projects Change-Id: Ifdbc57ff48f9fd4a40e6149ba636e0a55cbac502 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
* Fix that menus didn't show ampersands in files namesEike Ziller2018-03-261-0/+2
| | | | | | | | | | And instead interpreted the ampersand + following character as an accelerator key. Task-number: QTCREATORBUG-17817 Change-Id: I327239499ce56e75fd12f2df5be60d4b04913acd Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* Utils: Introduce case friendly comparison function to stringutilsTobias Hunger2018-03-131-0/+3
| | | | | | | | | | Use this operator in the miniprojecttargetselector as well as the projectconfigurationmodel. This should unify the sorting of build-/deploy- and runconfigurations in various places in Creator. Task-number: QTCREATORBUG-20023 Change-Id: I7aed2ebcb9d65244395d68b7dc5da599d6503962 Reviewed-by: hjk <hjk@qt.io>
* ProjectExplorer: Fix parsing ports from netstat output on Windowshjk2017-08-241-0/+2
| | | | | | | Handle IPv6, and do not try to interpret the result as hex. Change-Id: I700c233d03cc706bc8712ab9fabee75d7f126df3 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Unit tests: Fix ProjectInfoGenerator.* testsNikolai Kosjar2017-07-271-0/+3
| | | | | | | | | | ...by adapting to recent mime type changes: commit e8e46ab553bce9aac9adcaf2ac4ee1207b69ac93 Plugins: Fix that mimetype definition was not valid JSON Change-Id: Iac416ab481814e4488fac4d818c51c647c1ec349 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Introduce and use Utils::stripAcceleratorOrgad Shaneh2017-07-071-0/+3
| | | | | Change-Id: I8c37728ca5de20e2b68e6d0ac7fc120baa696040 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* MacroExpander: Prevent loop with subprovidersTobias Hunger2017-06-201-1/+1
| | | | | | | | Prevent a loop where a subprovider of a macroexpander creates the macroexpander itself. Change-Id: Id2f3e29651aeb22c818091d8c785a6ea01545463 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
* Wholesale conversion to #pragma oncehjk2016-03-301-4/+1
| | | | | | | Kudos to cgmb and https://github.com/cgmb/guardonce Change-Id: Ifa8970734b8d43fd08c9260c645bdb0228633791 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
* Update License according to agreement with Free Qt FoundationTobias Hunger2016-01-191-17/+12
| | | | | | | * Update remaining files in src Change-Id: I1896f17fcf34f71c3310c87899fb5171b8e4afb1 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
* Update LicenseEike Ziller2015-01-161-6/+6
| | | | | Change-Id: I711d5fb475ef814a1dc9d2822740e827f3f67125 Reviewed-by: Alessandro Portale <alessandro.portale@digia.com>