00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef FINDITEMENGINE_H
00022 #define FINDITEMENGINE_H
00023
00024
00025 #include <e32base.h>
00026
00027
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:
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;
00378 TBool IsValidEmailHostChar( const TChar& charac ) const;
00379 TBool IsValidPhoneNumberChar( const TChar& charac ) const;
00380 TBool IsValidUrlChar( const TChar& charac ) const;
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:
00432
00433 CArrayFixFlat<SFoundItem>* iItemArray;
00434
00435 TInt iPosition;
00436
00437 TInt iMinNumbers;
00438 };
00439
00440
00441 #endif
00442
00443