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

ProgramInfo Class Reference

Global program information. More...

#include <Option.h>

Inheritance diagram for rs::cmdline::ProgramInfo:

Inheritance graph
[legend]
Collaboration diagram for ProgramInfo:

Collaboration graph
[legend]
List of all members.

Public Methods

 ProgramInfo (const char *program_name_, int main_version_, int sub_version_, const char *program_description_, const char *creation_date_=__DATE__)
 Create the global program information. More...

 ~ProgramInfo ()
void init (int argc_, char *argv_[])
 Process command line options and arguments. More...

void needOne (CmdLineOptionArray options)
 Declare options, where one of them has to be given. More...

void neededBy (const CmdLineOption &drug, const CmdLineOption &addict)
 Declare dependencies between CmdLineOptions. More...

void infos (std::ostream &out) const
 Display program help. More...

bool optionsSpecified () const
 Test if any options were given on command line. More...

void throw_Error (const std::string &msg) const
 Throws an InfoError. If you print the error the program help is also shown. More...

const std::string & CallPath () const
 returns the directory the program was called from. More...

const std::string & ProgramPath () const
 returns the directory where the program is stored. More...

Exclude
Declaration of options that cannot be used together.

Each of the exclude-functions declares two (sets of) CmdLineOption's which may not be used together. If the user of your program uses any of them together, an InfoError will be raised.

void exclude (CmdLineOptionArray opt1, CmdLineOptionArray opt2)
void exclude (CmdLineOption &opt1, CmdLineOptionArray opt2)
void exclude (CmdLineOptionArray opt1, CmdLineOption &opt2)
void exclude (CmdLineOption &opt1, CmdLineOption &opt2)

Private Methods

void setProgramPaths (const char *argv0)

Private Attributes

std::string program_name
int main_version
int sub_version
std::string program_description
std::string creation_date
bool any_option_given
std::string program_path
std::string call_path

Detailed Description

Global program information.

See also:
rs::cmdline for an overview how to use ProgramInfo

Definition at line 460 of file Option.h.


Constructor & Destructor Documentation

ProgramInfo const char *    program_name_,
int    main_version_,
int    sub_version_,
const char *    program_description_,
const char *    creation_date_ = __DATE__
 

Create the global program information.

Every program using the command line interface has to declare exactly one global instance of ProgramInfo.

Parameters:
program_name_  The name of the program.
main_version_  The main version of the program.
sub_version_  The sub version of the program.
program_description_  A description of the purpose of the program.
creation_date_  Date of creation (defaults to NOW).
Note:
When an instance of ProgramInfo exists, all errors will print sth like 'Error in program_name_: blabla'. This is done by defining an err::ErrorModule with name 'program_name_'.
See also:
init() has to be called by main

Definition at line 436 of file Option.cpp.

~ProgramInfo   [inline]
 

Definition at line 494 of file Option.h.


Member Function Documentation

void setProgramPaths const char *    argv0 [private]
 

Definition at line 489 of file Option.cpp.

Referenced by ProgramInfo::init().

void init int    argc_,
char *    argv_[]
 

Process command line options and arguments.

When init is called, all declared options and arguments are scanned.

If option -?, -h or --help is given or if an error occurs, then some help for the usage of the program is displayed.

Parameters:
argc_  same as argc in main
argv_  same as argv in main

Definition at line 518 of file Option.cpp.

void exclude CmdLineOptionArray    opt1,
CmdLineOptionArray    opt2
 

Parameters:
opt1  Reference to (or array of) CmdLineOption's
opt2  Reference to (or array of) CmdLineOption's
Note:
None of the options in opt1 may be used together with any from opt2.
General info

Definition at line 886 of file Option.cpp.

void exclude CmdLineOption   opt1,
CmdLineOptionArray    opt2
[inline]
 

Parameters:
opt1  Reference to (or array of) CmdLineOption's
opt2  Reference to (or array of) CmdLineOption's
Note:
None of the options in opt1 may be used together with any from opt2.
General info

Definition at line 527 of file Option.h.

void exclude CmdLineOptionArray    opt1,
CmdLineOption   opt2
[inline]
 

Parameters:
opt1  Reference to (or array of) CmdLineOption's
opt2  Reference to (or array of) CmdLineOption's
Note:
None of the options in opt1 may be used together with any from opt2.
General info

Definition at line 531 of file Option.h.

void exclude CmdLineOption   opt1,
CmdLineOption   opt2
[inline]
 

Parameters:
opt1  Reference to (or array of) CmdLineOption's
opt2  Reference to (or array of) CmdLineOption's
Note:
None of the options in opt1 may be used together with any from opt2.
General info

Definition at line 535 of file Option.h.

void needOne CmdLineOptionArray    options
 

Declare options, where one of them has to be given.

Parameters:
options  Array of options, where one has to be given.

Definition at line 906 of file Option.cpp.

void neededBy const CmdLineOption   drug,
const CmdLineOption   addict
 

Declare dependencies between CmdLineOptions.

Parameters:
drug  needed by addict
addict  needs the drug

Definition at line 921 of file Option.cpp.

void infos std::ostream &    out const
 

Display program help.

Parameters:
out  where to print

Definition at line 742 of file Option.cpp.

bool optionsSpecified   const [inline]
 

Test if any options were given on command line.

Returns:
true if options were given.

Definition at line 558 of file Option.h.

void throw_Error const std::string &    msg const
 

Throws an InfoError. If you print the error the program help is also shown.

Parameters:
msg  the error message
Note:
InfoError is a hidden class derived from err::Error

Definition at line 929 of file Option.cpp.

const string & CallPath   const
 

returns the directory the program was called from.

Definition at line 936 of file Option.cpp.

const string & ProgramPath   const
 

returns the directory where the program is stored.

Definition at line 945 of file Option.cpp.


Member Data Documentation

std::string program_name [private]
 

Definition at line 461 of file Option.h.

Referenced by ProgramInfo::infos(), and ProgramInfo::setProgramPaths().

int main_version [private]
 

Definition at line 462 of file Option.h.

Referenced by ProgramInfo::infos().

int sub_version [private]
 

Definition at line 463 of file Option.h.

Referenced by ProgramInfo::infos().

std::string program_description [private]
 

Definition at line 464 of file Option.h.

Referenced by ProgramInfo::infos().

std::string creation_date [private]
 

Definition at line 465 of file Option.h.

Referenced by ProgramInfo::infos().

bool any_option_given [private]
 

Definition at line 467 of file Option.h.

Referenced by ProgramInfo::init().

std::string program_path [private]
 

Definition at line 471 of file Option.h.

Referenced by ProgramInfo::ProgramPath(), and ProgramInfo::setProgramPaths().

std::string call_path [private]
 

Definition at line 472 of file Option.h.

Referenced by ProgramInfo::CallPath(), and ProgramInfo::setProgramPaths().


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