Namespaces
Variants
Actions

How to define a custom separator in TLex

Jump to: navigation, search
Article Metadata

Article
Created: vasant21 (10 Aug 2007)
Last edited: hamishwillee (18 Sep 2012)

TLex does not provide support for user defined separators, hence a possible workaround could be using the MarkedToken(), Mark(), Get(), and Peek() methods for achieving the desired results.

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

Related Link

This page was last modified on 18 September 2012, at 08:57.
118 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved