int split(const std::string &sourceStr, const char *pSplit, std::vector<std::string> &lstStringDest)
{
int nSplitLen = strlen(pSplit);
if (sourceStr=="")
{
return 0;
}
std::size_t startindex = 0;
while (1)
{
std::size_t splitindex = sourceStr.find(pSplit, startindex);
//如果找不到,则退出
if (splitindex==std::string::npos)
{
break;
}
lstStringDest.push_back(sourceStr.substr(startindex, splitindex-startindex));
startindex = splitindex+nSplitLen;
}
//加入最后一个
lstStringDest.push_back(sourceStr.substr(startindex, sourceStr.size()));
return 0;
}
void InterceptString(char *cInterceptString, char *cSeparator, vector<string> &vOutSeparatorStr)
{
if (cInterceptString == NULL)
{
return;
}
char *pTmp = strtok(cInterceptString, cSeparator);
while (pTmp != NULL)
{
vOutSeparatorStr.push_back(pTmp);
pTmp = strtok(NULL, cSeparator);
}
}