added float parameters
This commit is contained in:
parent
fffd61bbed
commit
7f6288ed16
|
@ -79,6 +79,12 @@ void GetOpt::addArgument(const QString &name, const QString &description, QStrin
|
|||
addArgument(name, description, option);
|
||||
}
|
||||
|
||||
void GetOpt::addArgument(const QString &name, const QString &description, float *v) {
|
||||
Option option;
|
||||
option.float_value = v;
|
||||
addArgument(name, description, option);
|
||||
}
|
||||
|
||||
void GetOpt::addArgument(const QString &name, const QString &description, double *v) {
|
||||
Option option;
|
||||
option.double_value = v;
|
||||
|
@ -110,6 +116,11 @@ void GetOpt::addOption(char s, const QString &longname, const QString &descripti
|
|||
option.string_value = v;
|
||||
options.push_back(option);
|
||||
}
|
||||
void GetOpt::addOption(char s, const QString &longname, const QString &description, float *v) {
|
||||
Option option(Option::OPTION, s, longname, description);
|
||||
option.float_value = v;
|
||||
options.push_back(option);
|
||||
}
|
||||
void GetOpt::addOption(char s, const QString &longname, const QString &description, double *v) {
|
||||
Option option(Option::OPTION, s, longname, description);
|
||||
option.double_value = v;
|
||||
|
@ -217,6 +228,7 @@ bool GetOpt::assignOption(Option &o, QString arg, QString &error) {
|
|||
QVariant::Type type;
|
||||
if(o.value) type = o.value->type();
|
||||
if(o.string_value) type = QVariant::String;
|
||||
if(o.float_value) type = QVariant::Double;
|
||||
if(o.double_value) type = QVariant::Double;
|
||||
if(o.int_value) type = QVariant::Int;
|
||||
if(o.boolean_value) type = QVariant::Bool;
|
||||
|
@ -229,7 +241,8 @@ bool GetOpt::assignOption(Option &o, QString arg, QString &error) {
|
|||
}
|
||||
if(o.value) *(o.value) = v;
|
||||
if(o.string_value) *(o.string_value) = v.toString();
|
||||
if(o.double_value) *(o.double_value) = v.toDouble();
|
||||
if(o.float_value) *(o.float_value) = v.toFloat();
|
||||
if(o.double_value) *(o.double_value) = v.toDouble();
|
||||
if(o.int_value) *(o.int_value) = v.toInt();
|
||||
if(o.boolean_value) *(o.boolean_value) = v.toBool();
|
||||
return true;
|
||||
|
|
|
@ -53,14 +53,15 @@ class GetOpt {
|
|||
QString description;
|
||||
QVariant *value;
|
||||
QString *string_value;
|
||||
float *float_value;
|
||||
double *double_value;
|
||||
int *int_value;
|
||||
bool *boolean_value;
|
||||
|
||||
Option(): value(NULL), string_value(NULL), double_value(NULL), int_value(NULL), boolean_value(NULL) {}
|
||||
Option(): value(NULL), string_value(NULL), float_value(NULL), double_value(NULL), int_value(NULL), boolean_value(NULL) {}
|
||||
Option(Type _type, char _o, QString _name, QString _descr):
|
||||
type(_type), o(_o), name(_name), description(_descr),
|
||||
value(NULL), string_value(NULL), double_value(NULL), int_value(NULL), boolean_value(NULL) {}
|
||||
value(NULL), string_value(NULL), float_value(NULL), double_value(NULL), int_value(NULL), boolean_value(NULL) {}
|
||||
};
|
||||
|
||||
bool unlimitedArgs;
|
||||
|
@ -82,6 +83,7 @@ class GetOpt {
|
|||
//add a valued option (v will be left untouched if the option is not given)
|
||||
void addOption(char s, const QString &longname, const QString &description, QVariant *v);
|
||||
void addOption(char s, const QString &longname, const QString &description, QString *v);
|
||||
void addOption(char s, const QString &longname, const QString &description, float *v);
|
||||
void addOption(char s, const QString &longname, const QString &description, double *v);
|
||||
void addOption(char s, const QString &longname, const QString &description, int *v);
|
||||
void addOption(char s, const QString &longname, const QString &description, bool *v);
|
||||
|
@ -90,6 +92,7 @@ class GetOpt {
|
|||
//add an argument
|
||||
void addArgument(const QString &name, const QString &description, QVariant *v);
|
||||
void addArgument(const QString &name, const QString &description, QString *v);
|
||||
void addArgument(const QString &name, const QString &description, float *v);
|
||||
void addArgument(const QString &name, const QString &description, double *v);
|
||||
void addArgument(const QString &name, const QString &description, int *v);
|
||||
void addArgument(const QString &name, const QString &description, bool *v);
|
||||
|
|
Loading…
Reference in New Issue