Inheritance diagram for option_group_t:
Manages a set of options.
An option group has a classification hierarchy associated with it. Each level of the hierarchy is given a string name. Levels are added with add_class_level(). The levels are used when looking up an option with lookup_by_class(). The level hierarchy is printed in the form: "level1.level2.level3." A complete option name is specified by "level1.level2.level3.optionName:". A convention for level names is: programtype.programname where programtype is indicates the general type of the program and programname is the file name of the program.
Definition at line 228 of file option.h.
Public Member Functions | |
NORET | option_group_t (int max_class_levels) |
NORET | ~option_group_t () |
w_rc_t | add_class_level (const char *name) |
w_rc_t | add_option (const char *name, const char *possible_values, const char *default_value, const char *description, bool required, option_t::OptionSetFunc set_func, option_t *&new_opt, ostream *err_stream=&cerr) |
Add an option to this group. | |
w_rc_t | lookup (const char *name, bool exact, option_t *&ret) |
Look up an option by name. | |
w_rc_t | lookup_by_class (const char *opt_class_name, option_t *&ret, bool exact=false) |
Look up option by class name and option name. | |
w_rc_t | set_value (const char *name, bool exact, const char *value, bool overRide, ostream *err_stream) |
Set a value of an option identified by a class name and option name. | |
void | print_usage (bool longForm, ostream &err_stream) |
Print the descriptive information to the given stream. | |
void | print_values (bool longForm, ostream &err_stream) |
Print the descriptive information to the given stream. | |
w_rc_t | check_required (ostream *err_stream) |
Check that all required options are set. | |
w_rc_t | parse_command_line (const char **argv, int &argc, size_t min_len, ostream *err_stream) |
Search the command line for options, set, remove from argv,argc. | |
w_list_t< option_t, unsafe_list_dummy_lock_t > & | option_list () |
Return a list of the options in the group. | |
int | num_class_levels () |
Number of levels in the class names. | |
const char * | class_name () |
The complete option class name. |
w_rc_t option_group_t::add_option | ( | const char * | name, | |
const char * | possible_values, | |||
const char * | default_value, | |||
const char * | description, | |||
bool | required, | |||
option_t::OptionSetFunc | set_func, | |||
option_t *& | new_opt, | |||
ostream * | err_stream = &cerr | |||
) |
Add an option to this group.
[in] | name | Name of option. |
[in] | possible_values | String for printing "help" information. |
[in] | default_value | Default value or NULL. |
[in] | description | Description of the options's purpose. |
[in] | required | User must provide a value if "true". |
[in] | set_func | Callback used during file- or command-line- scanning to set the option value; this is needed because the options are typed. Possible callback functions include several provided here, described below. |
[out] | new_opt | The option_t created by this method is returned here. |
[in] | err_stream | Errors encountered during processing will cause messages to be sent here. |
Definition at line 383 of file option.cpp.
References w_list_t< T, LOCK >::append(), option_t::init(), w_rc_t::is_error(), lookup(), RC, RCOK, and W_DO.
Here is the call graph for this function:
Look up an option by name.
[in] | name | Name of option. |
[in] | exact | name is not an abbreviation. |
[out] | ret | Populate the given pointer if found. |
Definition at line 427 of file option.cpp.
References w_list_i< T, LOCK >::curr(), option_t::match(), option_t::name(), w_list_i< T, LOCK >::next(), and RC.
Referenced by add_option(), lookup_by_class(), parse_command_line(), and set_value().
Here is the call graph for this function:
Here is the caller graph for this function:
w_rc_t option_group_t::lookup_by_class | ( | const char * | opt_class_name, | |
option_t *& | ret, | |||
bool | exact = false | |||
) |
Look up option by class name and option name.
[in] | opt_class_name | is a string of the form level1.level2.optionname. A "?" can be used as a wild card for any single level name. A "*" can be used as a wild card for any number of level names. |
[out] | ret | Pass in an option_t* and it will be filled in if found. |
[in] | exact | opt_class_name is not an abbreviation. |
Definition at line 456 of file option.cpp.
References w_rc_t::is_error(), lookup(), and RC.
Referenced by option_stream_scan_t::scan().
Here is the call graph for this function:
Here is the caller graph for this function:
w_rc_t option_group_t::set_value | ( | const char * | name, | |
bool | exact, | |||
const char * | value, | |||
bool | overRide, | |||
ostream * | err_stream | |||
) |
Set a value of an option identified by a class name and option name.
Set the value of an option if it is not already set or if overRide is true.
[in] | name | is a string of the form level1.level2.optionname. |
[in] | exact | name is not an abbreviation. |
[in] | value | is a string form of the value to give the option; a value of NULL indicates un-set. |
[in] | overRide | allows the value to be overwritten. |
[in] | err_stream,: | error messages will be sent to err_stream if non-null. |
Definition at line 580 of file option.cpp.
References lookup(), RC, RCOK, option_t::set_value(), and W_DO.
Here is the call graph for this function:
w_rc_t option_group_t::check_required | ( | ostream * | err_stream | ) |
Check that all required options are set.
Return OPTERR_NotSet if any are not. Print information about each unset option to err_stream
Definition at line 666 of file option.cpp.
References option_t::is_required(), option_t::is_set(), option_t::name(), w_list_i< T, LOCK >::next(), and RC.
Here is the call graph for this function:
w_rc_t option_group_t::parse_command_line | ( | const char ** | argv, | |
int & | argc, | |||
size_t | min_len, | |||
ostream * | err_stream | |||
) |
Search the command line for options, set, remove from argv,argc.
[in] | argv | The command line to search. |
[in] | argc | Number of entries in argv[]. |
[in] | min_len | Don't process argv entries shorter than this. |
[out] | err_stream | Send error message here if non-NULL. |
Definition at line 684 of file option.cpp.
References w_rc_t::is_error(), lookup(), RC, and option_t::set_value().
Here is the call graph for this function: