summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qcommandlineparser.cpp
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2023-02-27 17:36:01 +0100
committerMårten Nordheim <marten.nordheim@qt.io>2023-03-02 12:08:10 +0100
commitaf95f9746666c63e54c760d34b25c3c8b9bfdc72 (patch)
treefbe7c8a370f59fe8eb91a81d475f86be73210a4c /src/corelib/tools/qcommandlineparser.cpp
parent83dac218130a5e91616d1cd515815f0ce9b6c332 (diff)
DNS Lookup: Change local function to return struct instead of enum
This let's us get rid of an out-parameter. Task-number: QTBUG-108873 Pick-to: 6.5 Change-Id: Ifc08d3905932f28ecdfdf3a7de1499700cc7e606 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/tools/qcommandlineparser.cpp')
-rw-r--r--src/corelib/tools/qcommandlineparser.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp
index c15e2827f1b..c0a073085db 100644
--- a/src/corelib/tools/qcommandlineparser.cpp
+++ b/src/corelib/tools/qcommandlineparser.cpp
@@ -176,7 +176,7 @@ QStringList QCommandLineParserPrivate::aliases(const QString &optionName) const
It is then advisable to introduce a function to do the command line parsing
which takes a struct or class receiving the option values returning an
- enumeration representing the result. The dnslookup example of the QtNetwork
+ object representing the result. The dnslookup example of the QtNetwork
module illustrates this:
\snippet dnslookup.h 0
@@ -204,20 +204,22 @@ QStringList QCommandLineParserPrivate::aliases(const QString &optionName) const
\code
- switch (parseCommandLine(parser, &query, &errorMessage)) {
- case CommandLineOk:
+ switch (parseResult.statusCode) {
+ case Status::Ok:
break;
- case CommandLineError:
+ case Status::Error: {
+ QString errorMessage = parseResult.errorString.value_or(u"Unknown error occurred"_qs);
QMessageBox::warning(0, QGuiApplication::applicationDisplayName(),
"<html><head/><body><h2>" + errorMessage + "</h2><pre>"
+ parser.helpText() + "</pre></body></html>");
return 1;
- case CommandLineVersionRequested:
+ }
+ case Status::VersionRequested:
QMessageBox::information(0, QGuiApplication::applicationDisplayName(),
QGuiApplication::applicationDisplayName() + ' '
+ QCoreApplication::applicationVersion());
return 0;
- case CommandLineHelpRequested:
+ case Status::HelpRequested:
QMessageBox::warning(0, QGuiApplication::applicationDisplayName(),
"<html><head/><body><pre>"
+ parser.helpText() + "</pre></body></html>");