1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the tools applications of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29//
30// W A R N I N G
31// -------------
32//
33// This file is not part of the Qt API. It exists purely as an
34// implementation detail. This header file may change from version to
35// version without notice, or even be removed.
36//
37// We mean it.
38
39#ifndef QApplicationArgumentParser_H
40#define QApplicationArgumentParser_H
41
42#include <QtCore/QVariant> /* Needed, because we can't forward declare QVariantList. */
43
44QT_BEGIN_NAMESPACE
45
46class QApplicationArgument;
47class QApplicationArgumentParserPrivate;
48class QStringList;
49template<typename A, typename B> struct QPair;
50template<typename T> class QList;
51template<typename Value> class QList;
52
53class QApplicationArgumentParser
54{
55public:
56 enum ExitCode
57 {
58 Success = 0,
59 ParseError = 1
60 };
61
62 QApplicationArgumentParser(int argc, char **argv);
63 QApplicationArgumentParser(const QStringList &input);
64 virtual ~QApplicationArgumentParser();
65 void addArgument(const QApplicationArgument &argument);
66 void setDeclaredArguments(const QList<QApplicationArgument> &arguments);
67 QList<QApplicationArgument> declaredArguments() const;
68
69 int count(const QApplicationArgument &argument) const;
70 bool has(const QApplicationArgument &argument) const;
71
72 virtual bool parse();
73 ExitCode exitCode() const;
74 QVariant value(const QApplicationArgument &argument) const;
75 QVariantList values(const QApplicationArgument &argument) const;
76 void setApplicationDescription(const QString &description);
77 void setApplicationVersion(const QString &version);
78 virtual void message(const QString &message) const;
79
80protected:
81 void setExitCode(ExitCode code);
82 void setUsedArguments(const QList<QPair<QApplicationArgument, QVariant> > &arguments);
83 QList<QPair<QApplicationArgument, QVariant> > usedArguments() const;
84 QStringList input() const;
85 virtual QVariant convertToValue(const QApplicationArgument &argument,
86 const QString &value) const;
87 virtual QString typeToName(const QApplicationArgument &argument) const;
88 virtual QVariant defaultValue(const QApplicationArgument &argument) const;
89
90private:
91 friend class QApplicationArgumentParserPrivate;
92 QApplicationArgumentParserPrivate *d;
93 Q_DISABLE_COPY(QApplicationArgumentParser)
94};
95
96QT_END_NAMESPACE
97
98#endif
99

source code of qtxmlpatterns/tools/xmlpatterns/qapplicationargumentparser_p.h