Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qcommandlineparser.h
Go to the documentation of this file.
1// Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QCOMMANDLINEPARSER_H
5#define QCOMMANDLINEPARSER_H
6
7#include <QtCore/qstringlist.h>
8
9#include <QtCore/qcoreapplication.h>
10#include <QtCore/qcommandlineoption.h>
11
12QT_REQUIRE_CONFIG(commandlineparser);
13
15
18
19class Q_CORE_EXPORT QCommandLineParser
20{
22public:
25
30 void setSingleDashWordOptionMode(SingleDashWordOptionMode parsingMode);
31
34 ParseAsPositionalArguments
35 };
36 void setOptionsAfterPositionalArgumentsMode(OptionsAfterPositionalArgumentsMode mode);
37
38 bool addOption(const QCommandLineOption &commandLineOption);
39 bool addOptions(const QList<QCommandLineOption> &options);
40
41 QCommandLineOption addVersionOption();
42 QCommandLineOption addHelpOption();
43 void setApplicationDescription(const QString &description);
44 QString applicationDescription() const;
45 void addPositionalArgument(const QString &name, const QString &description, const QString &syntax = QString());
46 void clearPositionalArguments();
47
48 void process(const QStringList &arguments);
49 void process(const QCoreApplication &app);
50
51 bool parse(const QStringList &arguments);
52 QString errorText() const;
53
54 bool isSet(const QString &name) const;
55 QString value(const QString &name) const;
56 QStringList values(const QString &name) const;
57
58 bool isSet(const QCommandLineOption &option) const;
61
62 QStringList positionalArguments() const;
63 QStringList optionNames() const;
64 QStringList unknownOptionNames() const;
65
67 Q_NORETURN void showHelp(int exitCode = 0);
68 QString helpText() const;
69
70private:
71 Q_DISABLE_COPY(QCommandLineParser)
72
74};
75
77
78#endif // QCOMMANDLINEPARSER_H
The QCommandLineOption class defines a possible command-line option. \inmodule QtCore.
The QCommandLineParser class provides a means for handling the command line options.
SingleDashWordOptionMode
This enum describes the way the parser interprets command-line options that use a single dash followe...
OptionsAfterPositionalArgumentsMode
This enum describes the way the parser interprets options that occur after positional arguments.
\inmodule QtCore
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QList< QVariant > arguments
Combined button and popup list for selecting options.
#define Q_NORETURN
#define Q_DECLARE_TR_FUNCTIONS(context)
static void showVersion()
static void showHelp()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLenum GLsizei GLsizei GLint * values
[15]
GLenum mode
GLuint name
GLuint GLenum option
static QString helpText(const QCommandLineParser &p, const PluginInformation &pluginInfo)
Definition main.cpp:764
#define QT_REQUIRE_CONFIG(feature)
QApplication app(argc, argv)
[0]