///////////////////////////////////////////////////////////////////////////
| 142 | |
| 143 | //////////////////////////////////////////////////////////////////////////////// |
| 144 | std::vector<sf::String> explode(const sf::String& string, sf::Uint32 delimiter) |
| 145 | { |
| 146 | if (string.isEmpty()) |
| 147 | return std::vector<sf::String>(); |
| 148 | |
| 149 | // For each character in the string |
| 150 | std::vector<sf::String> result; |
| 151 | sf::String buffer; |
| 152 | for (sf::Uint32 character : string) |
| 153 | { |
| 154 | // If we've hit the delimiter character |
| 155 | if (character == delimiter) |
| 156 | { |
| 157 | // Add them to the result vector |
| 158 | result.push_back(buffer); |
| 159 | buffer.clear(); |
| 160 | } |
| 161 | else |
| 162 | { |
| 163 | // Accumulate the next character into the sequence |
| 164 | buffer += character; |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | // Add to the result if buffer still has contents or if the last character is a delimiter |
| 169 | if (!buffer.isEmpty() || string[string.getSize() - 1] == delimiter) |
| 170 | result.push_back(buffer); |
| 171 | |
| 172 | return result; |
| 173 | } |
| 174 | |
| 175 | |
| 176 | //////////////////////////////////////////////////////////////////////////////// |
no test coverage detected