1// Copyright (C) 2020 The Qt Company Ltd.
2// Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QCOMMANDLINEOPTION_H
6#define QCOMMANDLINEOPTION_H
7
8#include <QtCore/qstringlist.h>
9#include <QtCore/qshareddata.h>
10
11QT_REQUIRE_CONFIG(commandlineparser);
12
13QT_BEGIN_NAMESPACE
14
15class QCommandLineOptionPrivate;
16
17class Q_CORE_EXPORT QCommandLineOption
18{
19public:
20 enum Flag {
21 HiddenFromHelp = 0x1,
22 ShortOptionStyle = 0x2
23 };
24 Q_DECLARE_FLAGS(Flags, Flag)
25
26 explicit QCommandLineOption(const QString &name);
27 explicit QCommandLineOption(const QStringList &names);
28 /*implicit*/ QCommandLineOption(const QString &name, const QString &description,
29 const QString &valueName = QString(),
30 const QString &defaultValue = QString());
31 /*implicit*/ QCommandLineOption(const QStringList &names, const QString &description,
32 const QString &valueName = QString(),
33 const QString &defaultValue = QString());
34 QCommandLineOption(const QCommandLineOption &other);
35
36 ~QCommandLineOption();
37
38 QCommandLineOption &operator=(const QCommandLineOption &other);
39 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QCommandLineOption)
40
41 void swap(QCommandLineOption &other) noexcept
42 { d.swap(other&: other.d); }
43
44 QStringList names() const;
45
46 void setValueName(const QString &name);
47 QString valueName() const;
48
49 void setDescription(const QString &description);
50 QString description() const;
51
52 void setDefaultValue(const QString &defaultValue);
53 void setDefaultValues(const QStringList &defaultValues);
54 QStringList defaultValues() const;
55
56 Flags flags() const;
57 void setFlags(Flags aflags);
58
59private:
60 QSharedDataPointer<QCommandLineOptionPrivate> d;
61};
62
63Q_DECLARE_SHARED(QCommandLineOption)
64Q_DECLARE_OPERATORS_FOR_FLAGS(QCommandLineOption::Flags)
65
66
67QT_END_NAMESPACE
68
69#endif // QCOMMANDLINEOPTION_H
70

source code of qtbase/src/corelib/tools/qcommandlineoption.h