split a long string into vectors by whitespace * line - input string * line_vec - output vector * delimiter - delimiter */
| 331 | * line_vec - output vector |
| 332 | * delimiter - delimiter */ |
| 333 | void split(const string &line, vector<string> &line_vec, |
| 334 | const char delimiter=' ') |
| 335 | { |
| 336 | bool within_word = false; |
| 337 | for (int pos=0;pos<line.size();pos++) |
| 338 | { |
| 339 | if (line[pos]==delimiter) |
| 340 | { |
| 341 | within_word = false; |
| 342 | continue; |
| 343 | } |
| 344 | if (!within_word) |
| 345 | { |
| 346 | within_word = true; |
| 347 | line_vec.push_back(""); |
| 348 | } |
| 349 | line_vec.back()+=line[pos]; |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | /* strip white space at the begining or end of string */ |
| 354 | string Trim(const string &inputString) |
no outgoing calls
no test coverage detected