ArgumentList 0.2
In version 0.1 of my ArgumentList there was an annoying problem, that is if we want to extract a parameter from command line that wasn’t a string, we had to write a converter by ourselves.
To solve this issue I modified the getSwitchArgument() method in order to accept a type as a template parameter. I hope this modification can simplify the use of the class.
So now, if we suppose to have something like that in our command line:
some-executable -i 10 -f 0.004
what we have to write in our code, in order to get the numerical values “10″ and “0.004″ is the following:
int i(0);
float f(0.0);
i = args.getSwitchArgument< int >("-i");
f = args.getSwitchArgument< float >("-f");
So right now, to have a string argument like before, it is necessary to pass the string parameter to the template, like in the following example:
string tempString;
tempString = args.getSwitchArgument< std::string >("-s");
An example is presented in the test directory included with the package. CMake is needed to build the package.
ArgumentList 0.2 can be downloaded here.
Related posts: