SHORE API
|
Command line option parser. More...
Classes | |
struct | usage_error |
Thrown to indicate a mistake by the user, to trigger displaying the usage page. More... | |
Public Types | |
enum | SummaryType { SUMMARY_STD, SUMMARY_COMPACT, SUMMARY_VERBOSE } |
Public Member Functions | |
void | set_posixly_correct (const bool p) |
Set whether to run getopt as POSIXLY_CORRECT. | |
std::string | set_optiongroup (const std::string &grp=std::string()) |
Set the group that new options are added to; returns the old group. | |
template<class T > | |
void | add_option (const std::string &longshort, T *target, const std::string &info, const std::string &aux_info=std::string()) |
Add a new command line option. | |
template<class T > | |
void | add_option (const std::string &longshort, T *target, const std::string &info, const OptionFlags def, const std::string &aux_info=std::string()) |
Add a new command line option. | |
template<class T > | |
void | add_option (const std::string &longshort, const std::string &conflicts_with, T *target, const std::string &info, const std::string &aux_info=std::string()) |
Add a new command line option. | |
template<class T > | |
void | add_option (const std::string &longshort, const std::string &conflicts_with, T *target, const std::string &info, const OptionFlags def, const std::string &aux_info=std::string()) |
Add a new command line option. | |
template<typename T > | |
void | add_residualargs (T *const target, const std::string &name, const OptionFlags def) |
Add non-option arguments. | |
template<typename T > | |
void | add_residualargs (T *const target, const std::string &name, const std::string &conflicts_with=std::string(), const OptionFlags def=OPT_NOTSET, typename boost::disable_if< boost::is_const< T > >::type *dummy=0) |
Add non-option arguments. | |
void | add_residualargs (const std::string &opt_id, const std::string &name) |
Add non-option arguments that are equivalent to some other option. | |
bool | allows_options () const |
Test if the parser has some options set up. | |
bool | allows_residualargs () const |
Test if the parser has some non-option arguments set up. | |
bool | have_aux_info () const |
Test if the parser has any option with auxiliary description. | |
void | operator() (int ac, char *av[]) |
Parsing function. | |
void | parse_conffile (const std::string &fn, const std::string §ion, const std::set< std::string > &noinclude=std::set< std::string >()) |
Parsing a configuration file. | |
void | dependency_check () |
Check parsed options for conflicts (automatically called by operator()). | |
int | get_argc () const |
Get the original number of cmd line arguments. | |
char ** | get_argv () const |
Get original pointer to the cmd line arguments. | |
int | get_residual_argc () const |
Get the number of remaining cmd line arguments. | |
char ** | get_residual_argv () const |
Get pointer to the remaining cmd line arguments. | |
bool | is_altered (const void *const ptr) const |
Test if the variable at the given address was altered by a cmd line option argument. | |
void | set_altered (const void *const ptr) |
size_t | num_altered () const |
Number of options provided on the cmd line. | |
std::string | get_optionsummary (const SummaryType typ=SUMMARY_STD) const |
Get a summary page of available command line options. | |
std::string | get_usagestring () const |
Get the short summary of the program usage. | |
Command line option parser.
This is the parser used by the program base class.