Zen API
 All Classes Files Functions Variables Typedefs Friends Macros Modules Pages
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.

Parameters
inputInput string to be searched.
delimiterListList of delimiter characters.
tokenStartIf token found, receives pointer to start of token; the refereneced pointer must be initialized to kNULL before first call.
tokenEndIf token found, receives pointer to one past end of token; the refereneced pointer must be initialized to kNULL before first call.
contextPointer to variable (maintained by caller) that stores parsing context between call invocations.
discardEmptyShould empty tokens be discarded?
Returns
kTRUE if a token was found.