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
34uint32_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
49uint64_t parse_u64_value(const std::string & value, std::string_view key) {
50 if (!value.empty() && value.front() == '-') {

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