2016-08-28 15:10:43 +02:00
|
|
|
#include "commandline/IntOption.h"
|
|
|
|
#include "commandline/Parser.h"
|
|
|
|
|
|
|
|
using namespace commandline;
|
|
|
|
|
|
|
|
int IntOption::getInt(Parser &parser, bool *ok, int base)
|
|
|
|
{
|
2017-02-11 22:52:47 +01:00
|
|
|
_int = value(parser).toInt(ok, base);
|
2021-11-29 18:51:03 +01:00
|
|
|
|
2017-02-11 22:52:47 +01:00
|
|
|
return _int;
|
2016-08-28 15:10:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int *IntOption::getIntPtr(Parser &parser, bool *ok, int base)
|
|
|
|
{
|
2017-02-11 22:52:47 +01:00
|
|
|
if (parser.isSet(this))
|
|
|
|
{
|
|
|
|
getInt(parser, ok, base);
|
|
|
|
return &_int;
|
|
|
|
}
|
|
|
|
return nullptr;
|
2016-08-28 15:10:43 +02:00
|
|
|
}
|
2021-11-29 18:51:03 +01:00
|
|
|
|
|
|
|
bool IntOption::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;
|
|
|
|
}
|