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

Function parse_int

Rapfi/external/cpptoml/include/cpptoml.h:2787–2810  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2785 }
2786
2787 std::shared_ptr<value<int64_t>> parse_int(std::string::iterator& it,
2788 const std::string::iterator& end,
2789 int base = 10,
2790 const char* prefix = "")
2791 {
2792 std::string v{it, end};
2793 v = prefix + v;
2794 v.erase(std::remove(v.begin(), v.end(), '_'), v.end());
2795 it = end;
2796 try
2797 {
2798 return make_value<int64_t>(std::stoll(v, nullptr, base));
2799 }
2800 catch (const std::invalid_argument& ex)
2801 {
2802 throw_parse_exception("Malformed number (invalid argument: "
2803 + std::string{ex.what()} + ")");
2804 }
2805 catch (const std::out_of_range& ex)
2806 {
2807 throw_parse_exception("Malformed number (out of range: "
2808 + std::string{ex.what()} + ")");
2809 }
2810 }
2811
2812 std::shared_ptr<value<double>> parse_float(std::string::iterator& it,
2813 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