Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Option Class Reference

An Option represents an argument or a flag (like -I) in a unix command. More...

#include <suifkernel/command_line_parsing.h>

Inheritance diagram for Option:

OptionInt OptionList OptionLiteral OptionLoop OptionMultiString OptionPrefixString OptionSelection OptionStream OptionString List of all members.

Public Methods

virtual bool parse_options ( istream& input_stream, bool &changed, ErrorSubSystem* output_for_errors )
 parses the command line and returns true if succeeded.

virtual bool parse_options ( int argc, char *argv[], bool &changed, ErrorSubSystem* output_for_errors )
virtual void print_to_stream ( ostream& print_stream ) const
virtual String to_string () const
virtual void print_debug () const
virtual bool parse ( TokenStream* tokens, bool &changed, ValueClass* parent = 0) = 0
 returns true if the token stream parsing does not fail at this option. More...

virtual int get_number_of_values () const
virtual void delete_values ()
virtual void print ( String& command_line_string, suif_vector<OptionDescription>* descriptions ) const
 Prepare the printable description of this option. More...

virtual void set_argument ( const String& argument )
 Set the name of the option to be printed out in a help message.

virtual void set_description ( const String& description, const String& group = emptyString )
 Set the description which explains what the option is.

virtual String get_description () const
virtual ~Option ()

Protected Methods

 Option ( String arguments = emptyString, Option* parent = 0)
 Option ( String arguments, String description, Option* parent)
virtual ValueClassget_value_class ( ValueClass* value, Option* context ) const

Protected Attributes

String _description
String _group
String _argument
Option* _parent
suif_vector<sf_owned ValueClass*>* sf_owned _values


Detailed Description

An Option represents an argument or a flag (like -I) in a unix command.

One can build a option tree with option instances as nodes to represent the grammar for the acceptable options. See the subclasses of Option for ways to construct the tree.

Each option may have multiple values associated with it.

Each option has the following component: parent - the parent option in the option tree. value - the values associated with this option, represented as a list of ValueClass instances. group - name associated with the collection of options argument - the name of this option, used in help message description - help message for this option.


Constructor & Destructor Documentation

Option::~Option () [virtual]

Option::Option ( String argument = emptyString,
Option * parent = 0) [protected]

Option::Option ( String argument,
String description,
Option * parent) [protected]


Member Function Documentation

void Option::delete_values () [virtual]

Reimplemented in OptionList, OptionLoop, and OptionSelection.

String Option::get_description ( void) const [virtual]

int Option::get_number_of_values () const [virtual]

ValueClass * Option::get_value_class ( ValueClass * value,
Option * context) const [protected, virtual]

bool Option::parse ( TokenStream * tokens,
bool & changed,
ValueClass * parent = 0) [inline, pure virtual]

returns true if the token stream parsing does not fail at this option.

sets the changed parameter to true if the option parsing generated some state. The changed token is important in loops because OptionSelections can succeed without actually consuming any of the token stream.

Reimplemented in OptionInt, OptionList, OptionLiteral, OptionLoop, OptionMultiString, OptionPrefixString, OptionSelection, OptionStream, and OptionString.

bool Option::parse_options ( int argc,
char * argv[],
bool & changed,
ErrorSubSystem * output_for_errors) [virtual]

bool Option::parse_options ( istream & input_stream,
bool & changed,
ErrorSubSystem * output_for_errors) [inline, virtual]

parses the command line and returns true if succeeded.

void Option::print ( String & command_line_string,
suif_vector<OptionDescription>* descriptions) const [inline, virtual]

Prepare the printable description of this option.

Append a printed message to command_line_string, and a description to descriptions.

Reimplemented in OptionList, OptionLiteral, OptionLoop, and OptionSelection.

void Option::print_debug () const [virtual]

void Option::print_to_stream ( ostream & output_stream) const [virtual]

void Option::set_argument ( const String & argument) [inline, virtual]

Set the name of the option to be printed out in a help message.

void Option::set_description ( const String & description,
const String & group = emptyString) [inline, virtual]

Set the description which explains what the option is.

String Option::to_string ( void) const [virtual]


Member Data Documentation

String Option::_argument [protected]

String Option::_description [protected]

String Option::_group [protected]

Option * Option::_parent [protected]

suif_vector<sf_owned ValueClass *>*sf_owned Option::_values [protected]


The documentation for this class was generated from the following files:
Generated at Mon Jul 31 13:44:14 2000 for NCI SUIF by doxygen 1.1.2 written by Dimitri van Heesch, © 1997-2000