MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / parse_u32_value

Function parse_u32_value

src/framework/runtime/options.cpp:34–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

parse_u32_optionFunction · 0.85

Calls 4

maxFunction · 0.85
stringFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected