telutils/phoneparser/src/CPhoneGsmParserBase.cpp
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:15:03 +0100
branchRCL_3
changeset 20 987c9837762f
parent 19 7d48bed6ce0c
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201033 Kit: 201035

/*
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Utility functions common for all parsers.
*
*/


// INCLUDE FILES
#include    "CPhoneGsmParserBase.h"

// ============================ MEMBER FUNCTIONS ===============================

// -----------------------------------------------------------------------------
// CPhoneGsmParserBase::IsPrefixOf
// -----------------------------------------------------------------------------
//
TBool CPhoneGsmParserBase::IsPrefixOf( 
        const TDesC& aString, 
        const TDesC& aPrefix )
    {
    TBool result = EFalse;

    if ( aPrefix.Length() <= aString.Length() )
        {
        TPtrC part( aString.Left( aPrefix.Length() ) );

        result = ( part == aPrefix );
        }

    return result;
    }

// -----------------------------------------------------------------------------
// CPhoneGsmParserBase::IsPostfixOf
// -----------------------------------------------------------------------------
//
TBool CPhoneGsmParserBase::IsPostfixOf(
        const TDesC& aString,
        const TDesC& aPostfix )
    {
    TBool result = EFalse;

    if ( aPostfix.Length() <= aString.Length() )
        {
        TPtrC part( aString.Right( aPostfix.Length() ) );

        result = ( part == aPostfix );
        }

    return result;
    }

// -----------------------------------------------------------------------------
// CPhoneGsmParserBase::ExtractNumber
// -----------------------------------------------------------------------------
//
TPtrC CPhoneGsmParserBase::ExtractNumber( 
        const TDesC& aString )
    {
    TPtrC result( KNullDesC );

    if ( aString.Length() )
        {
        TLex input( aString );
        TLexMark mark;
        input.Mark( mark );

        while ( input.Peek().IsDigit() )
            {
            input.Inc();
            }

        result.Set( input.MarkedToken( mark ) );
        }
    
    return result;
    }

//  End of File