Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Arak::Util::CommandLine::Option Class Reference

#include <parsecl.hpp>

Inheritance diagram for Arak::Util::CommandLine::Option:

Inheritance graph
[legend]
List of all members.

Detailed Description

An option that is either supplied or not.

Definition at line 27 of file parsecl.hpp.

Public Member Functions

 Option (const char *sflag, const char *lflag, const char *desc, bool required=false)
 Constructor.

virtual ~Option ()
 Destructor.

virtual bool supplied () const
 Returns true (after parsing) if this option was supplied on the command line.

virtual bool hasArg ()
 Returns true if this option takes an argument.


Protected Member Functions

bool matches (const char *flag) const
 Returns true if the supplied flag matches this option.

virtual bool read (const char *str)
 This is a placeholder for functionality in a derived class.

virtual void printUsage (std::ostream &out) const
 Prints the usage of this option to the supplied output stream.


Protected Attributes

const char * sflag
 The short form of the option.

const char * lflag
 The lflag form of the option.

const char * desc
 A description of the option.

bool _supplied
 This flag is true iff the option was supplied on the command line.

const bool required
 This flag is true iff the option is required.


Friends

class CommandLine


Constructor & Destructor Documentation

Arak::Util::CommandLine::Option::Option const char *  sflag,
const char *  lflag,
const char *  desc,
bool  required = false
[inline]
 

Constructor.

Parameters:
sflag The short form of the option. This is usually preceded by a single dash and consists of a single letter, as in "-h".
lflag The long form of the option. This is usually preceded by a double dash, as in "--help".
desc A description of the option. This should be a string with no formatting (e.g., no newlines).
required true if this option is required

Definition at line 114 of file parsecl.hpp.

References _supplied, and required.

virtual Arak::Util::CommandLine::Option::~Option  )  [inline, virtual]
 

Destructor.

Definition at line 122 of file parsecl.hpp.


Member Function Documentation

virtual bool Arak::Util::CommandLine::Option::hasArg  )  [inline, virtual]
 

Returns true if this option takes an argument.

Reimplemented in Arak::Util::CommandLine::Parameter< T >, and Arak::Util::CommandLine::MultiParameter< T >.

Definition at line 133 of file parsecl.hpp.

Referenced by Arak::Util::CommandLine::parse().

bool Arak::Util::CommandLine::Option::matches const char *  flag  )  const [inline, protected]
 

Returns true if the supplied flag matches this option.

A flag matches if it is a prefix of the option's short or long flag names.

Parameters:
flag the command line flag
Returns:
true if the flag matches this option

Definition at line 70 of file parsecl.hpp.

References lflag, and sflag.

Referenced by Arak::Util::CommandLine::parse().

virtual void Arak::Util::CommandLine::Option::printUsage std::ostream &  out  )  const [inline, protected, virtual]
 

Prints the usage of this option to the supplied output stream.

Reimplemented in Arak::Util::CommandLine::Parameter< T >, and Arak::Util::CommandLine::MultiParameter< T >.

Definition at line 91 of file parsecl.hpp.

References desc, lflag, and sflag.

Referenced by Arak::Util::CommandLine::printUsage().

virtual bool Arak::Util::CommandLine::Option::read const char *  str  )  [inline, protected, virtual]
 

This is a placeholder for functionality in a derived class.

It should not be called.

Parameters:
str a string representation of this option's value
Returns:
true if the read was successful

Reimplemented in Arak::Util::CommandLine::Parameter< T >, and Arak::Util::CommandLine::MultiParameter< T >.

Definition at line 83 of file parsecl.hpp.

Referenced by Arak::Util::CommandLine::parse().

virtual bool Arak::Util::CommandLine::Option::supplied  )  const [inline, virtual]
 

Returns true (after parsing) if this option was supplied on the command line.

Definition at line 128 of file parsecl.hpp.

References _supplied.

Referenced by main().


Friends And Related Function Documentation

friend class CommandLine [friend]
 

Reimplemented in Arak::Util::CommandLine::Parameter< T >, and Arak::Util::CommandLine::MultiParameter< T >.

Definition at line 29 of file parsecl.hpp.


Member Data Documentation

bool Arak::Util::CommandLine::Option::_supplied [protected]
 

This flag is true iff the option was supplied on the command line.

Definition at line 55 of file parsecl.hpp.

Referenced by Option(), Arak::Util::CommandLine::parse(), and supplied().

const char* Arak::Util::CommandLine::Option::desc [protected]
 

A description of the option.

This should be a string with no formatting (e.g., no newlines).

Definition at line 49 of file parsecl.hpp.

Referenced by printUsage().

const char* Arak::Util::CommandLine::Option::lflag [protected]
 

The lflag form of the option.

This is usually preceded by a double dash, as in "--help".

Definition at line 43 of file parsecl.hpp.

Referenced by matches(), and printUsage().

const bool Arak::Util::CommandLine::Option::required [protected]
 

This flag is true iff the option is required.

Definition at line 60 of file parsecl.hpp.

Referenced by Option(), and Arak::Util::CommandLine::parse().

const char* Arak::Util::CommandLine::Option::sflag [protected]
 

The short form of the option.

This is usually preceded by a single dash and consists of a single letter, as in "-h".

Definition at line 37 of file parsecl.hpp.

Referenced by matches(), Arak::Util::CommandLine::parse(), and printUsage().


The documentation for this class was generated from the following file:
Generated on Wed May 25 14:41:40 2005 for Arak by doxygen 1.3.6