String manipulation functions Specify the delimiter and wrapper to split the string.
| 42 | // String manipulation functions |
| 43 | // Specify the delimiter and wrapper to split the string. |
| 44 | std::vector<std::wstring> StringSplit(std::wstring_view str, |
| 45 | const wchar_t delim, |
| 46 | std::wstring_view enclosure) { |
| 47 | std::vector<std::wstring> result; |
| 48 | auto parts = std::views::split(str, delim); |
| 49 | for (const auto& part : parts) { |
| 50 | std::wstring_view part_sv(part); |
| 51 | if (!enclosure.empty()) { |
| 52 | if (!part_sv.empty() && part_sv.front() == enclosure.front()) { |
| 53 | part_sv.remove_prefix(1); |
| 54 | } |
| 55 | if (!part_sv.empty() && part_sv.back() == enclosure.back()) { |
| 56 | part_sv.remove_suffix(1); |
| 57 | } |
| 58 | } |
| 59 | result.emplace_back(part_sv); |
| 60 | } |
| 61 | return result; |
| 62 | } |
| 63 | |
| 64 | std::vector<std::string> StringSplit(std::string_view str, |
| 65 | const char delim, |
no outgoing calls
no test coverage detected