option_group_t Class Reference
[Run-Time Options]

Inherits w_base_t.

Inheritance diagram for option_group_t:

Inheritance graph
[legend]
Collaboration diagram for option_group_t:

Collaboration graph
[legend]
List of all members.

Detailed Description

Group of option_t. See Run-Time Options.

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.

Examples:

create_rec.cpp, init_config_options.cpp, log_exceed.cpp, sort_stream.cpp, startstop.cpp, and vtable_example.cpp.

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.


Member Function Documentation

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.

Parameters:
[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.
Creates an option_t and adds it to this group. The set_func parameter indicates what callback function to call when the option is set. Write your own or use one of these functions from option_t:
Examples:
create_rec.cpp, log_exceed.cpp, sort_stream.cpp, and vtable_example.cpp.

Definition at line 380 of file option.cpp.

References w_list_t< T, LOCK >::append(), DBG, option_t::init(), w_rc_t::is_error(), lookup(), RC, RCOK, and W_DO.

Here is the call graph for this function:

w_rc_t option_group_t::lookup ( const char *  name,
bool  exact,
option_t *&  ret 
)

Look up an option by name.

Parameters:
[in] name Name of option.
[in] exact name is not an abbreviation.
[out] ret Populate the given pointer if found.
Abbreviations are allowed if they are sufficient to identify the option and exact is false.
Examples:
log_exceed.cpp.

Definition at line 461 of file option.cpp.

References w_list_i< T, LOCK >::curr(), DBG, 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.

Parameters:
[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.
Abbreviations are allowed if they are sufficient to identify the option and exact is false.

Definition at line 490 of file option.cpp.

References DBG, 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.

Parameters:
[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 614 of file option.cpp.

References DBG, 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

Examples:
create_rec.cpp, init_config_options.cpp, log_exceed.cpp, sort_stream.cpp, startstop.cpp, and vtable_example.cpp.

Definition at line 700 of file option.cpp.

References DBG, 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.

Parameters:
[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.
Search the command line (argv[]) for options in this group. Command-line options must be preceded by "-" and are recognized only if they are min_len since options may be abbreviated. Any options found are removed from argv, and argc is adjusted accordingly.
Examples:
init_config_options.cpp.

Definition at line 718 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:


The documentation for this class was generated from the following files:
Generated on Wed Jul 7 17:22:43 2010 for Shore Storage Manager by  doxygen 1.4.7