Warning, file /include/QtCore/qcommandlineparser.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004 #ifndef QCOMMANDLINEPARSER_H
0005 #define QCOMMANDLINEPARSER_H
0006
0007 #include <QtCore/qstringlist.h>
0008
0009 #include <QtCore/qcoreapplication.h>
0010 #include <QtCore/qcommandlineoption.h>
0011
0012 QT_REQUIRE_CONFIG(commandlineparser);
0013
0014 QT_BEGIN_NAMESPACE
0015
0016 class QCommandLineParserPrivate;
0017 class QCoreApplication;
0018
0019 class Q_CORE_EXPORT QCommandLineParser
0020 {
0021 Q_DECLARE_TR_FUNCTIONS(QCommandLineParser)
0022 public:
0023 QCommandLineParser();
0024 ~QCommandLineParser();
0025
0026 enum SingleDashWordOptionMode {
0027 ParseAsCompactedShortOptions,
0028 ParseAsLongOptions
0029 };
0030 void setSingleDashWordOptionMode(SingleDashWordOptionMode parsingMode);
0031
0032 enum OptionsAfterPositionalArgumentsMode {
0033 ParseAsOptions,
0034 ParseAsPositionalArguments
0035 };
0036 void setOptionsAfterPositionalArgumentsMode(OptionsAfterPositionalArgumentsMode mode);
0037
0038 bool addOption(const QCommandLineOption &commandLineOption);
0039 bool addOptions(const QList<QCommandLineOption> &options);
0040
0041 QCommandLineOption addVersionOption();
0042 QCommandLineOption addHelpOption();
0043 void setApplicationDescription(const QString &description);
0044 QString applicationDescription() const;
0045 void addPositionalArgument(const QString &name, const QString &description, const QString &syntax = QString());
0046 void clearPositionalArguments();
0047
0048 void process(const QStringList &arguments);
0049 void process(const QCoreApplication &app);
0050
0051 bool parse(const QStringList &arguments);
0052 QString errorText() const;
0053
0054 bool isSet(const QString &name) const;
0055 QString value(const QString &name) const;
0056 QStringList values(const QString &name) const;
0057
0058 bool isSet(const QCommandLineOption &option) const;
0059 QString value(const QCommandLineOption &option) const;
0060 QStringList values(const QCommandLineOption &option) const;
0061
0062 QStringList positionalArguments() const;
0063 QStringList optionNames() const;
0064 QStringList unknownOptionNames() const;
0065
0066 Q_NORETURN void showVersion();
0067 Q_NORETURN void showHelp(int exitCode = 0);
0068 QString helpText() const;
0069
0070 private:
0071 Q_DISABLE_COPY(QCommandLineParser)
0072
0073 QCommandLineParserPrivate * const d;
0074 };
0075
0076 QT_END_NAMESPACE
0077
0078 #endif