MCPcopy Create free account
hub / github.com/dhbloo/rapfi / parse_float

Function parse_float

Rapfi/external/cpptoml/include/cpptoml.h:2812–2834  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2810 }
2811
2812 std::shared_ptr<value<double>> parse_float(std::string::iterator& it,
2813 const std::string::iterator& end)
2814 {
2815 std::string v{it, end};
2816 v.erase(std::remove(v.begin(), v.end(), '_'), v.end());
2817 it = end;
2818 char decimal_point = std::localeconv()->decimal_point[0];
2819 std::replace(v.begin(), v.end(), '.', decimal_point);
2820 try
2821 {
2822 return make_value<double>(std::stod(v));
2823 }
2824 catch (const std::invalid_argument& ex)
2825 {
2826 throw_parse_exception("Malformed number (invalid argument: "
2827 + std::string{ex.what()} + ")");
2828 }
2829 catch (const std::out_of_range& ex)
2830 {
2831 throw_parse_exception("Malformed number (out of range: "
2832 + std::string{ex.what()} + ")");
2833 }
2834 }
2835
2836 std::shared_ptr<value<bool>> parse_bool(std::string::iterator& it,
2837 const std::string::iterator& end)

Callers 1

parse_numberFunction · 0.85

Calls 5

throw_parse_exceptionFunction · 0.85
whatMethod · 0.80
eraseMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected