From 6893a8565d621c9e50a19a60e296d3d2aa5b0615 Mon Sep 17 00:00:00 2001 From: mac Date: Thu, 25 May 2000 13:04:57 +0000 Subject: [PATCH] Removed this ugly defaulting to 1 behaviour and solved it using template specialization --- eo/src/utils/eoParam.h | 15 +++++++++++++++ eo/src/utils/eoParser.cpp | 3 --- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/eo/src/utils/eoParam.h b/eo/src/utils/eoParam.h index fed8a525..4dba2c3b 100644 --- a/eo/src/utils/eoParam.h +++ b/eo/src/utils/eoParam.h @@ -169,6 +169,21 @@ private : ValueType repValue; }; +/// Specialized setValue for bool +template <> +void eoValueParam::setValue(std::string _value) +{ + if (_value.empty()) + { + repValue = true; + return; + } + + std::istrstream is(_value.c_str()); + is >> repValue; +} + + /// Because MSVC does not support partial specialization, the pair is a double, not a T template <> std::string eoValueParam >::getValue(void) const diff --git a/eo/src/utils/eoParser.cpp b/eo/src/utils/eoParser.cpp index 6fd16b2e..cb60c693 100644 --- a/eo/src/utils/eoParser.cpp +++ b/eo/src/utils/eoParser.cpp @@ -79,9 +79,6 @@ void eoParser::doRegisterParam(eoParam& param) const if (value.first) { - if (value.second == "") // it is there, but no value is given, default to "1" - value.second = "1"; // for bool - param.setValue(value.second); } }