finditemengine.h

Go to the documentation of this file.
00001 /*
00002 * ============================================================================
00003 *  Name        : FindItemEngine.h
00004 *  Part of     : Common Services / Common Engine
00005 *  Interface   : SDK, Find Item API
00006 *  Description : Find Item API offers methods for parsing phone numbers, email 
00007 *                addresses, URL addresses and URI addresses from given text.
00008 *  Version     : %version: ou1cfspd#14 %
00009 *
00010 *  Copyright © 2002-2006 Nokia.  All rights reserved.
00011 *  This material, including documentation and any related computer
00012 *  programs, is protected by copyright controlled by Nokia.  All
00013 *  rights are reserved.  Copying, including reproducing, storing,
00014 *  adapting or translating, any or all of this material requires the
00015 *  prior written consent of Nokia.  This material also contains
00016 *  confidential information which may not be disclosed to others
00017 *  without the prior written consent of Nokia.
00018 * ============================================================================
00019 */
00020 
00021 #ifndef FINDITEMENGINE_H
00022 #define FINDITEMENGINE_H
00023 
00024 //  INCLUDES
00025 #include <e32base.h>
00026 
00027 // CLASS DECLARATION
00028 
00101 class CFindItemEngine :public CBase
00102     {
00103     public:
00104 
00109         enum TFindItemSearchCase
00110             {
00113                         EFindItemSearchPhoneNumberBin = 4, 
00116             EFindItemSearchMailAddressBin = 8,
00119             EFindItemSearchURLBin  = 16,
00122             EFindItemSearchScheme  = 32
00123             };
00124 
00128         struct SFoundItem
00129             {
00132             TInt iStartPos;
00135             TInt iLength;
00138             TFindItemSearchCase iItemType;
00139                         };
00140 
00141     public:  // Constructors and destructor
00142         
00163         IMPORT_C static CFindItemEngine* NewL( const TDesC& aText, 
00164                                                const TFindItemSearchCase aSearchCase );
00165 
00189         IMPORT_C static CFindItemEngine* NewL( const TDesC& aText, 
00190                                                const TFindItemSearchCase aSearchCase,
00191                                                const TInt aMinNumbers );
00192 
00196         IMPORT_C virtual ~CFindItemEngine();
00197 
00198     public:
00205         IMPORT_C TBool Item( SFoundItem& aItem );
00206 
00215         IMPORT_C TBool NextItem( SFoundItem& aItem );
00216 
00225         IMPORT_C TBool PrevItem( SFoundItem& aItem );
00226                 
00236         IMPORT_C const CArrayFixFlat<SFoundItem>* ItemArray() const;
00237 
00246                 IMPORT_C TInt Position() const; 
00247         
00251         IMPORT_C void ResetPosition();
00252 
00258                 IMPORT_C TInt ItemCount() const;
00259                 
00279         IMPORT_C TInt DoNewSearchL( const TDesC& aText, const TFindItemSearchCase aSearchCase);
00280 
00303         IMPORT_C TInt DoNewSearchL( const TDesC& aText, const TFindItemSearchCase aSearchCase, 
00304                                     const TInt aMinNumbers );
00305 
00306     private:
00307         
00316         void AddItemL( const TInt& aStartPos, const TInt& aLength, 
00317                        const TFindItemSearchCase& aType );
00318 
00325         TBool SearchPhoneNumberL( const TDesC& aText);  
00326 
00333         TBool SearchMailAddressL( const TDesC& aText);  
00334 
00341         TBool SearchGenericUriL( const TDesC& aText);
00342 
00354         TBool SearchUrlL( const TDesC& aText, const TBool aFindFixedSchemas);
00355 
00369         TBool ParseUrlL( const TDesC& aType, const TPtrC& aTokenPtr, const TInt aTextOffset );
00370 
00377         TBool IsValidEmailChar( const TChar& charac ) const; // Login part of the e-mail address
00378         TBool IsValidEmailHostChar( const TChar& charac ) const; // Host part of the e-mail address
00379         TBool IsValidPhoneNumberChar( const TChar& charac ) const; // Phone number
00380         TBool IsValidUrlChar( const TChar& charac ) const; // URL
00381 
00385         CFindItemEngine();
00386 
00401         void ConstructL( const TDesC& aText, const TFindItemSearchCase aSearchCase, 
00402                          const TInt aMinNumbers );
00411                 void PerformSearchL( const TDesC& aText , const TFindItemSearchCase aSearchCase );
00412 
00413 
00420                 void ConvertArabicNumbersToWesternNumbers( HBufC* aBuf );
00421 
00425         CFindItemEngine( const CFindItemEngine& );
00429         CFindItemEngine& operator= ( const CFindItemEngine& );
00430 
00431     private:    // Data
00432         // Array of all found items.
00433         CArrayFixFlat<SFoundItem>* iItemArray;
00434                 // Engine's position in the iItemArray and iItemTypeArray.
00435         TInt iPosition;
00436         // Minimum count of numbers in a phone number
00437         TInt iMinNumbers;
00438     };
00439 
00440 // FINDITEMENGINE_H   
00441 #endif
00442             
00443 // End of File

Copyright © Nokia Corporation 2001-2008
Back to top