Program options parser.
More...
#include <programOptions.hpp>
|
| ProgramOptions (ErrorBufferInterface *errorhnd_) |
| Default constructor. More...
|
|
| ProgramOptions (const ProgramOptions &o) |
| Copy constructor. More...
|
|
| ProgramOptions (ErrorBufferInterface *errorhnd_, int argc_, const char **argv_, int nofopt,...) |
| Constructor. More...
|
|
bool | operator() (const std::string &optname) const |
| Test if an option specified by its long name is defined. More...
|
|
const char * | operator[] (std::size_t idx) const |
| Get the value of an argument specified by its index. More...
|
|
const char * | operator[] (const std::string &optname) const |
| Get the value of an option specified by its long name. More...
|
|
int | asInt (const std::string &optname) const |
| Get the value of an option specified by its long name as signed integer. More...
|
|
unsigned int | asUint (const std::string &optname) const |
| Get the value of an option specified by its long name as unsigned integer. More...
|
|
double | asDouble (const std::string &optname) const |
| Get the value of an option specified by its long name as unsigned integer. More...
|
|
std::vector< std::string > | list (const std::string &optname) const |
| Get the list of values of an option specified by its long name. More...
|
|
int | nofargs () const |
| Get the number of program arguments. More...
|
|
const char ** | argv () const |
| Get the list of program arguments. More...
|
|
void | print (std::ostream &out) |
| Print all proram options defined. More...
|
|
strus::ProgramOptions::ProgramOptions |
( |
ErrorBufferInterface * |
errorhnd_, |
|
|
int |
argc_, |
|
|
const char ** |
argv_, |
|
|
int |
nofopt, |
|
|
|
... |
|
) |
| |
const char** strus::ProgramOptions::argv |
( |
| ) |
const |
Get the list of program arguments.
- Returns
- the list of program arguments without options and the program name
double strus::ProgramOptions::asDouble |
( |
const std::string & |
optname | ) |
const |
Get the value of an option specified by its long name as unsigned integer.
- Parameters
-
[in] | optname | long name of the option |
- Returns
- the option value as integer or 0 on failure
int strus::ProgramOptions::asInt |
( |
const std::string & |
optname | ) |
const |
Get the value of an option specified by its long name as signed integer.
- Parameters
-
[in] | optname | long name of the option |
- Returns
- the option value as integer or 0 on failure
unsigned int strus::ProgramOptions::asUint |
( |
const std::string & |
optname | ) |
const |
Get the value of an option specified by its long name as unsigned integer.
- Parameters
-
[in] | optname | long name of the option |
- Returns
- the option value as integer or 0 on failure
std::vector<std::string> strus::ProgramOptions::list |
( |
const std::string & |
optname | ) |
const |
Get the list of values of an option specified by its long name.
- Parameters
-
[in] | optname | long name of the option |
- Returns
- the option values as vector, empty on failure
int strus::ProgramOptions::nofargs |
( |
| ) |
const |
Get the number of program arguments.
- Returns
- the number of program arguments without options and the program name
bool strus::ProgramOptions::operator() |
( |
const std::string & |
optname | ) |
const |
Test if an option specified by its long name is defined.
const char* strus::ProgramOptions::operator[] |
( |
std::size_t |
idx | ) |
const |
Get the value of an argument specified by its index.
- Parameters
-
[in] | index | of the argument starting with 0 |
- Note
- first argument (not the program name!) has index 0
- Returns
- the argument value as string or NULL on failure
const char* strus::ProgramOptions::operator[] |
( |
const std::string & |
optname | ) |
const |
Get the value of an option specified by its long name.
- Parameters
-
[in] | optname | long name of the option |
- Returns
- the option value as string or NULL on failure
void strus::ProgramOptions::print |
( |
std::ostream & |
out | ) |
|
Print all proram options defined.
- Parameters
-
[in] | where | to print the options to |
The documentation for this class was generated from the following file: