2016-08-28 15:10:43 +02:00
|
|
|
#include "commandline/Option.h"
|
|
|
|
#include "commandline/Parser.h"
|
|
|
|
|
|
|
|
using namespace commandline;
|
|
|
|
|
2017-03-04 22:17:42 +01:00
|
|
|
Option::Option(const QString &name, const QString &description, const QString &valueName, const QString &defaultValue)
|
|
|
|
: QCommandLineOption(name, description, valueName, defaultValue)
|
|
|
|
{}
|
|
|
|
|
|
|
|
Option::Option(const QStringList &names, const QString &description, const QString &valueName, const QString &defaultValue)
|
|
|
|
: QCommandLineOption(names, description, valueName, defaultValue)
|
|
|
|
{}
|
|
|
|
|
2016-08-28 15:10:43 +02:00
|
|
|
bool Option::validate(Parser & parser, QString &value)
|
|
|
|
{
|
|
|
|
/* By default everything is accepted */
|
2017-02-11 22:52:47 +01:00
|
|
|
return true;
|
2016-08-28 15:10:43 +02:00
|
|
|
}
|
|
|
|
|
2017-03-04 22:17:42 +01:00
|
|
|
Option::Option(const QCommandLineOption &other)
|
|
|
|
: QCommandLineOption(other)
|
|
|
|
{}
|
|
|
|
|
2020-08-08 23:12:43 +02:00
|
|
|
QString Option::value(Parser &parser) const
|
2016-08-28 15:10:43 +02:00
|
|
|
{
|
2017-02-11 22:52:47 +01:00
|
|
|
return parser.value(*this);
|
2016-08-28 15:10:43 +02:00
|
|
|
}
|
|
|
|
|
2020-08-08 23:12:43 +02:00
|
|
|
QString Option::name() const
|
2016-08-28 15:10:43 +02:00
|
|
|
{
|
2017-03-04 22:17:42 +01:00
|
|
|
return this->names().last();
|
2016-08-28 15:10:43 +02:00
|
|
|
}
|
|
|
|
|
2020-08-08 23:12:43 +02:00
|
|
|
QString Option::getError() const
|
2016-08-28 15:10:43 +02:00
|
|
|
{
|
2017-03-04 22:17:42 +01:00
|
|
|
return this->_error;
|
2016-08-28 15:10:43 +02:00
|
|
|
}
|
|
|
|
|
2020-08-08 23:12:43 +02:00
|
|
|
const char* Option::getCString(Parser &parser) const
|
2016-09-17 00:40:29 +02:00
|
|
|
{
|
2017-02-11 22:52:47 +01:00
|
|
|
return value(parser).toLocal8Bit().constData();
|
2016-09-17 00:40:29 +02:00
|
|
|
}
|