From 1c4cdae6636fcd193e6e6d809236d3ef218a70ad Mon Sep 17 00:00:00 2001 From: nojhan Date: Sun, 2 Oct 2011 15:44:51 +0200 Subject: [PATCH 1/4] use the logger to print warnings --- eo/src/utils/eoParser.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/eo/src/utils/eoParser.cpp b/eo/src/utils/eoParser.cpp index 97c4b3d5a..135402927 100644 --- a/eo/src/utils/eoParser.cpp +++ b/eo/src/utils/eoParser.cpp @@ -35,16 +35,11 @@ #include #include - #include +#include using namespace std; -void eoWarning(std::string str) -{ - cout << str << '\n'; -} - std::ostream& printSectionHeader(std::ostream& os, std::string section) { if (section == "") @@ -117,7 +112,6 @@ eoParser::eoParser ( unsigned _argc, char **_argv , string _programDescription, } - eoParam * eoParser::getParamWithLongName(const std::string& _name) const { typedef std::multimap MultiMapType; @@ -130,7 +124,6 @@ eoParam * eoParser::getParamWithLongName(const std::string& _name) const } - void eoParser::processParam(eoParam& param, std::string section) { // this param enters the parser: add the prefix to the long name @@ -214,7 +207,7 @@ void eoParser::readFrom(istream& is) { if (str.size() < 2) { - eoWarning("Missing parameter"); + eo::log << eo::warnings << "Missing parameter" << std::endl; needHelp.value() = true; return; } From ae919bc7123dae7c421f978df2813c5594834843 Mon Sep 17 00:00:00 2001 From: nojhan Date: Sun, 2 Oct 2011 22:22:18 +0200 Subject: [PATCH 2/4] shortcut to get a param value --- eo/src/utils/eoParser.cpp | 6 ++++++ eo/src/utils/eoParser.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/eo/src/utils/eoParser.cpp b/eo/src/utils/eoParser.cpp index 135402927..e97a2a2e7 100644 --- a/eo/src/utils/eoParser.cpp +++ b/eo/src/utils/eoParser.cpp @@ -112,6 +112,12 @@ eoParser::eoParser ( unsigned _argc, char **_argv , string _programDescription, } +std::string eoParser::get( const std::string & name) const +{ + return getParamWithLongName( name )->getValue(); +} + + eoParam * eoParser::getParamWithLongName(const std::string& _name) const { typedef std::multimap MultiMapType; diff --git a/eo/src/utils/eoParser.h b/eo/src/utils/eoParser.h index 0088ff4f1..48b18e915 100644 --- a/eo/src/utils/eoParser.h +++ b/eo/src/utils/eoParser.h @@ -156,6 +156,10 @@ public: virtual bool isItThere(eoParam& _param) const { return getValue(_param).first; } + + std::string get( const std::string & name) const; + + /** * get a handle on a param from its longName * From 59448b9635a1cb4e0dcc659c69935a0193cb7d7e Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 4 Oct 2011 21:43:53 +0200 Subject: [PATCH 3/4] more doc on the parser format --- eo/src/utils/eoParser.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eo/src/utils/eoParser.h b/eo/src/utils/eoParser.h index 48b18e915..e65f7566e 100644 --- a/eo/src/utils/eoParser.h +++ b/eo/src/utils/eoParser.h @@ -97,6 +97,11 @@ private : This class is persistent, so it can be stored and reloaded to restore parameter settings. + Parameters can be read from argv, strings or streams, and must be specified + using the following convention: --name=value or -n=value + + You should not use space as a separator between the parameter and its value. + @ingroup Parameters */ class eoParser : public eoParameterLoader, public eoObject, public eoPersistent From 277a77c8a1009c65fac69368f455e8a187cb167e Mon Sep 17 00:00:00 2001 From: nojhan Date: Thu, 6 Oct 2011 16:40:45 +0200 Subject: [PATCH 4/4] size_t -> std::size_t + header --- eo/src/eoFunctorStore.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eo/src/eoFunctorStore.cpp b/eo/src/eoFunctorStore.cpp index cb8d1a574..43cd778cd 100644 --- a/eo/src/eoFunctorStore.cpp +++ b/eo/src/eoFunctorStore.cpp @@ -3,6 +3,8 @@ #pragma warning(disable:4786) #endif +#include + #include #include @@ -10,7 +12,7 @@ /// clears the memory eoFunctorStore::~eoFunctorStore() { - for(size_t i = 0; i < vec.size(); ++i) { + for( std::size_t i = 0; i < vec.size(); ++i) { delete vec[i]; } }