4 #include <qapplication.h>
19 void Option::set(const QString &n, const OptionType &t, const QString &s, const QString &l)
27 QString Option::getName () { return name; }
28 QString Option::getShort () { return sName; }
29 QString Option::getLong() { return lName; }
30 OptionType Option::getType() { return type; }
31 void Option::setArg(const QString& s) { sarg=s; }
32 QString Option::getArg() { return sarg; }
33 void Option::setActive() { active=true; }
34 bool Option::isActive() { return active; }
36 ///////////////////////////////////////////////////////////////
43 while (i<qApp->argc())
45 arglist.append (qApp->argv()[i]);
50 progname=arglist.first();
53 // Work through rest of options
55 OptionList::iterator itopt;
56 QStringList::iterator itarg;
57 itarg=arglist.begin();
58 while (itarg!=arglist.end())
61 if ((*itarg).left(1)=="-")
63 // Compare given option to all defined options
64 itopt=optlist.begin();
65 while (itopt!=optlist.end())
67 if ((*itarg)==(*itopt).getShort() ||
68 (*itarg)==(*itopt).getLong())
72 if ((*itopt).getType()==StringOption)
75 if (itarg==arglist.end())
77 cout << "Error: argument to option missing\n";
80 (*itopt).setArg (*itarg);
89 qWarning("Error: Unknown argument ");
93 filelist.append (*itarg);
99 void Options::add (const QString &n, const OptionType &t=SwitchOption, const QString &s="", const QString &l="")
106 void Options::setHelpText (const QString &s)
111 QString Options::getHelpText ()
116 QString Options::getProgramName()
121 QStringList Options::getFileList ()
126 bool Options::isOn(const QString &s)
128 OptionList::iterator it;
129 for ( it = optlist.begin(); it != optlist.end(); ++it )
130 if ((*it).getName()==s && (*it).isActive() )
135 QString Options::getArg(const QString &s)
137 OptionList::iterator it;
138 for ( it = optlist.begin(); it != optlist.end(); ++it )
140 if ((*it).getName()==s)
141 return (*it).getArg();