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

Option that does not take an argument. More...

#include <option.h>

Inheritance diagram for jwscxx::base::Option_no_arg:
Collaboration diagram for jwscxx::base::Option_no_arg:

List of all members.

Public Member Functions

 Option_no_arg (char s_name, const char *l_name, const char *desc, void(*func)(void)) throw (Arg_error)
 Constructs an Option that does not take an argument.
int process (int argc, char **argv) const throw (Arg_error)
 Processes an Option from program command-line arguments.
void print (ostream &out, int width) const throw (Arg_error)
 Prints an Option to an output stream.

Protected Attributes

void(* func )(void)
 Function to process an Option with an argument.

Detailed Description

Option that does not take an argument.

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 260 of file option.h.


Constructor & Destructor Documentation

Option_no_arg::Option_no_arg ( char  s_name,
const char *  l_name,
const char *  desc,
void(*)(void)  func 
) throw (Arg_error)

Constructs an Option that does not take an argument.

Parameters:
s_nameShort name for the Option.
l_nameLong name for the Option.
descOption description.
funcFunction to process the Option.

Definition at line 407 of file option.cpp.


Member Function Documentation

int Option_no_arg::process ( int  argc,
char **  argv 
) const throw (Arg_error) [virtual]

Processes an Option from program command-line arguments.

Parameters:
argcNumber of command-line arguments.
argvThe command-line arguments.
Returns:
If this Option is in the arguments, its index is returned; otherwise < 0.
Exceptions:
Arg_errorError in processing the Option. This will never actually occur. It is just here because the function extends a virtual one.

Implements jwscxx::base::Option.

Definition at line 431 of file option.cpp.

void Option_no_arg::print ( ostream &  out,
int  width 
) const throw (Arg_error) [virtual]

Prints an Option to an output stream.

The format for printing is as follows

   -O, --option-string  Option description.

The Option::desc may wrap to multiple lines, but will be aligned properly.

Parameters:
outOutput stream to print to.
widthWidth of the option name field to use.
Note:
The format for printing assumes an 80 character line width.
Exceptions:
Arg_errorMaximum width is 60.

Implements jwscxx::base::Option.

Definition at line 463 of file option.cpp.


Member Data Documentation

void(* jwscxx::base::Option_no_arg::func)(void) [protected]

Function to process an Option with an argument.

Definition at line 286 of file option.h.


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