| 12 | #include "SplitString.h" |
| 13 | |
| 14 | unsigned splitString(String& what, char delim, Vector<int>& splits) |
| 15 | { |
| 16 | what.trim(); |
| 17 | splits.removeAllElements(); |
| 18 | const char* chars = what.c_str(); |
| 19 | unsigned splitCount = 0; |
| 20 | for(unsigned i = 0; i < what.length(); i++) { |
| 21 | if(chars[i] == delim) { |
| 22 | splitCount++; |
| 23 | } |
| 24 | } |
| 25 | if(splitCount == 0) { |
| 26 | splits.addElement(what.toInt()); |
| 27 | return (1); |
| 28 | } |
| 29 | |
| 30 | int startIndex = 0; |
| 31 | for(unsigned i = 0; i < what.length(); i++) { |
| 32 | if(what[i] == delim) { |
| 33 | splits.addElement(what.substring(startIndex, i).toInt()); |
| 34 | startIndex = i + 1; |
| 35 | } |
| 36 | } |
| 37 | splits.addElement(what.substring(startIndex).toInt()); |
| 38 | |
| 39 | return splits.count(); |
| 40 | } |
| 41 | |
| 42 | unsigned splitString(String& what, char delim, Vector<String>& splits) |
| 43 | { |
no test coverage detected