MCPcopy Create free account
hub / github.com/SmingHub/Sming / splitString

Function splitString

Sming/Wiring/SplitString.cpp:14–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12#include "SplitString.h"
13
14unsigned 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
42unsigned splitString(String& what, char delim, Vector<String>& splits)
43{

Callers 6

smtpParseMethod · 0.85
convertFQNFunction · 0.85
processExampleCommandFunction · 0.85
processExampleCommandFunction · 0.85
processSetCommandsMethod · 0.85
processCommandOptionsMethod · 0.85

Calls 8

removeAllElementsMethod · 0.80
addElementMethod · 0.80
trimMethod · 0.45
c_strMethod · 0.45
lengthMethod · 0.45
toIntMethod · 0.45
substringMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected