JWS C++ Library
C++ language utility library
jwscxx::base::Option Class Reference

Base program option. More...

#include <option.h>

Inheritance diagram for jwscxx::base::Option:
Collaboration diagram for jwscxx::base::Option:

List of all members.

Public Member Functions

 Option (char s_name, const char *l_name, const char *desc) throw (Arg_error)
 Constructs an Option.
virtual ~Option ()
 Deletes an Option.
virtual int process (int argc, char **argv) const =0 throw (Arg_error)
 Processes an Option from program command-line arguments.
virtual void print (ostream &out, int width) const =0 throw (Arg_error)
 Prints an Option to an output stream.

Protected Member Functions

bool is_s_name_option (const char *arg) const
 Returns whether or not arg is the short name of this Option.
bool is_l_name_option (const char *arg) const
 Returns whether or not arg is the long name of this Option.

Protected Attributes

char s_name
 Short name of the option.
const char * l_name
 Long name of the option.
const char * desc
 Description of the option.

Detailed Description

Base program option.

An option is specified on the command-line as follows

   --option-string
   -O

where

   Option::l_name = "option-string"
   Option::s_name = 'O'

Specifying an option in a file is similar, but only the Option::l_name can be used, for instance

   option-string

Definition at line 101 of file option.h.


Constructor & Destructor Documentation

Option::Option ( char  s_name,
const char *  l_name,
const char *  desc 
) throw (Arg_error)

Constructs an Option.

Parameters:
s_nameShort name for the Option.
l_nameLong name for the Option.
descOption description.

Definition at line 95 of file option.cpp.

virtual jwscxx::base::Option::~Option ( ) [inline, virtual]

Deletes an Option.

Definition at line 111 of file option.h.


Member Function Documentation

virtual int jwscxx::base::Option::process ( int  argc,
char **  argv 
) const throw (Arg_error) [pure virtual]

Processes an Option from program command-line arguments.

Implemented in jwscxx::base::Option_with_arg, and jwscxx::base::Option_no_arg.

virtual void jwscxx::base::Option::print ( ostream &  out,
int  width 
) const throw (Arg_error) [pure virtual]

Prints an Option to an output stream.

Implemented in jwscxx::base::Option_with_arg, and jwscxx::base::Option_no_arg.

bool Option::is_s_name_option ( const char *  arg) const [protected]

Returns whether or not arg is the short name of this Option.

Parameters:
argProgram argument to check if it is this Option.
Returns:
Whether or not arg is the short name of this Option.

Definition at line 114 of file option.cpp.

bool Option::is_l_name_option ( const char *  arg) const [protected]

Returns whether or not arg is the long name of this Option.

Parameters:
argProgram argument to check if it is this Option.
Returns:
Whether or not arg is the long name of this Option.

Definition at line 132 of file option.cpp.


Member Data Documentation

char jwscxx::base::Option::s_name [protected]

Short name of the option.

Example '-o', where flag='o'. If not used, set to 0 or '\0'.

Definition at line 146 of file option.h.

const char* jwscxx::base::Option::l_name [protected]

Long name of the option.

Example '--option', where string="option". If not used, set to 0.

Definition at line 153 of file option.h.

const char* jwscxx::base::Option::desc [protected]

Description of the option.

If not used, set to 0.

Definition at line 160 of file option.h.


The documentation for this class was generated from the following files: