×
Namespaces

Variants
Actions

Getting tokens

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: kiran10182 (07 May 2007)
Last edited: hamishwillee (23 Jul 2012)

Following code snippet illustrate how to extract tokens from the available data.

    CDesC16Array *array= new (ELeave) CDesC16ArrayFlat(10);
_LIT(KData,"This is the token example." \
"You will get different tokens in array.");
TLex lex(KData);
 
do
{
TPtrC token = lex.NextToken();
if(token.Length() == 0)
break;
array->AppendL(token);
} while(1);

Note: This is just an example which extract tokens from string defined using LIT macro. However you can use this code in general terms. You can extract tokens from descriptors, file data etc. Here Array granularity is taken as 10. You can use granularity on your application's discretion.

This page was last modified on 23 July 2012, at 10:39.
53 page views in the last 30 days.