CTulAddressStringTokenizer Class Reference

class CTulAddressStringTokenizer : public CBase

Address String Tokenizer API offers methods for parsing phone numbers and e-mail, URL and URI addresses from the given text. The API consists of the CTulAddressStringTokenizer class.

Usage:

 #include <tuladdressstringtokenizer.h>

 // SFoundItem instance
 CTulAddressStringTokenizer::SFoundItem item;

 // Some text
 TBufC<256> strSomeText(_L("Mail to [email protected] or call 040 1234567. 
 You can also tune in to audio feed at rtsp://someplace.com/somefeed.ra."));
	
 // First the user has to create an instance of CTulAddressStringTokenizer by using the
 // factory method NewL(). The method takes two parameters. The first 
 // parameter defines the text to be searched from and the second parameter 
 // tells what exactly is being looked for.
 CTulAddressStringTokenizer singleSearch = CTulAddressStringTokenizer::NewL(strSomeText, 
                  CTulAddressStringTokenizer::EFindItemSearchMailAddressBin);

 // The passed text is parsed in construction, and found items can be fetched 
 // by using the ItemArray() method. It returns a constant array containing 
 // all the found items. The interface also offers helper functions for 
 // handling the item array by itself. 

 // Get count of found items.
 TInt count(singleSearch->ItemCount());

 // Get currently selected item ([email protected]) to the result1 variable.
 singleSearch->Item(item);
 TPtrC16 result1(strSomeText.Mid(item.iStartPos, item.iLength));

 // Deallocate memory
 delete singleSearch;

 // Create an instance of CTulAddressStringTokenizer and look for all possible 
 // things (cases work as binary mask).
 CTulAddressStringTokenizer* multiSearch = CTulAddressStringTokenizer::NewL(strSomeText,
                  (CTulAddressStringTokenizer::EFindItemSearchPhoneNumberBin |           
                  CTulAddressStringTokenizer::EFindItemSearchURLBin | 
                  CTulAddressStringTokenizer::EFindItemSearchMailAddressBin | 
                  CTulAddressStringTokenizer::EFindItemSearchScheme));

 // Get count of found items.
 TInt count2(multiSearch->ItemCount());

 // Get currently selected item to the result2 variable.
 multiSearch->Item(item);

 // Debug print all items and their type.
 for( TInt i=0; i<count2; i++)
     {
     TPtrC16 result2(strSomeText.Mid(item.iStartPos, item.iLength));
     RDebug::Print(_L("Found type %d item:"), item.iItemType);
     RDebug::Print(_L("%S"), &result2);
     multiSearch->NextItem(item);
     }

 // Deallocate memory
 delete multiSearch;

Inherits from

  • CTulAddressStringTokenizer

Nested Classes and Structures

Public Member Functions
~CTulAddressStringTokenizer()
IMPORT_C TIntDoNewSearchL(const TDesC &, TInt)
IMPORT_C TIntDoNewSearchL(const TDesC &, TInt, TInt)
IMPORT_C TBoolItem(SFoundItem &)
IMPORT_C const CArrayFixFlat< SFoundItem > *ItemArray()
IMPORT_C TIntItemCount()
IMPORT_C CTulAddressStringTokenizer *NewL(const TDesC &, TInt)
IMPORT_C CTulAddressStringTokenizer *NewL(const TDesC &, TInt, TInt)
IMPORT_C TBoolNextItem(SFoundItem &)
IMPORT_C TIntPosition()
IMPORT_C TBoolPrevItem(SFoundItem &)
IMPORT_C voidResetPosition()
Private Member Functions
CTulAddressStringTokenizer()
CTulAddressStringTokenizer(const CTulAddressStringTokenizer &)
voidAddItemL(TInt, TInt, TTokenizerSearchCase)
voidConstructL(const TDesC &, TInt, TInt)
TBool IsValidEmailChar(const TChar &)
TBool IsValidEmailHostChar(const TChar &)
TBool IsValidPhoneNumberChar(const TChar &)
TBool IsValidUrlChar(const TChar &)
TBool ParseUrlL(const TDesC &, const TPtrC &, TInt)
voidPerformSearchL(const TDesC &, TInt)
TBool SearchGenericUriL(const TDesC &)
TBool SearchMailAddressL(const TDesC &)
TBool SearchPhoneNumberL(const TDesC &)
TBool SearchUrlL(const TDesC &, TBool)
CTulAddressStringTokenizer &operator=(const CTulAddressStringTokenizer &)
Inherited Functions
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
Public Member Enumerations
enumTTokenizerSearchCase { EFindItemSearchPhoneNumberBin = 4, EFindItemSearchMailAddressBin = 8, EFindItemSearchURLBin = 16, EFindItemSearchScheme = 32 }
Private Attributes
CArrayFixFlat< SFoundItem > *iFoundItems
TInt iMinNumbers
TInt iPosition

Constructor & Destructor Documentation

CTulAddressStringTokenizer()

CTulAddressStringTokenizer()[private]

CTulAddressStringTokenizer(const CTulAddressStringTokenizer &)

CTulAddressStringTokenizer(const CTulAddressStringTokenizer &)[private]

Parameters

const CTulAddressStringTokenizer &

~CTulAddressStringTokenizer()

IMPORT_C~CTulAddressStringTokenizer()

Member Functions Documentation

AddItemL(TInt, TInt, TTokenizerSearchCase)

voidAddItemL(TIntaStartPos,
TIntaLength,
TTokenizerSearchCaseaType
)[private]

Parameters

TInt aStartPos
TInt aLength
TTokenizerSearchCase aType

ConstructL(const TDesC &, TInt, TInt)

voidConstructL(const TDesC &aText,
TIntaSearchCases,
TIntaMinNumbers
)[private]

Parameters

const TDesC & aText
TInt aSearchCases
TInt aMinNumbers

DoNewSearchL(const TDesC &, TInt)

IMPORT_C TIntDoNewSearchL(const TDesC &aText,
TIntaSearchCases
)

Parameters

const TDesC & aText
TInt aSearchCases

DoNewSearchL(const TDesC &, TInt, TInt)

IMPORT_C TIntDoNewSearchL(const TDesC &aText,
TIntaSearchCases,
TIntaMinNumbers
)

Parameters

const TDesC & aText
TInt aSearchCases
TInt aMinNumbers

IsValidEmailChar(const TChar &)

TBool IsValidEmailChar(const TChar &charac)[private, static]

Parameters

const TChar & charac

IsValidEmailHostChar(const TChar &)

TBool IsValidEmailHostChar(const TChar &charac)[private, static]

Parameters

const TChar & charac

IsValidPhoneNumberChar(const TChar &)

TBool IsValidPhoneNumberChar(const TChar &charac)[private, static]

Parameters

const TChar & charac

IsValidUrlChar(const TChar &)

TBool IsValidUrlChar(const TChar &charac)[private, static]

Parameters

const TChar & charac

Item(SFoundItem &)

IMPORT_C TBoolItem(SFoundItem &aItem)const

Parameters

SFoundItem & aItem

ItemArray()

IMPORT_C const CArrayFixFlat< SFoundItem > *ItemArray()const

ItemCount()

IMPORT_C TIntItemCount()const

NewL(const TDesC &, TInt)

IMPORT_C CTulAddressStringTokenizer *NewL(const TDesC &aText,
TIntaSearchCases
)[static]

Parameters

const TDesC & aText
TInt aSearchCases

NewL(const TDesC &, TInt, TInt)

IMPORT_C CTulAddressStringTokenizer *NewL(const TDesC &aText,
TIntaSearchCases,
TIntaMinNumbers
)[static]

Parameters

const TDesC & aText
TInt aSearchCases
TInt aMinNumbers

NextItem(SFoundItem &)

IMPORT_C TBoolNextItem(SFoundItem &aItem)

Parameters

SFoundItem & aItem

ParseUrlL(const TDesC &, const TPtrC &, TInt)

TBool ParseUrlL(const TDesC &aType,
const TPtrC &aTokenPtr,
TIntaTextOffset
)[private]

Parameters

const TDesC & aType
const TPtrC & aTokenPtr
TInt aTextOffset

PerformSearchL(const TDesC &, TInt)

voidPerformSearchL(const TDesC &aText,
TIntaSearchCases
)[private]

Parameters

const TDesC & aText
TInt aSearchCases

Position()

IMPORT_C TIntPosition()const

PrevItem(SFoundItem &)

IMPORT_C TBoolPrevItem(SFoundItem &aItem)

Parameters

SFoundItem & aItem

ResetPosition()

IMPORT_C voidResetPosition()

SearchGenericUriL(const TDesC &)

TBool SearchGenericUriL(const TDesC &aText)[private]

Parameters

const TDesC & aText

SearchMailAddressL(const TDesC &)

TBool SearchMailAddressL(const TDesC &aText)[private]

Parameters

const TDesC & aText

SearchPhoneNumberL(const TDesC &)

TBool SearchPhoneNumberL(const TDesC &aText)[private]

Parameters

const TDesC & aText

SearchUrlL(const TDesC &, TBool)

TBool SearchUrlL(const TDesC &aText,
TBoolaFindFixedSchemas
)[private]

Parameters

const TDesC & aText
TBool aFindFixedSchemas

operator=(const CTulAddressStringTokenizer &)

CTulAddressStringTokenizer &operator=(const CTulAddressStringTokenizer &)[private]

Parameters

const CTulAddressStringTokenizer &

Member Enumerations Documentation

Enum TTokenizerSearchCase

Enumeration to define the search case. Multiple enumerations can be used as binary mask.

Enumerators

EFindItemSearchPhoneNumberBin = 4
EFindItemSearchMailAddressBin = 8
EFindItemSearchURLBin = 16
EFindItemSearchScheme = 32

Member Data Documentation

CArrayFixFlat< SFoundItem > * iFoundItems

CArrayFixFlat< SFoundItem > *iFoundItems[private]

TInt iMinNumbers

TInt iMinNumbers[private]

TInt iPosition

TInt iPosition[private]