|
Introduction
GetOpt_pp intro.
Construct a GetOpt_pp object by passing the argc and argv params to its constructor. The GetOpt_pp object will behave as an istream. The data can be extracted using some manipulators, the simplest being Option. int main(int argc, char* argv[])
{
GetOpt_pp args(argc, argv);
int ret;
args >> Option('i', "long_option", ret);
return ret;
}In the example above, either the option '-i' (short form) or "--long_option" (long form) is read from the arguments. That means that the program can be invoked in any of the following forms:
Quick Notes:
For example: g++ example_helloworld.cpp getopt_pp.cpp -o example_helloworld // Next: Basic Usage Back to Table Of Contents |
► Sign in to add a comment
getopt_pp.h, applied following patch to avoid a compilation warning
111c111 < : short_opt(other.short_opt), long_opt(other.long_opt), target(other.target) --- > : Option( other ), short_opt(other.short_opt), long_opt(other.long_opt), target(other.target)
Thanks, what compiler did you use? g++ 4.4.1 doesn't complain. Anyway, I'm adding a similar change in order to suppress such warning, whatever compiler it is. (I invoke the default constructor of the base class, rather than the copy ctor). Please test the committed version in the repository.