split a long string into vectors by whitespace * line - input string * line_vec - output vector * delimiter - delimiter */
| 2552 | * line_vec - output vector |
| 2553 | * delimiter - delimiter */ |
| 2554 | void split(const string &line, vector<string> &line_vec, |
| 2555 | const char delimiter=' ') |
| 2556 | { |
| 2557 | bool within_word = false; |
| 2558 | for (size_t pos=0;pos<line.size();pos++) |
| 2559 | { |
| 2560 | if (line[pos]==delimiter) |
| 2561 | { |
| 2562 | within_word = false; |
| 2563 | continue; |
| 2564 | } |
| 2565 | if (!within_word) |
| 2566 | { |
| 2567 | within_word = true; |
| 2568 | line_vec.push_back(""); |
| 2569 | } |
| 2570 | line_vec.back()+=line[pos]; |
| 2571 | } |
| 2572 | } |
| 2573 | |
| 2574 | /* strip white space at the begining or end of string */ |
| 2575 | string Trim(const string &inputString) |
no outgoing calls
no test coverage detected