Skip to content
Snippets Groups Projects
Commit b3e267b4 authored by Jö Fahlke's avatar Jö Fahlke
Browse files

[parametertreetest][fs1527] Kill int and double overloads of

ParameterTree::get("key", def).

These overloads were using atoi() resp. atof(), effectively ignoring junk at
the end of values.  This led to the situation where a floating point value
"0.5" could be parsed as an int "0" without any diagnostic.
parent ca29068c
No related branches found
No related tags found
No related merge requests found
...@@ -166,24 +166,6 @@ std::string ParameterTree::get(const std::string& key, const char* defaultValue) ...@@ -166,24 +166,6 @@ std::string ParameterTree::get(const std::string& key, const char* defaultValue)
return defaultValue; return defaultValue;
} }
int ParameterTree::get(const std::string& key, int defaultValue) const
{
std::stringstream stream;
stream << defaultValue;
std::string ret = get(key, stream.str());
return atoi(ret.c_str());
}
double ParameterTree::get(const std::string& key, double defaultValue) const
{
if(hasKey(key))
return atof((*this)[key].c_str());
else
return defaultValue;
}
std::string ParameterTree::ltrim(const std::string& s) std::string ParameterTree::ltrim(const std::string& s)
{ {
std::size_t firstNonWS = s.find_first_not_of(" \t\n\r"); std::size_t firstNonWS = s.find_first_not_of(" \t\n\r");
......
...@@ -141,28 +141,6 @@ namespace Dune { ...@@ -141,28 +141,6 @@ namespace Dune {
std::string get(const std::string& key, const char* defaultValue) const; std::string get(const std::string& key, const char* defaultValue) const;
/** \brief get value as int
*
* Returns value for given key interpreted as int.
*
* \param key key name
* \param defaultValue default if key does not exist
* \return value as int
*/
int get(const std::string& key, int defaultValue) const;
/** \brief get value as double
*
* Returns value for given key interpreted as double.
*
* \param key key name
* \param defaultValue default if key does not exist
* \return value as double
*/
double get(const std::string& key, double defaultValue) const;
/** \brief get value converted to a certain type /** \brief get value converted to a certain type
* *
* Returns value as type T for given key. * Returns value as type T for given key.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment