#include #include #include #ifndef N_ #define N_(x) x #endif #ifndef NN_ #define NN_(s, p) s, p #endif class options { public: x::option::list idm46296220378384; /* Top level option list */ /* OPTION: horizontal */ typedef x::option::bool_value horizontal_t; horizontal_t horizontal; /* CONSTRUCTOR */ options(const x::messagesptr &msgcat=x::messagesptr()) : idm46296220378384(x::option::list::create()), horizontal(horizontal_t::create()) { init(msgcat); } static std::string getoptmsg(const x::messagesptr &msgcat, const char *str) { return (!msgcat.null() ? msgcat->get(str):str); } template static std::string getoptmsg(const x::messagesptr &msgcat, const char *singular, const char *plural, int_type value) { return (!msgcat.null() ? msgcat->get(singular, plural, value): value == 1 ? singular:plural); } void init(const x::messagesptr &msgcat) { idm46296220378384->add_option(horizontal, "h", getoptmsg(msgcat, N_("horizontal")), 0, getoptmsg(msgcat, N_("Create a horizontal pane"))); idm46296220378384->addDefaultOptions(); } /* Construct a parser object */ x::option::parser getParser(const x::const_locale &localeArg=x::locale::base::environment()) { x::option::parser parser(x::option::parser::create(localeArg)); parser->setOptions(idm46296220378384); return parser; } /* Parse argc/argv as received by main(), return parser object */ x::option::parser parse(int argc, char **argv, const x::const_locale &localeArg =x::locale::base::environment()) { x::option::parser parser=getParser(localeArg); int err=parser->parseArgv(argc, argv); if (err == 0) err=parser->validate(); if (err) { if (err == x::option::parser::base::err_builtin) exit(0); std::cerr << parser->errmessage(); std::cerr.flush(); exit(1); } return parser; /* Retrieve parser->args, if desired. */ } };