Base class for options.
More...
#include <qpid/Options.h>
|
| Options (const std::string &name=std::string()) |
|
void | parse (int argc, char const *const *argv, const std::string &configfile=std::string(), bool allowUnknown=false) |
| Parses options from argc/argv, environment variables and config file. More...
|
|
bool | findArg (int argc, char const *const *argv, const std::string &theArg) |
| Tests for presence of argc/argv switch. More...
|
|
boost::program_options::options_description_easy_init | addOptions () |
|
Base class for options.
Example of use:
struct MySubOptions :
public Options {
int x;
string y;
MySubOptions() :
Options(
"Sub options") {
(
"y",
optValue(y,
"YUNIT"),
"Option Y");
}
};
struct MyOptions :
public Options {
bool z;
vector<string> foo;
MySubOptions subOptions;
MyOptions() :
Options(
"My Options") {
("z", boolSwitch(z), "Option Z")
(
"foo",
optValue(foo),
"Multiple option foo");
add(subOptions);
}
main(int argc, char** argv) {
opts.parse(argc, char** argv);
dosomething(opts.subOptions.x);
cout << opts << end;
}
Definition at line 135 of file Options.h.
qpid::Options::Options |
( |
const std::string & |
name = std::string() | ) |
|
boost::program_options::options_description_easy_init qpid::Options::addOptions |
( |
| ) |
|
|
inline |
bool qpid::Options::findArg |
( |
int |
argc, |
|
|
char const *const * |
argv, |
|
|
const std::string & |
theArg |
|
) |
| |
Tests for presence of argc/argv switch.
void qpid::Options::parse |
( |
int |
argc, |
|
|
char const *const * |
argv, |
|
|
const std::string & |
configfile = std::string() , |
|
|
bool |
allowUnknown = false |
|
) |
| |
Parses options from argc/argv, environment variables and config file.
Note the filename argument can reference an options variable that is updated by argc/argv or environment variable parsing.
The documentation for this struct was generated from the following file: