MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / split_spaces

Method split_spaces

core/string/ustring.cpp:998–1038  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

996}
997
998Vector<String> String::split_spaces(int p_maxsplit) const {
999 Vector<String> ret;
1000 int from = 0;
1001 int i = 0;
1002 int len = length();
1003 if (len == 0) {
1004 return ret;
1005 }
1006
1007 bool inside = false;
1008
1009 while (true) {
1010 bool empty = operator[](i) < 33;
1011
1012 if (i == 0) {
1013 inside = !empty;
1014 }
1015
1016 if (!empty && !inside) {
1017 inside = true;
1018 from = i;
1019 }
1020
1021 if (empty && inside) {
1022 if (p_maxsplit > 0 && p_maxsplit == ret.size()) {
1023 // Put rest of the string and leave cycle.
1024 ret.push_back(substr(from));
1025 break;
1026 }
1027 ret.push_back(substr(from, i - from));
1028 inside = false;
1029 }
1030
1031 if (i == len) {
1032 break;
1033 }
1034 i++;
1035 }
1036
1037 return ret;
1038}
1039
1040Vector<String> String::split(const String &p_splitter, bool p_allow_empty, int p_maxsplit) const {
1041 Vector<String> ret;

Callers 11

_get_drivesFunction · 0.80
_update_filterMethod · 0.80
_read_string_arrayMethod · 0.80
_read_transformMethod · 0.80
_native_search_cbMethod · 0.80
_add_qualifiers_to_rtFunction · 0.80
test_string.hFile · 0.80

Calls 2

sizeMethod · 0.65
push_backMethod · 0.45

Tested by

no test coverage detected