CTulAddressStringTokenizer Class Reference

#include <mw/tuladdressstringtokenizer.h>

Link against: etul.lib

class CTulAddressStringTokenizer : public CBase

Inherits from

  • CTulAddressStringTokenizer

Nested Classes and Structures

Detailed Description

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 me@someplace.com 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 (me@someplace.com) 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;

Member Enumeration Documentation

Enum TTokenizerSearchCase

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

Constructor & Destructor Documentation

~CTulAddressStringTokenizer ( )

IMPORT_C~CTulAddressStringTokenizer()

Destructor.

Member Function Documentation

DoNewSearchL ( const TDesC &, TInt )

IMPORT_C TIntDoNewSearchL(const TDesC &aText,
TIntaSearchCases
)

Executes a new search with the already created CTulAddressStringTokenizer instance. The position in the found items array is reset to the beginning of the array.

Parameters
aTextwill be parsed.
aSearchCasesidentifies what items are we looking for: EFindItemSearchPhoneNumberBin EFindItemSearchMailAddressBin EFindItemSearchURLBin EFindItemSearchScheme Any combination of these flags can be given as a bit mask.
Return Value
number of found items.
Leave Codes
oneof the Symbian error codes.
Panic Codes
ETulPanicInvalidTokenizerSearchCasein debug build if there is no valid search case.
ETulPanicDescriptorLengthin debug build if item's position and/or length is out of the document's range.

DoNewSearchL ( const TDesC &, TInt, TInt )

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

Executes a new search with the already created CTulAddressStringTokenizer instance. The position in the found items array is reset to the beginning of the array.

Parameters
aTextwill be parsed.
aSearchCasesidentifies what items are we looking for: EFindItemSearchPhoneNumberBin EFindItemSearchMailAddressBin EFindItemSearchURLBin EFindItemSearchScheme Any combination of these flags can be given as a bit mask.
aMinNumbersdefines a minimum count of numbers in a phone number string, during a phone number search.
Return Value
number of found items.
Leave Codes
KErrNone,if successful; otherwise one of the other system-wide error codes.
Panic Codes
ETulPanicInvalidTokenizerSearchCasein debug build if there is no valid search case.
ETulPanicDescriptorLengthin debug build if item's position and/or length is out of the document's range.

Item ( SFoundItem & )

IMPORT_C TBoolItem(SFoundItem &aItem)const

Gets the currently 'selected' item in the array of found items.

Parameters
aItemcontains the currently selected item after returning.
Return Value
ETrue if the item was found. EFalse if the item wasn't found.

ItemArray ( )

IMPORT_C const CArrayFixFlat< SFoundItem > *ItemArray()const

Gets the array of found items. Returns a constant pointer to the found items array of the CTulAddressStringTokenizer instance. The items cannot be modified through this pointer, only accessed. The ownership of the array stays with CTulAddressStringTokenizer.

Return Value
a constant pointer to the array of found items. Ownership stays with CTulAddressStringTokenizer.

ItemCount ( )

IMPORT_C TIntItemCount()const

Gets the number of items in the found items array.

Return Value
the number of items in the found items array.

NewL ( const TDesC &, TInt )

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

Two-phase constructor method that is used to create a new instance of the CTulAddressStringTokenizer class. This instance can then be queried for the items defined by the second parameter. The actual search is executed during construction.

Parameters
aTextwill be parsed.
aSearchCasesidentifies what items we are looking for: EFindItemSearchPhoneNumberBin EFindItemSearchMailAddressBin EFindItemSearchURLBin EFindItemSearchScheme Any combination of these flags can be given as a bit mask.
Return Value
a pointer to a new instance of CTulAddressStringTokenizer class.
Leave Codes
KErrNone,if successful; otherwise one of the other system-wide error codes.
Panic Codes
ETulPanicInvalidTokenizerSearchCasein debug build if there is no valid search case.
ETulPanicDescriptorLengthin debug build if item's position and/or length is out of the document's range.

NewL ( const TDesC &, TInt, TInt )

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

Two-phase constructor method that is used to create a new instance of the CTulAddressStringTokenizer class. This instance can then be queried for the items defined by the second parameter. The actual search is executed during construction.

Parameters
aTextwill be parsed.
aSearchCasesidentifies what items we are looking for: EFindItemSearchPhoneNumberBin EFindItemSearchMailAddressBin EFindItemSearchURLBin EFindItemSearchScheme Any combination of these flags can be given as a bit mask.
aMinNumbersdefines a minimum count of numbers in a phone number string, during a phone number search.
Return Value
a pointer to an new instance of CTulAddressStringTokenizer class.
Leave Codes
KErrNone,if successful; otherwise one of the other system-wide error codes.
Panic Codes
ETulPanicInvalidTokenizerSearchCasein debug build if there is no valid search case.
ETulPanicDescriptorLengthin debug build if item's position and/or length is out of the document's range.

NextItem ( SFoundItem & )

IMPORT_C TBoolNextItem(SFoundItem &aItem)

Gets the next found item relative to the currently selected item. Moves the selection to point to the next item in the array of found items.

Parameters
aItemcontains the next item after returning.
Return Value
ETrue if the item was found. EFalse if there's no next item.

Position ( )

IMPORT_C TIntPosition()const

Gets the current position (or the position of the currently selected item) in the found items array.

Return Value
the current position in the found items array of the CTulAddressStringTokenizer instance. If no items are in the array, zero is returned.

PrevItem ( SFoundItem & )

IMPORT_C TBoolPrevItem(SFoundItem &aItem)

Gets the previous found item relative to the currently selected item. Moves the selection to point to the previous item in the array of found items..

Parameters
aItemcontains the previous item after returning.
Return Value
ETrue if the item was found. EFalse if there's no previous item.

ResetPosition ( )

IMPORT_C voidResetPosition()

Resets the position in item array to zero (beginning of the array).