| 223 | requires(std::is_same_v<StringType, std::string_view> || |
| 224 | std::is_same_v<StringType, std::string>) |
| 225 | inline std::vector<StringType> SplitToVec(std::string_view source, |
| 226 | std::string_view sep, |
| 227 | bool trim = true, |
| 228 | bool clear = true) { |
| 229 | std::vector<StringType> result; |
| 230 | if (source.empty() || sep.empty()) return result; |
| 231 | |
| 232 | size_t pos_end = 0, pos_start = 0; |
| 233 | do { |
| 234 | pos_end = source.find(sep, pos_start); |
| 235 | if (pos_end == std::string_view::npos) pos_end = source.length(); |
| 236 | |
| 237 | auto sub_str = source.substr(pos_start, pos_end - pos_start); |
| 238 | |
| 239 | if (trim) Trim(sub_str); |
| 240 | |
| 241 | if (!(clear && sub_str.empty())) result.emplace_back(sub_str); |
| 242 | |
| 243 | pos_start = pos_end + sep.size(); |
| 244 | } while (pos_end < source.length()); |
| 245 | |
| 246 | return result; |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * @brief splicing vector to string |
nothing calls this directly
no outgoing calls
no test coverage detected