示例#1
0
文件: Misc.cpp 项目: salsita/Magpie
size_t Misc::SplitString(const CString & str, LPCTSTR tokens, CAtlList<CString> & list)
{
  list.RemoveAll();
  CAtlString token;
  int curPos = 0;

  token = str.Tokenize(tokens, curPos);
  while (-1 != curPos)
  {
    if (!token.IsEmpty())
    {
      list.AddTail(token);
    }
    token = str.Tokenize(tokens, curPos);
  }
  return list.GetCount();
}
   // typedef CStringT<TCHAR, StrTraitATL<TCHAR, ChTraitsCRT<TCHAR>>> CAtlString;

   CAtlString str(_T("cabbage"));
   CAtlString res = str.SpanIncluding(_T("abc"));
   ASSERT(res == _T("cabba"));
   res = str.SpanIncluding(_T("xyz"));
   ASSERT(res.IsEmpty());