MCPcopy Create free account
hub / github.com/davisking/dlib / parse_int_array

Function parse_int_array

dlib/data_io/arc_agi.h:165–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

parse_arc_gridFunction · 0.85

Calls 3

eraseMethod · 0.80
emptyMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected