| 1331 | } |
| 1332 | |
| 1333 | String String::get_slicec(char32_t p_splitter, int p_slice) const |
| 1334 | { |
| 1335 | if (is_empty()) |
| 1336 | { |
| 1337 | return String(); |
| 1338 | } |
| 1339 | |
| 1340 | if (p_slice < 0) |
| 1341 | { |
| 1342 | return String(); |
| 1343 | } |
| 1344 | |
| 1345 | const char32_t* c = this->ptr(); |
| 1346 | int i = 0; |
| 1347 | int prev = 0; |
| 1348 | int count = 0; |
| 1349 | while (true) |
| 1350 | { |
| 1351 | if (c[i] == 0 || c[i] == p_splitter) |
| 1352 | { |
| 1353 | if (p_slice == count) |
| 1354 | { |
| 1355 | return substr(prev, i - prev); |
| 1356 | } |
| 1357 | else if (c[i] == 0) |
| 1358 | { |
| 1359 | return String(); |
| 1360 | } |
| 1361 | else |
| 1362 | { |
| 1363 | count++; |
| 1364 | prev = i + 1; |
| 1365 | } |
| 1366 | } |
| 1367 | |
| 1368 | i++; |
| 1369 | } |
| 1370 | } |
| 1371 | |
| 1372 | Vector<String> String::split_spaces() const |
| 1373 | { |
no test coverage detected