| 31 | } |
| 32 | |
| 33 | std::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 | |
| 52 | void require_positive(float value, const char * name) { |
| 53 | if (!(value > 0.0F) || !std::isfinite(value)) { |
no test coverage detected