From 58f5fd2f61ffb4a0ce9e8e4b89c4a74fd7509dae Mon Sep 17 00:00:00 2001 From: evomarc Date: Mon, 5 Nov 2001 16:38:52 +0000 Subject: [PATCH] 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 --- eo/src/utils/eoParser.cpp | 20 ++++++++++++++++++++ eo/src/utils/eoParser.h | 12 +++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/eo/src/utils/eoParser.cpp b/eo/src/utils/eoParser.cpp index 10a2bea4..d7a138d3 100644 --- a/eo/src/utils/eoParser.cpp +++ b/eo/src/utils/eoParser.cpp @@ -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 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 diff --git a/eo/src/utils/eoParser.h b/eo/src/utils/eoParser.h index f95956de..52ef152b 100644 --- a/eo/src/utils/eoParser.h +++ b/eo/src/utils/eoParser.h @@ -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;