19 int main(
int argc,
char** argv)
24 std::vector<int> vInteger;
28 po_type desc (
"My options");
30 desc.add_option(Value<bool>(
"-help", &help,
"print help message").toggle(
true).default_value(
false).toggle_value(
true).help(
true))
31 .add_option(Value<int>(
"-i", &i,
"an integer").default_value(100,
"1.0.0"))
32 .add_option(Value<double>(
"-f", &fp,
"a floating point").required(
true))
33 .add_option(Value<std::vector<int> >(
"-vi", &vInteger,
"vector of integers"))
38 bool flag = desc.parse(argc, argv);
40 std::cout <<
"parsing succeeded\n";
42 catch (std::exception& e)
44 std::cout <<
"parsing failed\n";
45 std::cout << e.what() <<
"\n";
51 std::cout << desc <<
"\n";
55 std::cout <<
"help = " << ((help)?
"true" :
"false") << std::endl;
56 std::cout <<
"i = " << i << std::endl;
57 std::cout <<
"fp = " << fp << std::endl;
58 std::cout <<
"vInteger = ";
59 for (std::vector<int>::const_iterator it = vInteger.begin(); it != vInteger.end(); ++it)
60 std::cout << *it <<
" ";
61 std::cout << std::endl;
Top API for Limbo.ProgramOptions.
int main(int argc, char **argv)
test simple usage of program options, such as help, boolean, integer, floating point number...
a generic class for various data values
top API to parse program options