20 #ifndef OPTIONPARSER_H
21 #define OPTIONPARSER_H
24 #include <QStringList>
160 void addSwitch(
const QString &lname,
bool *b );
168 void addOption(
char s,
const QString &l, QString *v );
190 void addVarLengthOption(
const QString &l, QStringList *v );
214 void addRepeatableOption(
char s, QStringList *v );
222 void addRepeatableOption(
const QString &l, QStringList *v );
238 void addOptionalOption(
const QString &l, QString *v,
const QString &def );
244 void addOptionalOption(
char s,
const QString &l, QString *v,
const QString &def );
272 void addArgument(
const QString &name, QString *v );
279 void addOptionalArgument(
const QString &name, QString *v );
282 bool parse(
bool untilFirstSwitchOnly );
305 bool isSet(
const QString &name )
const;
308 int currentArgument()
const {
return currArg; }
311 enum OptionType { OUnknown, OEnd, OSwitch, OArg1, OOpt, ORepeat, OVarLen };
314 friend struct Option;
317 Option( OptionType t = OUnknown,
318 char s = 0,
const QString &l = QString::null )
329 QString *stringValue;
330 QStringList *listValue;
335 QList<Option> options;
336 typedef QList<Option>::const_iterator OptionConstIterator;
337 QMap<QString, int> setOptions;
339 void init(
int argc,
char *argv[],
int offset = 1 );
340 void addOption( Option o );
341 void setSwitch(
const Option &o );