gazebosim/gz-common

Helper functions for conversions that are locale independent

オープン

#233 opened on 2021/07/26

 (3 件のコメント) (0 件のリアクション) (0 人の担当者)C++ (59 件のフォーク)auto 404
enhancementhelp wanted

Repository metrics

Stars
 (28 個のスター)
PR merge metrics
 (平均マージ 9d 6h) (30d で 30 merged PRs)

説明

Desired behavior

Different software in the Ignition family uses all kind of C/C++ functions to convert between types that are locale dependent and make functionality to fail under non C locales. Examples are:

Trying to complete the list (split due to limitations in github search) based on https://www.gnu.org/software/libc/manual/html_node/Parsing-of-Numbers.html:

Alternatives considered

There is a native function in C++17 https://en.cppreference.com/w/cpp/utility/to_chars which is not available in all supported platforms at this time. The boost::lexical_cast could be an option but would be ideal not to depend on boost if possible.

Implementation suggestion

I think that the best approach would be to implement helper functions that encapsulate the implementation in this ign-common repository. The implementation can rely on to_chars if C++17 is available or use other workarounds (see https://github.com/ros/urdfdom_headers/pull/42).

A similar work was done for sdformat years ago. Following the locale_fix test can lead to details.

コントリビューターガイド