phoneengine/PhoneCntFinder/src/CPhoneRawMatchNumberExtractor.cpp
changeset 0 5f000ab63145
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     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:  This class extracts phone number for comparsion.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  INCLUDES
       
    20 #include "CPhoneRawMatchNumberExtractor.h"
       
    21 #include "CPhoneCntNumberParser.h"
       
    22 #include <cntdb.h>
       
    23 
       
    24 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    25 #include <cntphonenumparser.h>
       
    26 #endif
       
    27 
       
    28 // CONSTANTS
       
    29 
       
    30 // DEPRECATED
       
    31 const TUint KPhCntExtractorExtraChar = '1'; // number makes no difference.
       
    32 
       
    33 // ============================ MEMBER FUNCTIONS ===============================
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CCntRawPhoneNumberExtractor::CCntRawPhoneNumberExtractor
       
    37 // C++ constructor can NOT contain any code, that
       
    38 // might leave.
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 EXPORT_C CCntRawPhoneNumberExtractor::CCntRawPhoneNumberExtractor() 
       
    42 : iKPhoneNumberExtraChar( KPhCntExtractorExtraChar ) 
       
    43     {
       
    44     }
       
    45 
       
    46 // Destructor
       
    47 CCntRawPhoneNumberExtractor::~CCntRawPhoneNumberExtractor()
       
    48     {
       
    49     delete iNumberParser;
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CCntRawPhoneNumberExtractor::ConstructL
       
    54 // Symbian 2nd phase constructor can leave.
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 void CCntRawPhoneNumberExtractor::ConstructL()
       
    58     {
       
    59     iNumberParser = CCntNumberParser::NewL();
       
    60     iParser = iNumberParser->CntPhoneNumberParser();
       
    61     }
       
    62 
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CCntRawPhoneNumberExtractor::Release
       
    66 // 
       
    67 //  Releases used memory
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 void CCntRawPhoneNumberExtractor::Release()
       
    71     {
       
    72     delete this;
       
    73     }
       
    74 
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CCntRawPhoneNumberExtractor::ExtractRawNumber
       
    78 // 
       
    79 //  DEPRECATED. 
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 TUint CCntRawPhoneNumberExtractor::ExtractRawNumber(
       
    83     const TDesC& /*aTextualNumber*/)
       
    84     {
       
    85     __ASSERT_DEBUG( EFalse , User::Invariant() );
       
    86     return 0;
       
    87     }
       
    88 
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CCntRawPhoneNumberExtractor::ExtractRawNumber
       
    92 // 
       
    93 //  Does the actual extracting
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 TUint CCntRawPhoneNumberExtractor::ExtractRawNumber(
       
    97     const TDesC& aTextualNumber, 
       
    98     TDes& aRawNumber)
       
    99     {
       
   100     aRawNumber.Zero();
       
   101     iParser->ExtractRawNumber( aTextualNumber , iMatchBuffer );
       
   102     if ( iMatchBuffer.Length() == 0 )
       
   103         {
       
   104         return 0;
       
   105         }
       
   106 
       
   107     if ( iMatchBuffer.Length() > aRawNumber.MaxLength() )
       
   108         {
       
   109         aRawNumber = iMatchBuffer.Right( aRawNumber.MaxLength() );
       
   110         }
       
   111     else
       
   112         {
       
   113         aRawNumber = iMatchBuffer;
       
   114         }
       
   115     return 0;
       
   116     }
       
   117 
       
   118 // -----------------------------------------------------------------------------
       
   119 // CCntRawPhoneNumberExtractor::ExtraChar() const
       
   120 // 
       
   121 //  DEPRECATED.
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 TChar CCntRawPhoneNumberExtractor::ExtraChar() const
       
   125     {
       
   126     __ASSERT_DEBUG( EFalse , User::Invariant() );
       
   127     return iKPhoneNumberExtraChar;
       
   128     }   
       
   129     
       
   130 // End of file