PDA

View Full Version : Module to process application parameters



Opilki_Inside
6th April 2006, 09:21
Hello!

Has anyone a module to procees application parameters?

For example, my application run with this parameters:
myapp -h127.0.0.1 -Uusername mydb

I need to recognize parameters and values. I can write my own module, but I think sombody already done it.

wysota
6th April 2006, 10:15
1. man getopt (and look at getopt_long)

2. GetOpt class (http://www.froglogic.com/pg?id=PublicationsFreeware&category=getopt)

KShots
7th February 2007, 06:22
1 is all good and well if you're writing specifically for unix.

2 is Ok if you're writing a GUI application or an application that requires an event loop.

Neither is acceptable if you're writing a simple server application that wants to parse the command line on startup and doesn't want the huge footprint of Qt's event loop or GUI.

Has somebody written something like this yet?

wysota
7th February 2007, 10:30
I assure you the getopt class from Froglogic doesn't require an event loop... Moreover you can substitute Qt calls with STL calls and you'll strip the Qt dependency.

For Windows you can use this:
http://www.codeproject.com/cpp/xgetopt.asp

3dch
9th February 2007, 00:26
Maybe have a look at these libs:

http://argtable.sourceforge.net/
http://www.codeproject.com/cpp/ccmdline.asp
http://teem.sourceforge.net/hest/index.html