| 163 | // ------------------------------------------------------------------------------------ |
| 164 | |
| 165 | inline std::vector<int> parse_int_array(const std::string& str) |
| 166 | /*! |
| 167 | ensures |
| 168 | - Parses a comma-separated string of integers |
| 169 | - Returns a vector containing the parsed integers |
| 170 | - Whitespace around numbers is automatically stripped |
| 171 | !*/ |
| 172 | { |
| 173 | std::vector<int> result; |
| 174 | std::stringstream ss(str); |
| 175 | std::string segment; |
| 176 | while (std::getline(ss, segment, ',')) |
| 177 | { |
| 178 | segment.erase(0, segment.find_first_not_of(" \t\n\r")); |
| 179 | segment.erase(segment.find_last_not_of(" \t\n\r") + 1); |
| 180 | if (!segment.empty()) |
| 181 | result.push_back(std::stoi(segment)); |
| 182 | } |
| 183 | return result; |
| 184 | } |
| 185 | |
| 186 | // ------------------------------------------------------------------------------------ |
| 187 |
no test coverage detected