#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 idm46613508658448; /* Top level option list */ /* OPTION: square */ typedef x::option::bool_value square_t; square_t square; /* CONSTRUCTOR */ options(const x::messagesptr &msgcat=x::messagesptr()) : idm46613508658448(x::option::list::create()), square(square_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) { idm46613508658448->add_option(square, "s", getoptmsg(msgcat, N_("square")), 0, getoptmsg(msgcat, N_("Use a square border for the splash window"))); idm46613508658448->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(idm46613508658448); 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. */ } };