|
Zen API
|
| kBool kStrSplit | ( | const kChar * | input, |
| const kChar * | delimiterList, | ||
| const kChar ** | tokenStart, | ||
| const kChar ** | tokenEnd, | ||
| kChar * | context, | ||
| kBool | discardEmpty = kFALSE |
||
| ) |
Iterates over substrings within a string, as demarcated by a delimiter list.
This function provides a thread-safe alternative to strtok. The tokenStart and tokenEnd pointers must be initialized to kNULL prior to the first call. If a token is found, this function will return kTRUE and the pointers referenced by the tokenStart and tokenEnd parameters will be updated to indicate the token boundaries.
If the discardEmpty parameter is kTRUE, this function will ignore any extra delimiters that are not strictly required to separate tokens; otherwise, a token will be emitted for every delimiter.
Unlike strtok, the original delimimiter will remain unmodified at the location referenced by tokenEnd upon return of this call. To provide strtok-like behavior, the caller can optionally set the character referenced by tokenEnd to the null terminator.
| input | Input string to be searched. |
| delimiterList | List of delimiter characters. |
| tokenStart | If token found, receives pointer to start of token; the refereneced pointer must be initialized to kNULL before first call. |
| tokenEnd | If token found, receives pointer to one past end of token; the refereneced pointer must be initialized to kNULL before first call. |
| context | Pointer to variable (maintained by caller) that stores parsing context between call invocations. |
| discardEmpty | Should empty tokens be discarded? |