| 996 | } |
| 997 | |
| 998 | Vector<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 | |
| 1040 | Vector<String> String::split(const String &p_splitter, bool p_allow_empty, int p_maxsplit) const { |
| 1041 | Vector<String> ret; |
no test coverage detected