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

CmdLineArgument Class Reference

A command line argument. More...

#include <Option.h>

Inheritance diagram for rs::cmdline::CmdLineArgument:

Inheritance graph
[legend]
Collaboration diagram for CmdLineArgument:

Collaboration graph
[legend]
List of all members.

Public Methods

 CmdLineArgument (const char *name_, const char *helptext_, const char *value_=0, bool is_real_arg=true)
 Declare a new command line argument. More...

virtual ~CmdLineArgument ()
bool value_is_set () const
 operator bool () const
 Test the argument. More...

virtual bool reallyUsed () const
 Test the argument. More...

virtual std::string get ()
 Get the argument value. More...

virtual int getNumeric ()
 Get the argument value as numeric value (accepts decimal and hexadecimal arguments). More...

virtual double getDouble ()
 Get the argument value as floating point value. More...

virtual void set (std::string value_, bool set_default_value=false)
 Set the argument value manually. More...

void clear ()
 Clear the argument manually. More...

virtual std::string get_name () const
 Return name of argument (as shown in helptext: i.e. "<arg>" ). More...


Protected Methods

bool has_default () const
void set_has_default ()
virtual std::string get_helptext () const
 Get the helptext. More...


Private Attributes

std::string name
std::string value
bool has_default_value
bool really_used

Friends

class ProgramInfo

Detailed Description

A command line argument.

Definition at line 109 of file Option.h.


Constructor & Destructor Documentation

CmdLineArgument const char *    name_,
const char *    helptext_,
const char *    value_ = 0,
bool    is_real_arg = true
 

Declare a new command line argument.

Should be declared global.

Parameters:
name_  The name of the argument as it should be used in the helptext. (i.e. "filename" results in <filename>)
helptext_  Help for this command line argument.
value_  Default value (defaults to 0).
is_real_arg  Don't change this (defaults to true)

Definition at line 267 of file Option.cpp.

~CmdLineArgument   [virtual]
 

Definition at line 298 of file Option.cpp.


Member Function Documentation

bool value_is_set   const [inline]
 

Definition at line 129 of file Option.h.

operator bool   const [inline]
 

Test the argument.

Returns:
true if argument was given on command line, set using set() or has a default value.

Definition at line 133 of file Option.h.

virtual bool reallyUsed   const [inline, virtual]
 

Test the argument.

Returns:
true if argument was given on command line or set using set(). false if only has a default value.

Reimplemented in CmdLineArgumentOption, and RepeatedCmdLineArgumentOption.

Definition at line 137 of file Option.h.

virtual std::string get   [inline, virtual]
 

Get the argument value.

Returns:
The given command line argument.

Reimplemented in RepeatableCmdLineArgument, and RepeatedCmdLineArgumentOption.

Definition at line 141 of file Option.h.

Referenced by CmdLineArgument::getDouble(), CmdLineArgument::getNumeric(), and FileFilter::init().

int getNumeric   [virtual]
 

Get the argument value as numeric value (accepts decimal and hexadecimal arguments).

Returns:
The numeric value of the given command line argument.

Definition at line 192 of file Option.cpp.

double getDouble   [virtual]
 

Get the argument value as floating point value.

Returns:
The floating point value of the given command line argument.

Definition at line 229 of file Option.cpp.

virtual void set std::string    value_,
bool    set_default_value = false
[inline, virtual]
 

Set the argument value manually.

Parameters:
value_  New value for argument. (Calling set("xxx") has the same effect as if "xxx" has been given on command line.)
set_default_value  defaults to false. if true then only the default value is set.

Reimplemented in RepeatableCmdLineArgument, CmdLineArgumentOption, and RepeatedCmdLineArgumentOption.

Definition at line 154 of file Option.h.

void clear   [inline]
 

Clear the argument manually.

Reimplemented in CmdLineArgumentOption, and RepeatedCmdLineArgumentOption.

Definition at line 160 of file Option.h.

virtual std::string get_name   const [inline, virtual]
 

Return name of argument (as shown in helptext: i.e. "<arg>" ).

Reimplemented in RepeatableCmdLineArgument, and RepeatedCmdLineArgumentOption.

Definition at line 169 of file Option.h.

Referenced by CmdLineArgument::CmdLineArgument(), CmdLineArgumentOption::CmdLineArgumentOption(), ProgramInfo::init(), and CmdLineArgumentOption::print().

bool has_default   const [inline, protected]
 

Definition at line 174 of file Option.h.

void set_has_default   [inline, protected]
 

Definition at line 175 of file Option.h.

Referenced by ProgramInfo::init().

virtual std::string get_helptext   const [inline, protected, virtual]
 

Get the helptext.

Reimplemented from CmdLineHelpText.

Definition at line 177 of file Option.h.


Friends And Related Function Documentation

friend class ProgramInfo [friend]
 

Reimplemented in RepeatableCmdLineArgument.

Definition at line 172 of file Option.h.


Member Data Documentation

std::string name [private]
 

Definition at line 110 of file Option.h.

Referenced by CmdLineArgument::getDouble(), and CmdLineArgument::getNumeric().

std::string value [private]
 

Definition at line 111 of file Option.h.

bool has_default_value [private]
 

Definition at line 112 of file Option.h.

bool really_used [private]
 

Definition at line 113 of file Option.h.


The documentation for this class was generated from the following files:
Contact me in case of errors or questions.
This documentation is powered by Doxygen.
(C) 2000-2002 Doxygen