MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / rsplit

Method rsplit

modules/gui/gui/src/backend/text_server/ustring.cpp:1478–1528  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1476}
1477
1478Vector<String> String::rsplit(const String& p_splitter, bool p_allow_empty, int p_maxsplit) const
1479{
1480 Vector<String> ret;
1481 const int len = length();
1482 int remaining_len = len;
1483
1484 while (true)
1485 {
1486 if (remaining_len < p_splitter.length() || (p_maxsplit > 0 && p_maxsplit == ret.size()))
1487 {
1488 // no room for another splitter or hit max splits, push what's left and we're done
1489 if (p_allow_empty || remaining_len > 0)
1490 {
1491 ret.push_back(substr(0, remaining_len));
1492 }
1493 break;
1494 }
1495
1496 int left_edge;
1497 if (p_splitter.is_empty())
1498 {
1499 left_edge = remaining_len - 1;
1500 if (left_edge == 0)
1501 {
1502 left_edge--; // Skip to the < 0 condition.
1503 }
1504 }
1505 else
1506 {
1507 left_edge = rfind(p_splitter, remaining_len - p_splitter.length());
1508 }
1509
1510 if (left_edge < 0)
1511 {
1512 // no more splitters, we're done
1513 ret.push_back(substr(0, remaining_len));
1514 break;
1515 }
1516
1517 int substr_start = left_edge + p_splitter.length();
1518 if (p_allow_empty || substr_start < remaining_len)
1519 {
1520 ret.push_back(substr(substr_start, remaining_len - substr_start));
1521 }
1522
1523 remaining_len = left_edge;
1524 }
1525
1526 ret.reverse();
1527 return ret;
1528}
1529
1530Vector<double> String::split_floats(const String& p_splitter, bool p_allow_empty) const
1531{

Callers 9

__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
load_from_raw_jsonMethod · 0.80
load_from_raw_jsonMethod · 0.80
__init__Method · 0.80
__init__Method · 0.80
set_namesMethod · 0.80
short_nameMethod · 0.80

Calls 7

substrFunction · 0.85
lengthFunction · 0.50
lengthMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
is_emptyMethod · 0.45
reverseMethod · 0.45

Tested by

no test coverage detected