string toolkit
| 40 | |
| 41 | // string toolkit |
| 42 | static inline void split(std::string_view src, std::string_view token, strArray& vect) |
| 43 | { |
| 44 | size_t nend = 0; |
| 45 | size_t nbegin = 0; |
| 46 | size_t tokenSize = token.size(); |
| 47 | while (nend != std::string::npos) |
| 48 | { |
| 49 | nend = src.find(token, nbegin); |
| 50 | if (nend == std::string::npos) |
| 51 | vect.emplace_back(std::string{src.substr(nbegin, src.length() - nbegin)}); |
| 52 | else |
| 53 | vect.emplace_back(std::string{src.substr(nbegin, nend - nbegin)}); |
| 54 | nbegin = nend + tokenSize; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | // first, judge whether the form of the string like this: {x,y} |
| 59 | // if the form is right,the string will be split into the parameter strs; |
no test coverage detected