| 105 | namespace internal { |
| 106 | |
| 107 | std::vector<std::string_view> SplitString(std::string_view v, char delimiter, |
| 108 | int64_t limit) { |
| 109 | std::vector<std::string_view> parts; |
| 110 | size_t start = 0, end; |
| 111 | while (true) { |
| 112 | if (limit > 0 && static_cast<size_t>(limit - 1) <= parts.size()) { |
| 113 | end = std::string::npos; |
| 114 | } else { |
| 115 | end = v.find(delimiter, start); |
| 116 | } |
| 117 | parts.push_back(v.substr(start, end - start)); |
| 118 | if (end == std::string::npos) { |
| 119 | break; |
| 120 | } |
| 121 | start = end + 1; |
| 122 | } |
| 123 | return parts; |
| 124 | } |
| 125 | |
| 126 | template <typename StringLike> |
| 127 | static std::string JoinStringLikes(const std::vector<StringLike>& strings, |