Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation
Classes | Public Member Functions | List of all members
qpid::Options Struct Reference

Base class for options. More...

#include <qpid/Options.h>

Classes

struct  Exception
 

Public Member Functions

 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 ()
 

Detailed Description

Base class for options.

Example of use:

struct MySubOptions : public Options {
int x;
string y;
MySubOptions() : Options("Sub options") {
("x", optValue(x,"XUNIT"), "Option X")
("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) {
Options opts;
opts.parse(argc, char** argv);
// Use values
dosomething(opts.subOptions.x);
if (error)
cout << opts << end; // Help message.
}

Definition at line 145 of file Options.h.

Constructor & Destructor Documentation

qpid::Options::Options ( const std::string &  name = std::string())

Member Function Documentation

boost::program_options::options_description_easy_init qpid::Options::addOptions ( )
inline

Definition at line 168 of file Options.h.

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:

Qpid C++ API Reference
Generated on Tue Jan 27 2015 for Qpid C++ Client API by doxygen 1.8.9.1