![]() |
|||
|
ParamContainer Download ParamContainer
ParamContainer is simple and easy to use C++ class to parse command line
parameters. Parameters format are derived from UNIX getopt_long() function
syntax but may contain nested parameters as well. It was developed to fit
requirenments of our projects, but we'll be glad if it will be useful for
somebody else. Main features of ParamContainer are:
* Easy to use
* Structure of command line conforms object hierarchy.
* Adding/changing parameters is really easy. You don't need to modify class
interfaces and anything outside of the class which new parameter
corresponds to.
* Parameters can be saved to the project file and loaded later.
* When command line contains additional file names, they paths will be
converted to relative in project file, so you can freely move project with
all required files to the different location.
* ParamContainer can be used as internal interface between presentation
(GUI) and logic parts of the project. You can use the same logic part in
graphics/command-line versions of your project.
* Dynamically generated help screen
* Powerful error handling
* Portability between Win32 and Unix systems (on Win32 systems there must
be WIN32 preprocessor definition).
Quick start
===========
Here is the simple way to use ParamContainer in your project:
* Add ParamContainer.cpp and ParamContainer.h into project
* Include ParamContainer.h in your main cpp file:
#include "ParamContainer.h"
* Create ParamContainer object in your main() function
ParamContainer p;
* Add some parameters using addParam()
p.addParam("long-name", 'n', ParamContainer::regular,
"parameter description", "default_value");
//"long-name" - long parameter name
//'n' - short parameter name
//ParamContainer::regular - parameter type
// (regular means that parameter is not required and has an argument)
//"parameter description" - description
//"default_value" - default value
* call parseCommandLine()
p.parseCommandLine(argc, argv[]);
* obtain parameter values via []
cout << p["long-name"];
* compile and run your program, specifying your argument:
programname --long-name=value
or
programname -n value
or
programname -n "value"
Download ParamContainer
For bug reports and comments - contact us |
|
||
|
|
|||