In file EO++.h:

class Parser

Parses the command line

Public Classes

class BadType: public UException
This class managges bad param types
BadType(const string& _param, const string& _value, const string& _correctType)
Constructor
class MissingReqParam: public UException
This class managges exceptions produced when the user forgot a required parameter
MissingReqParam(const string& _shortName)
Constructor
class MissingVal: public UException
This class managges exceptions produced when there isn't a value for a parameter
MissingVal(const string& _param)
Constructor
class UnknownArg: public UException
This class managges unknown argument exceptions
UnknownArg( const string& _arg)
Constructor

Public Methods

void addFlag(const string& _shortName, const string& _longName, const string _description)
Adds a flag
void addParam(const string& _shortName, const string& _longName, const string& _default = "", Param::valueType _valType=Param::STRING, const string& _description="", bool _required=false)
Adds a param
float getFloat(const string& _param)
Gets the float value of a param given its short name or its long name
int getInt(const string& _param)
Gets the int value of a param given its short name or its long name
string getString(const string& _param)
Gets the string value of a param given its short name or its long name
bool isEnabled(const string& _flag)
Checks if a flag is enabled or not given its short name or its long name
void parse(int _argc, char **_argv)
Parses the command line, updating the flags or params according to its contents
Parser( const Parser& _parser )
Copy constructor
Parser( string _programName, string _programDescription)
Constructor
void printHelp()
Prints an automatic help in the standard output using the information provided by flags and parameters
virtual ~Parser()
Virtual destructor is needed

Private Methods

void enableFlag(const string& _name)
Enables a flag given its short name or its long name
void setParamValue(const string& _name, const char* _value)
Sets a new value for a param given its short name or its long name

Documentation

Parses the command line
Parser( string _programName, string _programDescription)
Constructor
Parameters:
_programName - Name to call the program from command line
_programDescription - Description of the work the program does

Parser( const Parser& _parser )
Copy constructor
Parameters:
_parser - The source parser

virtual ~Parser()
Virtual destructor is needed

void addFlag(const string& _shortName, const string& _longName, const string _description)
Adds a flag
Parameters:
_shortName - Short name of the flag.
_longName - Long name of the flag.
_state - Initial state.
_description - What the flag is useful for

void addParam(const string& _shortName, const string& _longName, const string& _default = "", Param::valueType _valType=Param::STRING, const string& _description="", bool _required=false)
Adds a param
Parameters:
_shortName - Short name of the param.
_longName - Long name of the param.
_default - Default value.
_valType - Type of the parameter
_description - Parameter utility
_required - If the parameter is necessary or not

bool isEnabled(const string& _flag)
Checks if a flag is enabled or not given its short name or its long name
Throws:
UnknownArg if the flag doesn't exist
Parameters:
_flag - One of the names of the flag.

string getString(const string& _param)
Gets the string value of a param given its short name or its long name
Throws:
UnknownArg if the param doesn't exist
Parameters:
_param - One of the names of the param.

int getInt(const string& _param)
Gets the int value of a param given its short name or its long name
Throws:
UnknownArg if the param doesn't exist
BadType if the param's value isn't a correct int
Parameters:
_param - One of the names of the param.

float getFloat(const string& _param)
Gets the float value of a param given its short name or its long name
Throws:
UnknownArg if the param doesn't exist
BadType if the param's value isn't a correct float
Parameters:
_param - One of the names of the param.

void parse(int _argc, char **_argv)
Parses the command line, updating the flags or params according to its contents. After parsing the method thereWereErrors() to check if there have been parsing errors or not.
Throws:
UnknownArg if an argument doesn't exist
MissingVal if a param hasn't got a value
Parameters:
_argc - The argument count of the command line.
_argv - The arguments of the command line.

void printHelp()
Prints an automatic help in the standard output using the information provided by flags and parameters

class UnknownArg: public UException
This class managges unknown argument exceptions

UnknownArg( const string& _arg)
Constructor
Parameters:
_arg - string to be shown when the exception occurs

class BadType: public UException
This class managges bad param types

BadType(const string& _param, const string& _value, const string& _correctType)
Constructor
Parameters:
_param - The param
_value - The value of the param

class MissingVal: public UException
This class managges exceptions produced when there isn't a value for a parameter

MissingVal(const string& _param)
Constructor
Parameters:
_param - The param

class MissingReqParam: public UException
This class managges exceptions produced when the user forgot a required parameter

MissingReqParam(const string& _shortName)
Constructor
Parameters:
_shortName - The param's short name

void enableFlag(const string& _name)
Enables a flag given its short name or its long name
Throws:
UnknownArg if the flag doesn't exist
Parameters:
_name - One of the names of the flag.

void setParamValue(const string& _name, const char* _value)
Sets a new value for a param given its short name or its long name
Throws:
UnknownArg if the param doesn't exist
MissingVal if the param hasn't got a value
Parameters:
_name - One of the names of the param.
_value - Value to be assigned.


This class has no child classes.

alphabetic index hierarchy of classes


BinOp