32 ParamNames getParamNames(vector<Parameter*> params) {
33 struct HoldsFunction {
34 static auto_ptr<Dummy> dummyCreate() {
35 return auto_ptr<Dummy>(0);
39 ParamNames names(
"option");
40 for (
size_t i = 0; i < params.size(); ++i)
41 names.registerProduct(params[i]->getName(), HoldsFunction::dummyCreate);
47 _paramsDeleter(_ownedParams) {
51 ParamNames names = getParamNames(
_params);
54 while (i < tokenCount) {
55 if (tokens[i][0] !=
'-')
56 reportError(
string(
"Expected an option when reading \"") +
57 tokens[i] +
"\", but options start with a dash (-).\n");
58 string prefix(tokens[i] + 1);
64 while (i + 1 + argCount < tokenCount &&
65 tokens[i + 1 + argCount][0] !=
'-')
76 unsigned int argCount) {
77 for (vector<Parameter*>::iterator it =
_params.begin();
79 if ((*it)->getName() == optionName) {
80 (*it)->processArguments(args, argCount);
107 if ((*it)->getName() == name)
118 if ((*it)->getName() == name)
const string & getString(const CliParams ¶ms, const string &name)
unsigned int getInt(const CliParams ¶ms, const string &name)
bool getBool(const CliParams ¶ms, const string &name)
void setBool(CliParams ¶ms, const string &name, bool newValue)
void exceptionSafePushBack(Container &container, auto_ptr< Element > pointer)
string getUniqueNameWithPrefix(const NameFactory< AbstractProduct > &factory, const string &prefix)
Returns the unique product name that has the indicated prefix, or return prefix itself if it is the a...
vector< Parameter * > _params
void processOption(const string &optionName, const char **params, unsigned int paramCount)
bool hasParam(const string &name) const
vector< Parameter * > _ownedParams
void parseCommandLine(unsigned int tokenCount, const char **tokens)
vector< Parameter * >::const_iterator const_iterator
const Parameter & getParam(const string &name) const
void add(auto_ptr< Parameter > param)
A NameFactory takes a name and then creates an instance of a class that has been previously registere...
vector< Parameter * >::iterator iterator
const string & getName() const
void reportInternalError(const string &errorMsg)
void reportError(const string &errorMsg)
#define INTERNAL_ERROR(msg)