| 47 | } |
| 48 | return static_cast<uint32_t>(out); |
| 49 | } |
| 50 | |
| 51 | uint64_t parse_u64_value(const std::string & value, std::string_view key) { |
| 52 | if (!value.empty() && value.front() == '-') { |
| 53 | throw std::runtime_error(std::string(key) + " must be an unsigned integer"); |
| 54 | } |
| 55 | size_t parsed = 0; |
| 56 | const unsigned long long out = std::stoull(value, &parsed); |
| 57 | if (parsed != value.size()) { |
| 58 | throw std::runtime_error(std::string(key) + " must be an unsigned integer"); |
| 59 | } |
| 60 | if (out > std::numeric_limits<uint64_t>::max()) { |
| 61 | throw std::runtime_error(std::string(key) + " is outside uint64 range"); |
| 62 | } |
| 63 | return static_cast<uint64_t>(out); |
| 64 | } |
| 65 |
no test coverage detected