JWS C++ Library
C++ language utility library
|
Option that takes an argument. More...
#include <option.h>
Public Member Functions | |
Option_with_arg (char s_name, const char *l_name, const char *desc, void(*func)(const char *arg) throw(Arg_error)) throw (Arg_error) | |
Constructs an Option that takes an argument. | |
int | process (int argc, char **argv) const throw (Arg_error) |
Processes an Option from program command-line arguments. | |
void | print (ostream &out, int width) const throw (Arg_error) |
Prints an Option to an output stream. | |
Protected Member Functions | |
const char * | get_l_name_arg (const char *str) const |
Gets the argument for the Option from its long name. | |
Protected Attributes | |
void(* | func )(const char *arg) |
Function to process an Option with an argument. |
Option that takes an argument.
An option is specified on the command-line as follows
--option-string=arg
-O arg
where
Option::l_name = "option-string" Option::s_name = 'O'
Specifying an option in a file is similar, but only the Option::l_name can be used, for instance
option-string=arg
int Option_with_arg::process | ( | int | argc, |
char ** | argv | ||
) | const throw (Arg_error) [virtual] |
Processes an Option from program command-line arguments.
argc | Number of command-line arguments. |
argv | The command-line arguments. |
Implements jwscxx::base::Option.
Definition at line 200 of file option.cpp.
void Option_with_arg::print | ( | ostream & | out, |
int | width | ||
) | const throw (Arg_error) [virtual] |
Prints an Option to an output stream.
The format for printing is as follows
-O, --option-string=ARG Option description.
The Option::desc may wrap to multiple lines, but will be aligned properly.
out | Output stream to print to. |
width | Width of the option name field to use. |
Arg_error | Maximum width is 60. |
Implements jwscxx::base::Option.
Definition at line 237 of file option.cpp.
const char * Option_with_arg::get_l_name_arg | ( | const char * | str | ) | const [protected] |
Gets the argument for the Option from its long name.
str | String to get the Option argument from. |
Definition at line 374 of file option.cpp.
void(* jwscxx::base::Option_with_arg::func)(const char *arg) [protected] |