https://stackoverflow.com/questions/236129/how-do-i-iterate-over-the-words-of-a-string/236803#236803 */
| 552 | https://stackoverflow.com/questions/236129/how-do-i-iterate-over-the-words-of-a-string/236803#236803 |
| 553 | */ |
| 554 | std::vector<std::string> Helper::splitString(std::string sep, std::string str, size_t maxSplits) { |
| 555 | std::vector<std::string> tokens; |
| 556 | std::size_t start = 0; |
| 557 | std::size_t end = 0; |
| 558 | std::size_t splitLen = sep.size(); |
| 559 | while( (end = str.find(sep, start)) != std::string::npos ) { |
| 560 | tokens.push_back( str.substr(start, end - start) ); |
| 561 | start = end + splitLen; |
| 562 | if( maxSplits > 0 && tokens.size() == maxSplits ) |
| 563 | break; |
| 564 | } |
| 565 | tokens.push_back(str.substr(start)); |
| 566 | return tokens; |
| 567 | } |
| 568 | |
| 569 | |
| 570 | /** |