Generated on Tue Dec 16 12:50:03 2008 for BIU-2.2.0 by doxygen 1.5.1

biu::COptionParser Class Reference

#include <OptionParser.hh>


Detailed Description

Class for type assured parameter parsing and help output generation.

Author:
Martin Mann <mmann@informatik.uni-freiburg.de>

Definition at line 92 of file OptionParser.hh.

Public Member Functions

bool argExist (std::string option)
 COptionParser (OptionMap _options, int argc, char **argv, std::string infoText)
void coutUsage () const
bool getBoolVal (std::string arg)
char getCharVal (std::string arg)
double getDoubleVal (std::string arg)
float getFloatVal (std::string arg)
int getIntVal (std::string arg)
std::string getStrVal (std::string arg)
bool noErrors ()

Static Public Attributes

static int OUTPUT_LINE_LENGTH

Private Types

enum  ERRORS { ERR_NO_OPT, ERR_WR_USE, ERR_WR_VAL, ERR_NO_ARG }
typedef __gnu_cxx::hash_map<
std::string, int, hash_string
STR2INT_MAP

Private Member Functions

void coutError (int error, std::string optionName, std::string errormsg)
void coutLineBreaking (std::string text, std::ostream &os, const int emptyHeadSize, const int lineLength) const
bool isCastable (std::string val, int type) const
void parseOpt (int argc, char **argv)

Private Attributes

bool errorOccured
std::string infoText
unsigned int maxOName
STR2INT_MAP mopt
OptionMap opt
std::string programName

Data Structures

struct  hash_string


Member Typedef Documentation

typedef __gnu_cxx::hash_map< std::string, int, hash_string > biu::COptionParser::STR2INT_MAP [private]

Definition at line 115 of file OptionParser.hh.


Member Enumeration Documentation

possible error codes

Enumerator:
ERR_NO_OPT 
ERR_WR_USE 
ERR_WR_VAL 
ERR_NO_ARG 

Definition at line 129 of file OptionParser.hh.


Constructor & Destructor Documentation

biu::COptionParser::COptionParser ( OptionMap  _options,
int  argc,
char **  argv,
std::string  infoText 
)

construction

Definition at line 31 of file OptionParser.cc.


Member Function Documentation

bool biu::COptionParser::argExist ( std::string  option  ) 

== true if the corresponding parameter was given or has a default value

Definition at line 134 of file OptionParser.cc.

void biu::COptionParser::coutError ( int  error,
std::string  optionName,
std::string  errormsg 
) [private]

prints a formatted error output

Parameters:
error the error code for the main return value
optionName the name of the option not found
errormsg the error message to display

Definition at line 200 of file OptionParser.cc.

void biu::COptionParser::coutLineBreaking ( std::string  text,
std::ostream &  os,
const int  emptyHeadSize,
const int  lineLength 
) const [private]

help function for help output generation

Definition at line 55 of file OptionParser.cc.

void biu::COptionParser::coutUsage (  )  const

prints the program help output to std::cout

Definition at line 86 of file OptionParser.cc.

bool biu::COptionParser::getBoolVal ( std::string  arg  ) 

Definition at line 190 of file OptionParser.cc.

char biu::COptionParser::getCharVal ( std::string  arg  ) 

Definition at line 150 of file OptionParser.cc.

double biu::COptionParser::getDoubleVal ( std::string  arg  ) 

Definition at line 179 of file OptionParser.cc.

float biu::COptionParser::getFloatVal ( std::string  arg  ) 

Definition at line 168 of file OptionParser.cc.

int biu::COptionParser::getIntVal ( std::string  arg  ) 

Definition at line 157 of file OptionParser.cc.

std::string biu::COptionParser::getStrVal ( std::string  arg  ) 

Definition at line 143 of file OptionParser.cc.

bool biu::COptionParser::isCastable ( std::string  val,
int  type 
) const [private]

tests whether or not the parameters are parseable

Parameters:
val the string to cast
type the variable to cast to
Returns:
true if a cast is possible, false otherwise

Definition at line 214 of file OptionParser.cc.

bool biu::COptionParser::noErrors (  ) 

== true if an error occured during parameter parsing

Definition at line 50 of file OptionParser.cc.

void biu::COptionParser::parseOpt ( int  argc,
char **  argv 
) [private]

checks the parameters

Definition at line 262 of file OptionParser.cc.


Field Documentation

== true if the parameters are not parseable

Definition at line 124 of file OptionParser.hh.

std::string biu::COptionParser::infoText [private]

additional informations for help output

Definition at line 122 of file OptionParser.hh.

unsigned int biu::COptionParser::maxOName [private]

Definition at line 125 of file OptionParser.hh.

Definition at line 126 of file OptionParser.hh.

the list of possible parameter options

Definition at line 120 of file OptionParser.hh.

the maximal line length for the help output

Definition at line 152 of file OptionParser.hh.

std::string biu::COptionParser::programName [private]

the name of the program

Definition at line 121 of file OptionParser.hh.


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