telutils/phoneparser/src/CPhoneGsmParserContainer.cpp
changeset 0 ff3b6d0fd310
child 19 7d48bed6ce0c
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Container for parsers.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    <featmgr.h>
       
    21 
       
    22 #include    "CPhoneGsmParserContainer.h"
       
    23 #include    "CPhoneGsmParserResult.h"
       
    24 #include    "CPhoneGsmOptionContainer.h"
       
    25 #include    "PhoneGsmParser.h"
       
    26 
       
    27 // CONSTANTS
       
    28 const TInt KPhoneParserArrayGranularity = 5;
       
    29 
       
    30 // ============================ MEMBER FUNCTIONS ===============================
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CPhoneGsmParserContainer::CPhoneGsmParserContainer
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CPhoneGsmParserContainer::CPhoneGsmParserContainer()
       
    37     {
       
    38     }
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // CPhoneGsmParserContainer::ConstructL
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 void CPhoneGsmParserContainer::ConstructL()
       
    45     {
       
    46     iArray = 
       
    47         new ( ELeave ) CParserArray( KPhoneParserArrayGranularity );
       
    48     }
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // CPhoneGsmParserContainer::NewLC
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 CPhoneGsmParserContainer* CPhoneGsmParserContainer::NewLC()
       
    55     {
       
    56     CPhoneGsmParserContainer* self = 
       
    57         new ( ELeave ) CPhoneGsmParserContainer;
       
    58     
       
    59     CleanupStack::PushL( self );
       
    60     self->ConstructL();
       
    61     
       
    62     return self;
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CPhoneGsmParserContainer::~CPhoneGsmParserContainer
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 CPhoneGsmParserContainer::~CPhoneGsmParserContainer()
       
    70     {
       
    71     if ( iArray )
       
    72         {
       
    73         iArray->ResetAndDestroy();
       
    74         }
       
    75     delete iArray;
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CPhoneGsmParserContainer::AddL
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 void CPhoneGsmParserContainer::AddL(
       
    83         CPhoneGsmParserBase& aParser )
       
    84     {
       
    85     TInt index;
       
    86     TInt count = iArray->Count();
       
    87 
       
    88     for ( index = 0; index < count; index++ )
       
    89         {
       
    90         CPhoneGsmParserBase* parser = iArray->At( index );
       
    91 
       
    92         if ( parser == &aParser )
       
    93             {
       
    94             PhoneGsmParser::Panic( PhoneGsmParser::EIncorrectUse );
       
    95             }
       
    96         }
       
    97 
       
    98     iArray->AppendL( &aParser );
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CPhoneGsmParserContainer::ParseL
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 TBool CPhoneGsmParserContainer::ParseL( 
       
   106         const TDesC& aString,
       
   107         CPhoneGsmParserResult& aResult,
       
   108         CPhoneGsmOptionContainerBase& aOptions )
       
   109     {
       
   110     TInt index;
       
   111     TInt count = iArray->Count();
       
   112     TBool result = EFalse;
       
   113 
       
   114     for ( index = 0; index < count; index++ )
       
   115         {
       
   116         CPhoneGsmParserBase* parser = iArray->At( index );
       
   117 
       
   118         result = parser->ParseL( aString, aResult, aOptions );
       
   119 
       
   120         if ( result )
       
   121             {
       
   122             break;
       
   123             }
       
   124         }
       
   125 
       
   126     return result;
       
   127     }
       
   128 
       
   129 //  End of File