21 int main(
int argc,
char** argv)
23 using namespace limbo;
30 std::vector<int> vInteger;
31 std::vector<std::string> vString;
34 po.
add_option(
Value<bool>(
"-help", &help,
"print help message").toggle(
true).default_value(
false).toggle_value(
true).help(
true))
38 .
add_option(
Value<std::vector<int> >(
"-vi", &vInteger,
"vector of integers"))
39 .
add_option(
Value<std::vector<std::string> >(
"-vs", &vString,
"vector of string"))
45 bool flag = po.
parse(argc, argv);
47 cout <<
"parsing succeeded\n";
49 catch (std::exception& e)
51 cout <<
"parsing failed\n";
52 cout << e.what() <<
"\n";
55 cout <<
"help = " << ((help)?
"true" :
"false") << endl;
56 cout <<
"i = " << i << endl;
57 cout <<
"fp = " << fp << endl;
58 cout <<
"str = " << str << endl;
59 cout <<
"vInteger = ";
60 for (std::vector<int>::const_iterator it = vInteger.begin(); it != vInteger.end(); ++it)
64 for (std::vector<std::string>::const_iterator it = vString.begin(); it != vString.end(); ++it)
68 assert_msg(help ==
false,
"help turned to true");
Top API for Limbo.ProgramOptions.
int main(int argc, char **argv)
test usage of program options, such as help, boolean, integer, floating point number, and vector
ProgramOptions & add_option(ValueType const &data)
generic API to add options of various data types
a generic class for various data values
top API to parse program options
void print() const
print help message
bool parse(int argc, char **argv)
read command line options
#define assert_msg(condition, message)
assertion with message
namespace for Limbo.ProgramOptions