examples/ForumNokia/SMSExample/Engine/src/SMSExampleParser.cpp

00001 /*
00002  * Copyright © 2008 Nokia Corporation.
00003  */
00004 
00005 #include "SMSExampleParser.h"
00006 
00007 const TInt KNumberLength = 10;
00008 
00009 CSMSExampleParser::CSMSExampleParser(void)
00010     {
00011     }
00012  
00013 EXPORT_C CSMSExampleParser::~CSMSExampleParser(void)
00014     {
00015     }
00016 
00017 EXPORT_C CSMSExampleParser* CSMSExampleParser::NewL()
00018     {
00019     CSMSExampleParser* self = new (ELeave) CSMSExampleParser();
00020     CleanupStack::PushL(self);
00021     self->ConstructL();
00022     CleanupStack::Pop(self);
00023     return self;
00024     }
00025       
00026 void CSMSExampleParser::ConstructL()
00027     {
00028     }
00029 
00030 EXPORT_C TBool CSMSExampleParser::ParseMessage(const TDesC& aMessage, TDes& aNumber)
00031     {
00032     TLex numberLex = TLex( aMessage );
00033 
00034     // while not end-of-file
00035     while ( !numberLex.Eos() )
00036         {
00037         TChar character = numberLex.Get();
00038 
00039         if ( character.IsDigit() ) 
00040             {
00041             aNumber.Append( character );
00042             }
00043         else 
00044             {
00045             aNumber.Delete( 0, aNumber.Length() );
00046             }
00047 
00048         // Search for a number which is in format XXXXXXXXXX ( X = [0-9], 
00049         // whitespaces are not allowed). 
00050         // For example "0551234567" would return true. 
00051         // but "055 1234567" would not
00052         if ( aNumber.Length() == KNumberLength ) 
00053             {
00054             return ETrue;
00055             }
00056         }
00057 
00058     return EFalse;
00059     }

Generated by  doxygen 1.6.2