I am looking for a command line parser for Qt4.
I did a small google search, and found this: http://www.froglogic.com/pg?id=PublicationsFreeware&category=getopt however it lacks support for "--enable-foo" and "--disable-foo" switches. Besides that, it looks like a real winner.
EDIT:
It seems Frologic removed this. So the best options I see are using Boost (which is not API nor ABI stable) or forking the support for kdelibs. Yay...
It's 2013 and still no "1st party" arg parser. Anyways..if anyone finds themselves facing the same problem and would like to avoid the learning curves that come with cmd parser libs, here is a "quick & dirty" fix for you:-
Example:-
Usage:
Params can be passed in any order
Edit: Updates to this snippet will be found here
There is also QxtCommandOptions from http://www.libqxt.org/
A really simple method is to scan "key=value" args,
put them in a table say zz.map: QString -> QVariant,
and get their values with zz.map.value( key, default ). An example:
ztest.h
is < 1 page, below; same for Python ~ 10 lines.(Everybody has his/her favorite options parser; this one's about the simplest.
Worth repeating: however you specify options, echo them to output files --
"every scientist I know has trouble keeping track of what parameters they used last time they ran a script".)
To make QPoints etc work one of course needs a QString -> QPoint parser. Anyone know offhand why this doesn't work (in Qt 4.4.3) ?
Added 25nov --
That package does support --disable-foo and --enable-foo via opts.addSwitch("disable-foo", &foo_disabled); and opts.addSwitch("enable-foo", &foo_enabled);. You need handle checking both, and dealing with someone specifying both (oops).
What I don't understand is how this has anything to do with QT4...
Also for some fancy options parsing you can try gperf.
IBM has a nice tutorial on it.
Another option I ran across while looking to do this, too:
http://code.google.com/p/qgetopts/
I haven't used it though.