MCPcopy Create free account
hub / github.com/OpenHD/OpenHD / string_to_float

Method string_to_float

OpenHD/ohd_common/src/openhd_util.cpp:152–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152std::optional<float> OHDUtil::string_to_float(const std::string& s) {
153 try {
154 auto ret = std::stof(s);
155 return ret;
156 } catch (...) {
157 openhd::log::get_default()->warn("Cannot convert [{}] to float", s);
158 return std::nullopt;
159 }
160}
161
162std::optional<long> OHDUtil::string_to_long_hex(const std::string& s) {
163 if (!contains(s, "0x")) return std::nullopt;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected