Line data Source code
1 : #include <string> 2 : #include <vector> 3 : 4 : class Util { 5 : 6 : public: 7 34 : static std::vector<std::string> split(const std::string &text, char sep) { 8 34 : std::vector<std::string> tokens; 9 34 : std::size_t start = 0, end = 0; 10 102 : while ((end = text.find(sep, start)) != std::string::npos) { 11 136 : tokens.push_back(text.substr(start, end - start)); 12 68 : start = end + 1; 13 : } 14 68 : tokens.push_back(text.substr(start)); 15 34 : return tokens; 16 0 : } 17 : };