added supporto for non variant arguments

This commit is contained in:
Federico Ponchio 2014-02-12 15:19:43 +00:00
parent 57880ef231
commit d45132e06b
2 changed files with 39 additions and 5 deletions

View File

@ -69,12 +69,40 @@ void GetOpt::addOption(char s, const QString &name, const QString &description,
//add an argument
void GetOpt::addArgument(const QString &name, const QString &description, QVariant *v) {
Option option;
assert(!findArg(name, option));
option.type = Option::ARGUMENT;
option.name = name;
option.description = description;
option.value = v;
options.push_back(option);
addArgument(name, description, option);
}
void GetOpt::addArgument(const QString &name, const QString &description, QString *v) {
Option option;
option.string_value = v;
addArgument(name, description, option);
}
void GetOpt::addArgument(const QString &name, const QString &description, double *v) {
Option option;
option.double_value = v;
addArgument(name, description, option);
}
void GetOpt::addArgument(const QString &name, const QString &description, int *v) {
Option option;
option.int_value = v;
addArgument(name, description, option);
}
void GetOpt::addArgument(const QString &name, const QString &description, bool *v) {
Option option;
option.boolean_value = v;
addArgument(name, description, option);
}
void GetOpt::addArgument(const QString &name, const QString &description, Option option) {
assert(!findArg(name, option));
option.type = Option::ARGUMENT;
option.name = name;
option.description = description;
options.push_back(option);
}
void GetOpt::addOption(char s, const QString &longname, const QString &description, QString *v) {

View File

@ -89,6 +89,11 @@ 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, double *v);
void addArgument(const QString &name, const QString &description, int *v);
void addArgument(const QString &name, const QString &description, bool *v);
void addArgument(const QString &name, const QString &description, Option option);
//add an optional agrument
void addOptionalArgument(const QString &name, const QString &description, QVariant *v);
@ -120,3 +125,4 @@ class GetOpt {
};
#endif