Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

Options Class Reference
[Command line options library]

A list of command line options, with methods for parsing strings and streams to set the options. More...

#include <options.h>

List of all members.

Public Member Functions

 Options ()
 Default constructor: creates an empty list of options.
 ~Options ()
 Destructor: de-allocates all the _option<T> objects contained in this Options list.
template<typename T>
void Add (std::string name, T &variable)
 Create a new _option<T>, with name name and linked to variable, and add it to the list.
bool Parse (std::string str)
 Parse str, looking for "name=value", search for an option called "name", and set its linked variable to whatever "value" evaluates as.
int Parse (char **str, int n)
 Parse an array of n null-terminated C strings.
int Parse (std::istream &file)
 Parse a stream, by successively reading and parsing strings from the stream. Terminates when the stream is empty.
void Print (std::ostream &os=std::cout)
 Print the options, one per line, to a stream. The output format looks much like C++ code, and is also readable by Parse().
bool SetOption (std::string name, std::string value)
 Search for an option called name, and set its value to whatever value evaluates as. Not really intended for external use.

Public Attributes

std::list< _optionbase * > OpList
 STL list of pointers to _option<T> (of which _optionbase is the common base class).


Detailed Description

A list of command line options, with methods for parsing strings and streams to set the options.

To use the options library, declare a variable of type Options. Then, add as many parameters as desired to its internal list using Add(). Once you've registered all the parameters you want, use one of the Parse() methods to read in parameter values from:

Options stores parameters internally in an STL list. When given a string of the form "name=value" to parse, it searches the list for an option called "name". So, if two options have the same name, the second one will never get found. It is also possible to add the same variable with two different names, in which case it can be altered by either name. This is probably not a good idea.


The documentation for this class was generated from the following files:
Generated on Wed Jun 14 22:25:28 2006 for linalg by  doxygen 1.4.4