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

ost::CommandOption Class Reference

CommandOption is the base class for all command line options. More...

#include <cmdoptns.h>

Inheritance diagram for ost::CommandOption::

ost::CommandOptionNoArg ost::CommandOptionWithArg ost::CommandOptionArg ost::CommandOptionCollect ost::CommandOptionRest List of all members.

Public Types

enum  OptionType { HasArg, NoArg, Trailing, Collect }
 OptionType is for denoting what type of option this is, with an arg, without an arg or the trailing args. Option type. More...


Public Methods

virtual ~CommandOption ()
 A virtual destructor just in case. More...

 CommandOption (const char *in_option_name, const char *in_option_letter, const char *in_description, OptionType in_option_type, bool in_required=false, CommandOption **pp_next=&DefaultCommandOptionList)
 CommandOption contructor. More...

virtual void FoundOption (CommandOptionParse *cop, const char *value=0)
 FoundOption is called by the CommandOptionParse object during the parsing of the command line options. More...

virtual void FoundOption (CommandOptionParse *cop, const char **value, int num)
 FoundOption is called by the CommandOptionParse object during the parsing of the command line options. More...

virtual void ParseDone (CommandOptionParse *cop)
 Once parsing of command line options is complete, this method is called. More...

virtual void PerformTask (CommandOptionParse *cop)
 Once CommandOption objects have completed parsing and there are no errors they may have some specific tasks to perform. More...

virtual bool HasValue ()
 For fields with the required flag set, this method is used to determine if the Option has satisfied it's required status. More...


Public Attributes

const char * option_name
 Long option name, these will be preceded with "--" on the command line. More...

const char * option_letter
 option letter, these will be preceded with "-" on the command line. More...

const char * description
 A short description of the option for Usage messages. More...

OptionType option_type
 This command option's OptionType. More...

bool required
 True if this parameter is required. More...

CommandOption * next
 This next CommandOption in this list of options or nil if no more options exist. More...


Detailed Description

CommandOption is the base class for all command line options.

Command line options can be defined statically and used when constructing a command line parser onject using MakeCommandOptionParse. This serves only as a base class to CommandOptionWithArg, CommandOptionRest or CommandOptionNoArg which can also be used to derive more complex classes or even entire applications.

Author:
Gianni Mariani <gianni@mariani.ws>


Member Enumeration Documentation

enum ost::CommandOption::OptionType
 

OptionType is for denoting what type of option this is, with an arg, without an arg or the trailing args. Option type.

Enumeration values:
HasArg   This option is associated with a value.
NoArg   This option is a flag only.
Trailing   Remaining of the command line arguments.
Collect   Collect values that are not a value to an option.


Constructor & Destructor Documentation

virtual ost::CommandOption::~CommandOption   [virtual]
 

A virtual destructor just in case.

ost::CommandOption::CommandOption const char *   in_option_name,
const char *   in_option_letter,
const char *   in_description,
OptionType   in_option_type,
bool   in_required = false,
CommandOption **   pp_next = & DefaultCommandOptionList
 

CommandOption contructor.

Note the default values for required and pp_next.

Parameters:
in_option_name   long option name
in_option_letter   short letter name
in_description   short description of the option
in_option_type   the type of this option
in_required   true if option is required
pp_next   the linked list header


Member Function Documentation

virtual void ost::CommandOption::FoundOption CommandOptionParse *   cop,
const char **   value,
int   num
[virtual]
 

FoundOption is called by the CommandOptionParse object during the parsing of the command line options.

Parameters:
cop   pointer to the command option parser
value   an array of values of this option
num   number of values in the array

Reimplemented in ost::CommandOptionWithArg.

virtual void ost::CommandOption::FoundOption CommandOptionParse *   cop,
const char *   value = 0
[virtual]
 

FoundOption is called by the CommandOptionParse object during the parsing of the command line options.

Parameters:
cop   pointer to the command option parser
value   the value of this option

Reimplemented in ost::CommandOptionWithArg, and ost::CommandOptionNoArg.

virtual bool ost::CommandOption::HasValue   [virtual]
 

For fields with the required flag set, this method is used to determine if the Option has satisfied it's required status.

The default methods simply returns true if any values have been found. This could be specialized to return true based on some other criteria.

Reimplemented in ost::CommandOptionWithArg.

virtual void ost::CommandOption::ParseDone CommandOptionParse *   cop [virtual]
 

Once parsing of command line options is complete, this method is called.

This can be used to perform last minute checks on the options collected.

Parameters:
cop   pointer to the command option parser

virtual void ost::CommandOption::PerformTask CommandOptionParse *   cop [virtual]
 

Once CommandOption objects have completed parsing and there are no errors they may have some specific tasks to perform.

PerformTask must return.

Parameters:
cop   pointer to the command option parser


Member Data Documentation

const char* ost::CommandOption::description
 

A short description of the option for Usage messages.

e.g. Usage: mycommand : blah -f, --file <DESCRIPTION here>

CommandOption* ost::CommandOption::next
 

This next CommandOption in this list of options or nil if no more options exist.

const char* ost::CommandOption::option_letter
 

option letter, these will be preceded with "-" on the command line.

e.g. -f foo.x

const char* ost::CommandOption::option_name
 

Long option name, these will be preceded with "--" on the command line.

e.g. --file foo.x

OptionType ost::CommandOption::option_type
 

This command option's OptionType.

bool ost::CommandOption::required
 

True if this parameter is required.

If the parameter is not supplied and required is true, an error will be flagged in the option processor.


The documentation for this class was generated from the following file:
Generated at Thu Jan 24 11:06:03 2002 for CommonC++ by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001