TLex 不提供用户定义分隔符,因此我们可以采用可选方案:MarkedToken(), Mark(), Get(), 和Peek()方法,获得我们需要的结果。
// As an example taking "," as a separator.
_LIT8(KSomeConstString, "first, second, third, fourth,");
TLex8 lex(KSomeConstString);
TChar ch;
TBuf8<50> token;
while((ch = lex.Get()) != 0 )
{
while ((ch = lex.Peek()) != ',')
lex.Inc();
token.Copy(lex.MarkedToken());
/* Now we have the string as the token,
* do something.. */
lex.Inc();
lex.Mark();
}
No related wiki articles found