JWS C++ Library
C++ language utility library
|
Collection of Options for processing. More...
#include <option.h>
Public Member Functions | |
Options () | |
Constructs an empty collection of options. | |
~Options () | |
Deletes a collection of options. | |
void | add (Option *opt) |
Adds an option to the collection. | |
int | process (int argc, char **argv) const throw (Arg_error) |
Processes the options in the collection from program command-line arguments. | |
void | process (const char *fname) const throw (IO_error, Arg_error) |
Processes the options in the collection from a file. | |
void | process (istream &in) const throw (Arg_error) |
Processes the options in the collection from an input stream. | |
void | print (ostream &out=cerr, int width=20) const |
Prints the options in the collection to an output stream. | |
Private Member Functions | |
bool | is_an_option (const char *arg) const |
Returns whether an argument is an option. | |
Private Attributes | |
list< Option * > | opts |
Collection of Options. |
jwscxx::base::Options::Options | ( | ) | [inline] |
Options::~Options | ( | ) |
Deletes a collection of options.
Deletes all the Option in the collection.
Definition at line 606 of file option.cpp.
void Options::add | ( | Option * | opt | ) |
Adds an option to the collection.
opt | Option to add to the collection. |
Definition at line 621 of file option.cpp.
int Options::process | ( | int | argc, |
char ** | argv | ||
) | const throw (Arg_error) |
Processes the options in the collection from program command-line arguments.
argc | Number of arguments in argv. |
argv | Array of string arguments. |
jwscxx::base::Arg_error | Error in processing an argument. |
Definition at line 635 of file option.cpp.
Processes the options in the collection from a file.
fname | File to process the options from. |
IO_error | There was a problem opening or reading from fname. |
Arg_error | Could not process an option in the file. |
Definition at line 675 of file option.cpp.
void Options::process | ( | istream & | in | ) | const throw (Arg_error) |
Processes the options in the collection from an input stream.
in | Input stream to process the options from. |
Arg_error | Could not process an option in the file. |
Definition at line 711 of file option.cpp.
void Options::print | ( | ostream & | out = cerr , |
int | width = 20 |
||
) | const |
Prints the options in the collection to an output stream.
The format for printing is as follows
-O, --option-string 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. |
Definition at line 784 of file option.cpp.
bool Options::is_an_option | ( | const char * | arg | ) | const [private] |
Returns whether an argument is an option.
Definition at line 795 of file option.cpp.
list<Option *> jwscxx::base::Options::opts [private] |