| 584 | } |
| 585 | |
| 586 | inline void split(const std::string &text, char sep, std::vector<std::string> &tokens, bool skip_empty = false) |
| 587 | { |
| 588 | if (tokens.size() > 0) tokens.clear(); |
| 589 | std::size_t start = 0, end = 0; |
| 590 | while (true) |
| 591 | { |
| 592 | end = text.find(sep, start); |
| 593 | if (end == std::string::npos) |
| 594 | { |
| 595 | if (start < text.size()) |
| 596 | tokens.push_back(text.substr(start)); |
| 597 | else if (!skip_empty) |
| 598 | tokens.push_back(""); |
| 599 | break; |
| 600 | } |
| 601 | std::string subs = text.substr(start, end - start); |
| 602 | if (skip_empty) |
| 603 | { |
| 604 | if (subs.size() > 0) |
| 605 | tokens.push_back(subs); |
| 606 | } |
| 607 | else |
| 608 | { |
| 609 | tokens.push_back(subs); |
| 610 | } |
| 611 | start = end + 1; |
| 612 | } |
| 613 | } |
| 614 | |
| 615 | struct concatenator { |
| 616 | template<class T> |
no test coverage detected