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

#include <CmdArguments.h>

Public Member Functions

 CmdArguments (int argc, char **argv)
 
 CmdArguments ()
 
 ~CmdArguments ()
 
template<class T >
getArg (const std::string name, bool isFatal=false)
 
template<class 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 >
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

Definition at line 42 of file CmdArguments.h.

Constructor & Destructor Documentation

◆ CmdArguments() [1/2]

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

Definition at line 46 of file CmdArguments.h.

References addArguments().

Here is the call graph for this function:

◆ CmdArguments() [2/2]

CmdArguments::CmdArguments ( )
inline

Definition at line 50 of file CmdArguments.h.

◆ ~CmdArguments()

CmdArguments::~CmdArguments ( )
inline

Definition at line 53 of file CmdArguments.h.

Member Function Documentation

◆ addArgument()

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

Definition at line 107 of file CmdArguments.h.

References arguments_, and name.

◆ addArguments()

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

parse user arguments

Definition at line 32 of file CmdArguments.cpp.

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

Referenced by CmdArguments().

Here is the call graph for this function:

◆ arg()

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 179 of file CmdArguments.h.

References arguments_, name, and Attrib::Legacy::Distribution::T.

Referenced by addArguments(), and split().

◆ getArg() [1/2]

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 60 of file CmdArguments.h.

References name.

◆ getArg() [2/2]

template<class T >
T CmdArguments::getArg ( const std::string  name,
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 76 of file CmdArguments.h.

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

Here is the call graph for this function:

◆ getArguments()

char ** CmdArguments::getArguments ( ) const

Definition at line 54 of file CmdArguments.cpp.

References arguments_, and end().

Here is the call graph for this function:

◆ getNumArguments()

unsigned int CmdArguments::getNumArguments ( ) const
inline

Definition at line 133 of file CmdArguments.h.

References arguments_.

◆ replaceArgument()

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

Definition at line 120 of file CmdArguments.h.

References arguments_, and name.

◆ split()

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

helper to split string

Definition at line 42 of file CmdArguments.cpp.

References arg(), and name.

Referenced by addArguments().

Here is the call graph for this function:

Member Data Documentation

◆ arguments_

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

container for storing command line options

Definition at line 159 of file CmdArguments.h.

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

◆ warned_

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

Definition at line 161 of file CmdArguments.h.

Referenced by getArg().


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