Splits an input string into a series of strings on the basis of a single delimiting char. Returns: None
| Return Type | Function name | Arguments |
|---|---|---|
| void | SplitStrOnChar | (hzArray<hzString>&,hzString&,char,) |
Declared in file: hzTextproc.h
Defined in file : hzTextproc.cpp
Function Logic:
Function body:
void SplitStrOnChar (hzArray<hzString>& ar)hzString& input, char cDelim,
{
// Category: Text Processing
//
// Splits an input string into a series of strings on the basis of a single delimiting char.
//
// Arguments: 1) ar The vector of strings that will be populated by this operation (note it is first cleared)
// 2) input The input string or chain
// 3) cDelim The delimitor (default of comma)
//
// Returns: None
const char* i ; // Input iterator
hzString S ; // Substring of input
uint32_t nRef = 0; // Substring end position (within input)
uint32_t nPos = 0; // Substring start position (within input)
ar.Clear() ;
if (input)
{
if (!cDelim)
cDelim = 0;
i = *input ;
nRef = nPos = 0;
for (;;)
{
if (i[nPos] == 0|| i[nPos] == cDelim)
{
S = input.SubString(nRef, nPos - nRef) ;
if (S)
ar.Add(S) ;
if (i[nPos] == 0)
break ;
nRef = nPos + 1;
}
nPos++ ;
}
}
}