OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CmdArguments Class Reference

Parsing command line arguments. More...

#include <CmdArguments.h>

Public Member Functions

 CmdArguments (int argc, char **argv)
 
 CmdArguments ()
 
 ~CmdArguments ()
 
template<class T >
T getArg (const std::string name, bool isFatal=false)
 
template<class T >
T getArg (const std::string name, T default_value, bool isFatal=false)
 
template<class T >
void addArgument (const std::string &name, const T &value)
 
template<class T >
void replaceArgument (const std::string &name, const T &value)
 
char ** getArguments () const
 
unsigned int getNumArguments () const
 

Private Member Functions

void addArguments (int argc, char **argv)
 parse user arguments More...
 
void split (std::string &name, std::string &value, std::string arg)
 helper to split string More...
 
template<class T >
T arg (const std::string name)
 

Private Attributes

std::map< std::string,
std::string > 
arguments_
 container for storing command line options More...
 
std::set< std::string > warned_
 

Detailed Description

Parsing command line arguments.

In order to have a flexible framework, each component implementation gets access to all command line arguments. All command line options have the form: –name=value Spaces before and after the "=" will be trimmed.

Definition at line 26 of file CmdArguments.h.

Constructor & Destructor Documentation

CmdArguments::CmdArguments ( int  argc,
char **  argv 
)
inline

Definition at line 30 of file CmdArguments.h.

References addArguments().

Here is the call graph for this function:

CmdArguments::CmdArguments ( )
inline

Definition at line 34 of file CmdArguments.h.

CmdArguments::~CmdArguments ( )
inline

Definition at line 37 of file CmdArguments.h.

Member Function Documentation

template<class T >
void CmdArguments::addArgument ( const std::string &  name,
const T value 
)
inline

Definition at line 91 of file CmdArguments.h.

References arguments_.

void CmdArguments::addArguments ( int  argc,
char **  argv 
)
private

parse user arguments

Definition at line 3 of file CmdArguments.cpp.

References arg(), arguments_, name, and split().

Referenced by CmdArguments().

Here is the call graph for this function:

template<class T >
T CmdArguments::arg ( const std::string  name)
inlineprivate

tries to retrieve command line parameter.

Exceptions
OptPilotExceptionif parameter was not found.

Definition at line 156 of file CmdArguments.h.

References arguments_, and T.

Referenced by addArguments().

template<class T >
T CmdArguments::getArg ( const std::string  name,
bool  isFatal = false 
)
inline

Get command line argument without specifying default value.

See Also
getArg

Definition at line 44 of file CmdArguments.h.

References name.

template<class T >
T CmdArguments::getArg ( const std::string  name,
T  default_value,
bool  isFatal = false 
)
inline

Get command line argument with default value. If the parameter is not found either an exception is thrown or a warning is written to stdout and the default value is used (

See Also
isFatal).
Parameters
[in]nameof the command line argument
[in]default_valueof the parameter
[in]isFatalthrow exception if parameter is expected to be present, default is false
Returns
argument value

Definition at line 60 of file CmdArguments.h.

References Physics::e, endl(), name, T, Options::warn, and warned_.

Here is the call graph for this function:

char ** CmdArguments::getArguments ( ) const

Definition at line 25 of file CmdArguments.cpp.

References arguments_.

unsigned int CmdArguments::getNumArguments ( ) const
inline

Definition at line 117 of file CmdArguments.h.

References arguments_.

template<class T >
void CmdArguments::replaceArgument ( const std::string &  name,
const T value 
)
inline

Definition at line 104 of file CmdArguments.h.

References arguments_.

void CmdArguments::split ( std::string &  name,
std::string &  value,
std::string  arg 
)
private

helper to split string

Definition at line 13 of file CmdArguments.cpp.

Referenced by addArguments().

Member Data Documentation

std::map<std::string, std::string> CmdArguments::arguments_
private

container for storing command line options

Definition at line 143 of file CmdArguments.h.

Referenced by addArgument(), addArguments(), arg(), getArguments(), getNumArguments(), and replaceArgument().

std::set<std::string> CmdArguments::warned_
private

Definition at line 145 of file CmdArguments.h.

Referenced by getArg().


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