| 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) |
no test coverage detected