| 32 | } |
| 33 | |
| 34 | uint32_t parse_u32_value(const std::string & value, std::string_view key) { |
| 35 | if (!value.empty() && value.front() == '-') { |
| 36 | throw std::runtime_error(std::string(key) + " must be an unsigned integer"); |
| 37 | } |
| 38 | size_t parsed = 0; |
| 39 | const unsigned long out = std::stoul(value, &parsed); |
| 40 | if (parsed != value.size()) { |
| 41 | throw std::runtime_error(std::string(key) + " must be an unsigned integer"); |
| 42 | } |
| 43 | if (out > std::numeric_limits<uint32_t>::max()) { |
| 44 | throw std::runtime_error(std::string(key) + " is outside uint32 range"); |
| 45 | } |
| 46 | return static_cast<uint32_t>(out); |
| 47 | } |
| 48 | |
| 49 | uint64_t parse_u64_value(const std::string & value, std::string_view key) { |
| 50 | if (!value.empty() && value.front() == '-') { |
no test coverage detected