| 278 | |
| 279 | template<typename T, typename TParseElementFunc> |
| 280 | std::vector<T> ParseArrayImpl(std::istream& stream, TParseElementFunc parseElementFunc, const char* chars = "\t ,:") |
| 281 | { |
| 282 | std::vector<T> result; |
| 283 | // Processes line-by-line. |
| 284 | std::string line; |
| 285 | while (std::getline(stream, line)) |
| 286 | { |
| 287 | std::vector<std::string> tokens = armnn::stringUtils::StringTokenizer(line, chars); |
| 288 | for (const std::string& token : tokens) |
| 289 | { |
| 290 | if (!token.empty()) // See https://stackoverflow.com/questions/10437406/ |
| 291 | { |
| 292 | try |
| 293 | { |
| 294 | result.push_back(parseElementFunc(token)); |
| 295 | } |
| 296 | catch (const std::exception&) |
| 297 | { |
| 298 | ARMNN_LOG(error) << "'" << token << "' is not a valid number. It has been ignored."; |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | return result; |
| 305 | } |
nothing calls this directly
no test coverage detected