summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qcommandlineparser.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-08-161-0/+5
|\ | | | | | | | | | | | | | | | | | | | | | | Conflicts: qmake/doc/src/qmake-manual.qdoc src/corelib/global/qglobal.cpp src/corelib/tools/qstring.cpp src/network/socket/qabstractsocket.cpp src/network/socket/qnativesocketengine_unix.cpp src/plugins/platforms/eglfs/api/qeglfsglobal.h Change-Id: Id5dfdbd30fa996f9b4b66a0b030b7d3b8c0ef288
| * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-08-131-0/+5
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qglobal.cpp src/corelib/io/qsettings.cpp src/corelib/itemmodels/qstringlistmodel.cpp tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp Change-Id: I1c6c306ef42c3c0234b19907914b19da706b4a03
| | * QCommandLineParser: call qCoreApp post routines before ::exit()David Faure2016-08-121-0/+5
| | | | | | | | | | | | | | | | | | | | | This gives a chance for some cleanups at least. Change-Id: I3a628e32c6fc8c7fa00943769210c517005f2a0a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-05-031-3/+4
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | CoreLib: use const (and const APIs) moreAnton Kudryavtsev2016-04-181-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For CoW types const methods will be called. Mark store_persistent_indexes() as const, because this method does not modify the object. Change-Id: Ic867913b4fb5aaebfbaaffe1d3be45cf7b646403 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | QtCore: Remove Windows CE.Friedemann Kleint2016-03-301-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | Remove QSysInfo::WV_CE_5/6 enumeration values, #ifdef sections for Q_OS_WINCE and wince .pro file clauses in library, examples and tests. Task-number: QTBUG-51673 Change-Id: Ib63463445f3a26e04d018b193e4655030002f5f9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | | Add QCommandLineOption::Flags containing HiddenFromHelp and ShortOptionStyleOlivier Goffart2016-03-231-3/+17
|/ / | | | | | | | | | | | | | | | | | | | | | | This patch adds a new option, QCommandLineOption::ShortOptionStyle, which helps applications (such as compilers, so moc and now qdoc) which need to mix long-style and short flags. [ChangeLog][QtCore][QCommandLineOption] Added flags() and setFlags() methods. Added ShortOptionStyle and HiddenFromHelp flags. Change-Id: I944ce56aff2b28ecd6bb9d2d23c4e726e9d06647 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | QtCore: replace QStringLiteral with QLatin1String when appendingMarc Mutz2016-02-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It makes little sense to use QStringLiteral for strings which are immediately appended to, or which are appended to other strings, because no dynamic memory allocation is saved by doing so. But if the only advantage of QStringLiteral does not apply, all its disadvantages dominate, to wit: injection of calls to qstring dtor, non-sharability of data between C strings and QStringLiterals and among QStringLiterals, and doubled storage requirements. Fix by replacing QStringLiteral with QLatin1String. Saves 1156B in text size on stripped optimized Linux AMD64 GCC 4.9 builds. Change-Id: If805e431f570ec1d2ac62c548f516f1b17390c3a Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Updated license headersJani Heikkinen2016-01-151-13/+19
| | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge remote-tracking branch 'origin/5.6' into devFrederik Gladhorn2016-01-081-2/+8
|\| | | | | | | | | | | Based on merge done by Liang Qi Change-Id: Id566e5b9f284d29bff2199f13f9417c660f5b26f
| * Winrt: Show message when command line processing fails/usage should be shownOliver Wolff2016-01-051-2/+8
| | | | | | | | | | Change-Id: If8f69906beb22f632ccbde92aab5caf914dcb31b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
* | QtCore: eradicate all Q_FOREACH loops [tools]Marc Mutz2016-01-041-11/+9
| | | | | | | | | | | | | | | | Saves just under 5.5KiB in text size on optimized GCC 4.9 Linux AMD64 builds. Change-Id: I6d868a7d2e469cf0564127b0e66cd7b272a0c9cd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Optimize string building in QCommandLineParserPrivate::helpText()Marc Mutz2015-12-291-20/+22
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | - Don't detach QCoreApplication::arguments() by calling first(), call constFirst() - Use QString foo; foo += initial; instead of QString foo = initial; where 'foo' receives more appends later (does not force an initial capacity that is known to be too small). - Use QStringBuilder more - Don't use QStringLiteral in QStringBuilder expressions - Reserve optionNameList. Its max. size is known ahead of time. - Don't create optionNameStrings for hidden options. The result was never used, they just served as placeholders for the lock-step iteration that followed and wrapped the text. - Don't create a QStringList to join(), append to the result string directly. - Cache the return value of option.valueName(). Not only is this faster, it also saves more than 2KiB in text size on optimized GCC 4.9 Linux AMD64 builds. Change-Id: Id1d88f3c36a521ac71f3a7436810ed31319077ae Reviewed-by: David Faure <david.faure@kdab.com>
* Fix \sinceLars Knoll2015-10-081-2/+2
| | | | | | | This API only appeared in 5.6. Change-Id: I3ddda44f7c55c94c7f22f76f83a45094209d8c39 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtCore: mark some more types as movable/primitiveMarc Mutz2015-07-071-0/+1
| | | | | | | | These are already held in QVectors. Change-Id: I6fe831ba5b75d792fd13e63ef0d2e178b52e1107 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.5' into devSimon Hausmann2015-06-031-4/+4
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qnamespace.qdoc src/corelib/io/qwindowspipereader.cpp src/corelib/io/qwindowspipereader_p.h src/corelib/statemachine/qstatemachine.cpp src/corelib/statemachine/qstatemachine_p.h src/plugins/platforms/xcb/qxcbconnection.h tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp tests/auto/tools/qmake/tst_qmake.cpp tests/manual/touch/main.cpp Change-Id: I917d694890e79ee3da7d65134b5b085e23e0dd62
| * Don't assign iterator to const_iteratorSérgio Martins2015-06-021-4/+4
| | | | | | | | | | | | | | | | It should also be possible to use QT_STRICT_ITERATORS in Qt's own code base Change-Id: I0914db480d4d2b06e71e3a2588163efdd3ff6d27 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | QCommandLineParser: add parsing mode for options after argumentsDavid Faure2015-03-061-3/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new mode, ParseAsPositionalArguments, allows to interpret "application argument --opt" as having two positional arguments, "argument" and "--opt". This mode is useful for executables that aim to launch other executables (e.g. wrappers, debugging tools, etc.) or who support internal commands followed by options for the command. "argument" is the name of the command, and all options occurring after it can be collected and parsed by another command line parser, possibly in another executable. [ChangeLog][QtCore][QCommandLineParser] Add parsing mode for options after arguments, to allow treating them as more arguments. Change-Id: I48d5fcf90f2f59deda8422538b8ebf2680fae828 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QCommandLineParser: add support for hiding options from --help.David Faure2015-02-231-0/+2
|/ | | | | | | | | [ChangeLog][QtCore][QCommandLineParser] Added support for hiding options from the --help output, with QCommandLineOption::setHidden(true). Task-number: QTBUG-44298 Change-Id: I62cc2a55428365c0bcc79d2e47c72c0c92104e74 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-111-6/+6
| | | | | | | | | | | | | | | | | | 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 remote-tracking branch 'origin/5.4' into devSimon Hausmann2014-12-181-3/+5
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qglobal.h src/platformsupport/platformcompositor/qopenglcompositor.cpp src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp tests/auto/gui/kernel/qwindow/tst_qwindow.cpp Change-Id: I5422868500be695584a496dbbbc719d146bc572d
| * Doc: corrected documentation addOptions()Nico Vertriest2014-12-121-3/+5
| | | | | | | | | | | | Task-number: QTBUG-43259 Change-Id: If27c0658f7abaa4ce01de343ce90c14bd911212f Reviewed-by: Martin Smith <martin.smith@digia.com>
* | QCommandLineParser: Show usage and errors in message boxes on Windows.Friedemann Kleint2014-11-271-20/+48
|/ | | | | | | | | | | Use the Windows MessageBox API if no console window can be obtained. [ChangeLog][QtCore][QCommandLineParser] Message boxes are used to display errors and usage if no console window can be obtained on Windows. Change-Id: I63ee8e4d8bd78db83e688fd69374779102562aa3 Reviewed-by: David Faure <david.faure@kdab.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-18/+10
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* QCommandLineParser: support extremely concise option configuration in C++11Marc Mutz2014-08-061-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The goal of this commit to make the code in the test work: QCommandLineParser parser; parser.addOptions({ { "a", "The A option." }, { { "v", "verbose" }, "The verbose option." }, { { "i", "infile" }, "The input file.", "value" }, }); For this, QCommandLineParser needs a version of addOption that can take a list of options. That's what addOptions() is for. More importantly, the QCommandLineOption ctors mustn't be explicit. OTOH, any implicit conversion from QString or QStringList to QCommandLineOption is also undesirable. To solve this dilemma, add new QCommandLineOption ctors that just take one argument and are explicit, and make the existing ctors implicit. In order to avoid ambiguities, remove the default values of their resp. 2nd arguments. The new ctors are by intention not \since 5.4, as they are completely transparent to the user. Et voila, even better than getopt_long(3). [ChangeLog][QtCore][QCommandLineParser] Added addOptions() method. Change-Id: I5e779f3406cd0f6c8ec6ecbf6c8074af226de300 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-03-241-0/+72
|\ | | | | | | | | | | | | Conflicts: src/gui/image/qjpeghandler.cpp Change-Id: I9db3acea7d5c82f5da679c8eaeb29431136665f0
| * Use QCommandLineParser in example dnslookup.Friedemann Kleint2014-03-151-0/+72
| | | | | | | | | | | | | | | | | | | | | | Show how use QCommandLineParser with additional parameter checking for custom options and positional arguments. Also explain how to display help in GUI applications. Change-Id: I03513e09b7dd5b150259593da0af2ef2a281cab2 Reviewed-by: David Faure <david.faure@kdab.com>
* | Add QCommandLineParser::showVersion(), similar to showHelp().David Faure2014-03-141-4/+18
|/ | | | | | Change-Id: I1782c226ee8c457a68eb9ae9948a2a6a700d7a52 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Make QCommandLineParser not crash if passed a bad QCommandLineOptionThiago Macieira2014-01-161-1/+2
| | | | | | | | | | | This otherwise crashed: QCommandLineOotion opt("with=equals"); parser.isSet(opt); Can't write a unit test because it produces a warning. Change-Id: Ifc67f20bb4b16b96d93dffbe4e82e6cc8a17584d Reviewed-by: David Faure <david.faure@kdab.com>
* QCommandLineParser: pluck some low-hanging fruit re: exception safetyMarc Mutz2013-12-061-2/+2
| | | | | | | | | | | | | | | | | Make QCommandLineParser::add{Help,Version}Option() QCommandLineOption::setDefaultValue() QCommandLineOptionPrivate::setNames() have transaction semantics: either they succeed, or they change nothing. It's trivial to provide this guarantee, so do it. Add a test for the surprising property that setDefaultValue("") resets defaultValues() to an empty QStringList instead of one that contains the empty string. Change-Id: I61623019de3c7d2e52c24f42cc2e23ec5fddc4da Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCommandLineParser: add word-wrapping algorithmDavid Faure2013-11-171-5/+44
| | | | | | | | Rather than breaking at column 79 precisely, break entire words, to improve readability. Change-Id: Ie30db00f0e6ed95cce87480c3b91804826c6076b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* Doc: Adding mark-up to boolean default values.Jerome Pasion2013-10-081-8/+8
| | | | | | | | | | | | | | | | | Default values should have mark-up to denote that they are code. This commit changes: -"property is true" to "property is \c true". -"Returns true" to "Returns \c true". -"property is false" to "property is \c false". -"returns true" to "returns \c true". -"returns false" to "returns \c false". src/3rdparty and non-documentation instances were ignored. Task-number: QTBUG-33360 Change-Id: Ie87eaa57af947caa1230602b61c5c46292a4cf4e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* QCommandLineParser: improve implementationDavid Faure2013-09-101-11/+9
| | | | | | | Based on feedback from Thiago. Change-Id: I9a3ce0b90b5d1d680c66351d421874effbd426f8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCommandLineParser: improve documentationDavid Faure2013-09-101-29/+43
| | | | | | | Based on feedback from Thiago Change-Id: I8912447197e636732e5b8ac37e77d18b54e9b43d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Long live QCommandLineParser!David Faure2013-08-241-0/+896
The QCommandLineParser class provides a means for handling the command line options. QCoreApplication provides the command-line arguments as a simple list of strings. QCommandLineParser provides the ability to define a set of options, parse the command-line arguments, and store which options have actually been used, as well as option values. Done-with: Laszlo Papp <lpapp@kde.org> Change-Id: Ic7bebc10b3f8d8dd06ad0f4bb897c51d566e3b7c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>