-yuelongr | 查看-118 | 发表时间-11/5/2009
虽然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();
}
(来自:Forum Nokia Wiki)