ParseString Parses the given string into its components. A component is defined as the data found between the given separation characters in the sepChars string. Params string - string to parse sepChars - characters to use as the separations between each of the string components. index - the zero
| 137 | UTE_ERROR - error |
| 138 | ****************************************************/ |
| 139 | int CUT_StrMethods::ParseString(LPCSTR string,LPCSTR sepChars,int index, |
| 140 | LPSTR buf,int buflen, char chStringQualifier){ |
| 141 | |
| 142 | int t,x; |
| 143 | int strLen ; |
| 144 | int sepLen ; |
| 145 | int piece = FALSE; |
| 146 | int startPos =0; |
| 147 | int endPos = 0; |
| 148 | int currentIndex = 0; |
| 149 | int found = FALSE; |
| 150 | |
| 151 | if(buflen >0) |
| 152 | buf[0]=0; |
| 153 | if (string == NULL) |
| 154 | return UTE_ERROR; |
| 155 | |
| 156 | if (sepChars == NULL) |
| 157 | return UTE_ERROR; |
| 158 | |
| 159 | bool bInsideString = false; // Indicates if we are inside a string or not. |
| 160 | // When we are inside string we do not look for |
| 161 | // separator characters |
| 162 | |
| 163 | strLen= (int)strlen(string); |
| 164 | sepLen = (int)strlen(sepChars); |
| 165 | //go through the string to find the param at the given index |
| 166 | for(t=0;t<=strLen;t++) |
| 167 | { |
| 168 | if (chStringQualifier != 0 && string[t] == chStringQualifier) |
| 169 | bInsideString = !bInsideString; // toggle inside string |
| 170 | |
| 171 | //check for separation chars |
| 172 | for(x=0;x<sepLen;x++) |
| 173 | { |
| 174 | if((string[t] == sepChars[x] && !bInsideString) || string[t] == 0) |
| 175 | { |
| 176 | if(piece) |
| 177 | { |
| 178 | endPos = t -1; |
| 179 | if(currentIndex == index) |
| 180 | { |
| 181 | found = TRUE; |
| 182 | break; |
| 183 | } |
| 184 | currentIndex++; |
| 185 | } |
| 186 | piece = FALSE; |
| 187 | break; |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | if(found == TRUE) |
| 192 | break; |
| 193 | |
| 194 | //if none is found then it must be a piece |
| 195 | if(x == sepLen) |
| 196 | { |
nothing calls this directly
no outgoing calls
no test coverage detected