CFEL - ASG Software Suite  2.5.0
CASS
Public Types | Public Member Functions | Private Attributes | List of all members
cass::CommandlineArgumentParser Class Reference

command line argument parser More...

#include <cl_parser.hpp>

+ Collaboration diagram for cass::CommandlineArgumentParser:

Public Types

typedef std::map< std::string, std::pair< bool *, std::string > > switches_t
 a container type for switches More...
 
typedef std::map< std::string, std::pair< int *, std::string > > intarguments_t
 a container type for switches More...
 
typedef std::map< std::string, std::pair< std::string *, std::string > > stringarguments_t
 a container type for switches More...
 

Public Member Functions

void usage ()
 output which commandline parameters are available More...
 
void operator() (const QStringList &argumentList)
 operator to parse the argumetns More...
 
void add (const std::string &sw, const std::string &desc, bool &val)
 add a switch to the switches container More...
 
void add (const std::string &sw, const std::string &desc, std::string &val)
 add a switch to the string container More...
 
void add (const std::string &sw, const std::string &desc, int &val)
 add a switch to the int container More...
 

Private Attributes

switches_t _switches
 container for the switches More...
 
stringarguments_t _stringargs
 container for the string arguments More...
 
intarguments_t _intargs
 container for the int arguments More...
 

Detailed Description

command line argument parser

object that will parse the command line parameters and set the switches and retrieve the arguments

Author
Lutz Foucar

Definition at line 27 of file cl_parser.hpp.

Member Typedef Documentation

typedef std::map<std::string,std::pair<int*,std::string> > cass::CommandlineArgumentParser::intarguments_t

a container type for switches

Definition at line 34 of file cl_parser.hpp.

typedef std::map<std::string,std::pair<std::string*,std::string> > cass::CommandlineArgumentParser::stringarguments_t

a container type for switches

Definition at line 37 of file cl_parser.hpp.

typedef std::map<std::string,std::pair<bool*,std::string> > cass::CommandlineArgumentParser::switches_t

a container type for switches

Definition at line 31 of file cl_parser.hpp.

Member Function Documentation

void cass::CommandlineArgumentParser::add ( const std::string &  sw,
const std::string &  desc,
bool &  val 
)
inline

add a switch to the switches container

Parameters
swthe name of the parameter to look for
descthe description of the parameter
vala reference to the value that should be changed.

Definition at line 122 of file cl_parser.hpp.

References _switches.

Referenced by main().

void cass::CommandlineArgumentParser::add ( const std::string &  sw,
const std::string &  desc,
std::string &  val 
)
inline

add a switch to the string container

Parameters
swthe name of the parameter to look for
descthe description of the parameter
vala reference to the value that should be changed.

Definition at line 133 of file cl_parser.hpp.

References _stringargs.

void cass::CommandlineArgumentParser::add ( const std::string &  sw,
const std::string &  desc,
int &  val 
)
inline

add a switch to the int container

Parameters
swthe name of the parameter to look for
descthe description of the parameter
vala reference to the value that should be changed.

Definition at line 144 of file cl_parser.hpp.

References _intargs.

void cass::CommandlineArgumentParser::operator() ( const QStringList argumentList)
inline

operator to parse the argumetns

the arguments are retrieved as a QStringList from Qt. Go through the list and try to find the parameter in the containers. If it is the switches container simply set the switch to true. Otherwise take the next parameter that should be the argument of the preceding parameter. Start at the 2nd argument of the list, since the first is just the program name.

Parameters
argumentListthe list of arguments

Definition at line 78 of file cl_parser.hpp.

References _intargs, _stringargs, _switches, and usage().

void cass::CommandlineArgumentParser::usage ( )
inline

output which commandline parameters are available

Definition at line 40 of file cl_parser.hpp.

References _intargs, _stringargs, and _switches.

Referenced by main(), and operator()().

Member Data Documentation

intarguments_t cass::CommandlineArgumentParser::_intargs
private

container for the int arguments

Definition at line 157 of file cl_parser.hpp.

Referenced by add(), operator()(), and usage().

stringarguments_t cass::CommandlineArgumentParser::_stringargs
private

container for the string arguments

Definition at line 154 of file cl_parser.hpp.

Referenced by add(), operator()(), and usage().

switches_t cass::CommandlineArgumentParser::_switches
private

container for the switches

Definition at line 151 of file cl_parser.hpp.

Referenced by add(), operator()(), and usage().


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