Added method
eoParam* getParamWithLongName(std::string _name); so now you can get a parameter in another place than where it was defined just by giving its name
This commit is contained in:
parent
aee6584cea
commit
58f5fd2f61
2 changed files with 31 additions and 1 deletions
|
|
@ -79,6 +79,26 @@ eoParser::eoParser ( unsigned _argc, char **_argv , string _programDescription,
|
|||
processParam(needHelp);
|
||||
}
|
||||
|
||||
/**
|
||||
* get a handle on a param from its longName
|
||||
*
|
||||
* if not found, returns 0 (null pointer :-)
|
||||
*
|
||||
* Not very clean (requires hard-coding of the long name twice!)
|
||||
* but very useful in many occasions...
|
||||
*/
|
||||
eoParam* eoParser::getParamWithLongName(std::string _name)
|
||||
{
|
||||
typedef std::multimap<std::string, eoParam*> MultiMapType;
|
||||
typedef MultiMapType::const_iterator It;
|
||||
for (It p = params.begin(); p != params.end(); ++p)
|
||||
{
|
||||
if (p->second->longName() == _name)
|
||||
return p->second;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void eoParser::processParam(eoParam& param, std::string section)
|
||||
{
|
||||
doRegisterParam(param); // plainly register it
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
/**
|
||||
CVS Info: $Date: 2001-04-10 15:08:09 $ $Version$ $Author: evomarc $
|
||||
CVS Info: $Date: 2001-11-05 16:38:51 $ $Version$ $Author: evomarc $
|
||||
*/
|
||||
#ifndef eoParser_h
|
||||
#define eoParser_h
|
||||
|
|
@ -149,6 +149,16 @@ public:
|
|||
virtual bool isItThere(eoParam& _param) const
|
||||
{ return getValue(_param).first; }
|
||||
|
||||
/**
|
||||
* get a handle on a param from its longName
|
||||
*
|
||||
* if not found, returns 0 (null pointer :-)
|
||||
*
|
||||
* Not very clean (requires hard-coding of the long name twice!)
|
||||
* but very useful in many occasions...
|
||||
*/
|
||||
eoParam* getParamWithLongName(std::string _name);
|
||||
|
||||
private:
|
||||
|
||||
void doRegisterParam(eoParam& param) const;
|
||||
|
|
|
|||
Reference in a new issue