smsexampleparser.cpp

来自「symbian平台」· C++ 代码 · 共 87 行

CPP
87
字号
/*
* ============================================================================
*  Name     : CSMSExampleParser from SMSExampleParser.h
*  Part of  : SMSExample
*  Created  : 12.03.2005 by Forum Nokia
*  Version  : 1.0
*  Copyright: Nokia Corporation
* ============================================================================
*/

#include "SMSExampleParser.h"

// ----------------------------------------------------------------------------
// CSMSExampleParser::CSMSExampleParser(void)
//
// Symbian OS 2 phase constructor.
// ----------------------------------------------------------------------------
CSMSExampleParser::CSMSExampleParser(void)
	{
	}

// ----------------------------------------------------------------------------
// CSMSExampleParser::~CSMSExampleParser(void)
//
// Destructor.
// ----------------------------------------------------------------------------
CSMSExampleParser::~CSMSExampleParser(void)
	{
	}

// ----------------------------------------------------------------------------
// CSMSExampleParser::NewL()
//
// Symbian OS 2 phase constructor.
// ----------------------------------------------------------------------------
CSMSExampleParser* CSMSExampleParser::NewL()
	{
	CSMSExampleParser* self = new (ELeave) CSMSExampleParser();
    CleanupStack::PushL(self);
    self->ConstructL();
    CleanupStack::Pop(self);
    return self;
	}
	  
// ----------------------------------------------------------------------------
// void CSMSExampleParser::ConstructL()
//
// Symbian OS 2 phase constructor.
// ----------------------------------------------------------------------------        
 void CSMSExampleParser::ConstructL()
	{
	}

// ----------------------------------------------------------------------------
// CSMSExampleParser::ParseMessage(TDesC& aMessage, TDes& aNumber)
//
// Parse message body and try to find number which has exactly 10 digits.
// ----------------------------------------------------------------------------
TBool CSMSExampleParser::ParseMessage(TDesC& aMessage, TDes& aNumber)
	{
	TLex numberLex = TLex( aMessage );

	// while not end-of-file
	while ( !numberLex.Eos() )
		{
		TChar character = numberLex.Get();

		if ( character.IsDigit() ) 
			{
			aNumber.Append( character );
			}
		else 
			{
			aNumber.Delete( 0, aNumber.Length() );
			}

		// Search for a number which is in format XXXXXXXXXX ( X = [0-9], whitespaces 
		// are not allowed). For example "0551234567" would return true. but "055 1234567" 
		// would not
		if ( aNumber.Length() == 10 ) 
			{
			return ETrue;
			}
		}

	return EFalse;
	}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?