Skip to content

Use locale independent conversion from double to string (#1099)#1155

Closed
davetcoleman wants to merge 1 commit intomoveit:melodic-develfrom
davetcoleman:melodic-locale
Closed

Use locale independent conversion from double to string (#1099)#1155
davetcoleman wants to merge 1 commit intomoveit:melodic-develfrom
davetcoleman:melodic-locale

Conversation

@davetcoleman
Copy link
Copy Markdown
Member

Cherry pick of e855e7f

* Use locale independent conversion from double to string

boost::lexical_cast<std::string>(0.1) returns "0,1" on Dutch, German and probably some other locales
which boost::lexical_cast<double> fails to parse even on Dutch, German etc locales

so this commit uses std::ostringstream which seems to be the only sane way to ignore locale

* clang format

* use std::locale::classic() instead of std::locale()

std::locale() copies the global locale, which is already used at construction time of std::stringstream. So this was a noop.
The global locale defaults to std::locale::classic() but it might have been set somewhere else before,
 so explicitly setting std::locale::classic() makes this code independent of locale settings elsewhere.

* factor out conversion from double/float to string into moveit_utils

* clang format

* more explicit description

Co-Authored-By: simonschmeisser <s.schmeisser@gmx.net>

* adress documentation comments

* add and use conversion functions from string to double

* Don't write localized doubles to benchmark results

* use template internally to avoid code duplication

* Add error handling for std::string->float/double

now throws a std::runtime_exception if errors occur.
For planners this gets caught in planning_pipeline::PlanningPipeline::generatePlan
and there are no further users of toDouble/toFloat currently

* remove extra parantheses again

* Code review comments by Dave
@rhaschke
Copy link
Copy Markdown
Contributor

This contains many merge conflicts. Replacing it by #1160.

@davetcoleman davetcoleman deleted the melodic-locale branch October 26, 2018 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants