2017-03-04 22:17:42 +01:00
|
|
|
#pragma once
|
2016-08-28 15:10:43 +02:00
|
|
|
|
|
|
|
#include <QCommandLineOption>
|
|
|
|
#include <QCommandLineParser>
|
|
|
|
|
|
|
|
namespace commandline
|
|
|
|
{
|
|
|
|
|
|
|
|
class Parser;
|
|
|
|
|
|
|
|
/* Note, this class and all it's derivatives store the validated results for caching. This means that unlike the
|
|
|
|
* regular QCommandLineOption it is _not_ idempotent! */
|
|
|
|
class Option: public QCommandLineOption
|
|
|
|
{
|
|
|
|
public:
|
2017-03-04 22:17:42 +01:00
|
|
|
Option(const QString &name,
|
|
|
|
const QString &description = QString(),
|
2019-07-10 10:24:40 +02:00
|
|
|
const QString &valueName = QString(),
|
2017-03-04 22:17:42 +01:00
|
|
|
const QString &defaultValue = QString()
|
|
|
|
);
|
|
|
|
|
|
|
|
Option(const QStringList &names,
|
|
|
|
const QString &description = QString(),
|
2019-07-10 10:24:40 +02:00
|
|
|
const QString &valueName = QString(),
|
2017-03-04 22:17:42 +01:00
|
|
|
const QString &defaultValue = QString()
|
|
|
|
);
|
|
|
|
|
|
|
|
Option(const QCommandLineOption &other);
|
|
|
|
|
|
|
|
virtual bool validate(Parser &parser, QString &value);
|
2020-08-08 23:12:43 +02:00
|
|
|
QString name() const;
|
|
|
|
QString getError() const;
|
|
|
|
QString value(Parser &parser) const;
|
|
|
|
const char* getCString(Parser &parser) const;
|
2017-03-04 22:17:42 +01:00
|
|
|
|
2020-11-14 17:58:56 +01:00
|
|
|
virtual ~Option();
|
|
|
|
|
2017-03-04 22:17:42 +01:00
|
|
|
protected:
|
|
|
|
QString _error;
|
2016-08-28 15:10:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|