8 #ifndef _STRUS_BASE_PROGRAM_OPTIONS_HPP_INCLUDED
9 #define _STRUS_BASE_PROGRAM_OPTIONS_HPP_INCLUDED
24 :m_errorhnd(errorhnd_),m_argc(0),m_argv(0){}
28 :m_errorhnd(o.m_errorhnd),m_argc(o.m_argc),m_argv(o.m_argv),m_opt(o.m_opt){}
34 bool operator()(
const std::string& optname)
const;
40 const char*
operator[]( std::size_t idx)
const;
45 const char*
operator[](
const std::string& optname)
const;
50 int asInt(
const std::string& optname)
const;
55 unsigned int asUint(
const std::string& optname)
const;
60 double asDouble(
const std::string& optname)
const;
65 std::vector<std::string>
list(
const std::string& optname)
const;
73 const char**
argv()
const;
77 void print( std::ostream& out);
86 void add(
const char* arg);
88 bool getOpt(
const char*
argv, std::vector<std::string>& optlist, std::string& optarg);
90 ErrorBufferInterface* m_errorhnd;
91 std::map<std::string,bool> m_longnamemap;
92 std::map<char,std::string> m_aliasmap;
96 ErrorBufferInterface* m_errorhnd;
99 typedef std::multimap<std::string,std::string> OptMap;
100 typedef std::pair<std::string,std::string> OptMapElem;
ProgramOptions(const ProgramOptions &o)
Copy constructor.
Definition: programOptions.hpp:27
const char * operator[](std::size_t idx) const
Get the value of an argument specified by its index.
int nofargs() const
Get the number of program arguments.
unsigned int asUint(const std::string &optname) const
Get the value of an option specified by its long name as unsigned integer.
int asInt(const std::string &optname) const
Get the value of an option specified by its long name as signed integer.
std::vector< std::string > list(const std::string &optname) const
Get the list of values of an option specified by its long name.
ProgramOptions(ErrorBufferInterface *errorhnd_)
Default constructor.
Definition: programOptions.hpp:23
Program options parser.
Definition: programOptions.hpp:19
void print(std::ostream &out)
Print all proram options defined.
Interface for reporting and catching errors in modules.
Definition: errorBufferInterface.hpp:24
Interface for reporting and catching errors.
double asDouble(const std::string &optname) const
Get the value of an option specified by its long name as unsigned integer.
bool operator()(const std::string &optname) const
Test if an option specified by its long name is defined.
const char ** argv() const
Get the list of program arguments.