2016-08-28 15:10:43 +02:00
|
|
|
#include "commandline/DoubleOption.h"
|
|
|
|
#include "commandline/Parser.h"
|
|
|
|
|
|
|
|
using namespace commandline;
|
|
|
|
|
|
|
|
double DoubleOption::getDouble(Parser &parser, bool *ok)
|
|
|
|
{
|
2017-02-11 22:52:47 +01:00
|
|
|
_double = value(parser).toDouble(ok);
|
|
|
|
return _double;
|
2016-08-28 15:10:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
double *DoubleOption::getDoublePtr(Parser &parser, bool *ok)
|
|
|
|
{
|
2017-02-11 22:52:47 +01:00
|
|
|
if (parser.isSet(this))
|
|
|
|
{
|
|
|
|
getDouble(parser, ok);
|
|
|
|
return &_double;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
2016-08-28 15:10:43 +02:00
|
|
|
}
|
2021-11-29 18:51:03 +01:00
|
|
|
|
|
|
|
bool DoubleOption::validate(Parser & parser, QString & value)
|
|
|
|
{
|
|
|
|
if (ValidatorOption::validate(parser,value))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
_error = QString("Value must be between %1 and %2.").arg(_minimum).arg(_maximum);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|