×
Namespaces

Variants
Actions

如何在TLex中自定义分隔符

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

文章
翻译:
hoolee
最后由 hamishwillee 在 22 Dec 2011 编辑

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();
}

相关链接

This page was last modified on 22 December 2011, at 05:06.
107 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×