From f97cbceba9827629c6f010554513219a828d9592 Mon Sep 17 00:00:00 2001 From: Simon Schmeisser Date: Wed, 24 Oct 2018 11:46:06 +0200 Subject: [PATCH] use helper function strToDouble for locale independent parsing of colors --- urdf_model/include/urdf_model/color.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/urdf_model/include/urdf_model/color.h b/urdf_model/include/urdf_model/color.h index 505d9a6..46915a5 100644 --- a/urdf_model/include/urdf_model/color.h +++ b/urdf_model/include/urdf_model/color.h @@ -73,13 +73,10 @@ class Color { try { - rgba.push_back(std::stof(pieces[i])); + rgba.push_back(strToDouble(pieces[i].c_str())); } - catch (std::invalid_argument &/*e*/) { - return false; - } - catch (std::out_of_range &/*e*/) { - return false; + catch (std::runtime_error &/*e*/) { + throw ParseError("Unable to parse component [" + pieces[i] + "] to a double (while parsing a color value)"); } } }