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

Method split

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

Source from the content-addressed store, hash-verified

1414}
1415
1416Vector<String> String::split(const String& p_splitter, bool p_allow_empty, int p_maxsplit) const
1417{
1418 Vector<String> ret;
1419
1420 if (is_empty())
1421 {
1422 if (p_allow_empty)
1423 {
1424 ret.push_back("");
1425 }
1426 return ret;
1427 }
1428
1429 int from = 0;
1430 int len = length();
1431
1432 while (true)
1433 {
1434 int end;
1435 if (p_splitter.is_empty())
1436 {
1437 end = from + 1;
1438 }
1439 else
1440 {
1441 end = find(p_splitter, from);
1442 if (end < 0)
1443 {
1444 end = len;
1445 }
1446 }
1447 if (p_allow_empty || (end > from))
1448 {
1449 if (p_maxsplit <= 0)
1450 {
1451 ret.push_back(substr(from, end - from));
1452 }
1453 else
1454 {
1455 // Put rest of the string and leave cycle.
1456 if (p_maxsplit == ret.size())
1457 {
1458 ret.push_back(substr(from, len));
1459 break;
1460 }
1461
1462 // Otherwise, push items until positive limit is reached.
1463 ret.push_back(substr(from, end - from));
1464 }
1465 }
1466
1467 if (end == len)
1468 {
1469 break;
1470 }
1471
1472 from = end + p_splitter.length();
1473 }

Callers 5

simplify_pathMethod · 0.45
path_toMethod · 0.45
is_valid_filenameMethod · 0.45
validate_filenameMethod · 0.45
parse_structured_textMethod · 0.45

Calls 8

substrFunction · 0.85
is_emptyFunction · 0.50
lengthFunction · 0.50
findFunction · 0.50
push_backMethod · 0.45
is_emptyMethod · 0.45
sizeMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected