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

Function split_float_list

src/models/stable_audio/request.cpp:33–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31}
32
33std::vector<float> split_float_list(const std::string & value, const char * option_name) {
34 std::vector<float> out;
35 std::stringstream stream(value);
36 std::string item;
37 while (std::getline(stream, item, ',')) {
38 item = trim(item);
39 if (item.empty()) {
40 throw std::runtime_error(std::string(option_name) + " contains an empty value");
41 }
42 size_t parsed = 0;
43 const float parsed_value = std::stof(item, &parsed);
44 if (parsed != item.size() || !std::isfinite(parsed_value)) {
45 throw std::runtime_error(std::string(option_name) + " must contain finite floats");
46 }
47 out.push_back(parsed_value);
48 }
49 return out;
50}
51
52void require_positive(float value, const char * name) {
53 if (!(value > 0.0F) || !std::isfinite(value)) {

Callers 2

durations_from_requestFunction · 0.85

Calls 4

trimFunction · 0.70
stringFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected