API published in: S60 3rd Ed
Link against: commonengine.lib
None
#include <finditemengine.h>
Find Item API offers methods for parsing phone numbers and e-mail, URL and URI addresses from the given text. The API consist of the CFindItemEngine class.
Usage:
#include <finditemengine.h> // SFoundItem instance CFindItemEngine::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 CFindItemEngine 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. CFindItemEngine* singleSearch = CFindItemEngine::NewL(strSomeText, CFindItemEngine::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 offers also 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 FindItemEngine and look for all possible // things (cases work as binary mask). CFindItemEngine* multiSearch = CFindItemEngine::NewL(strSomeText, (CFindItemEngine::TFindItemSearchCase) (CFindItemEngine::EFindItemSearchPhoneNumberBin | CFindItemEngine::EFindItemSearchURLBin | CFindItemEngine::EFindItemSearchMailAddressBin | CFindItemEngine::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;
Public Types | |
| enum | TFindItemSearchCase { EFindItemSearchPhoneNumberBin = 4, EFindItemSearchMailAddressBin = 8, EFindItemSearchURLBin = 16, EFindItemSearchScheme = 32 } |
| Enumeration to define the search case. More... | |
Public Member Functions | |
| virtual IMPORT_C | ~CFindItemEngine () |
| Destructor. | |
| IMPORT_C TBool | Item (SFoundItem &aItem) |
| Gets the currently 'selected' item in the array of found items. | |
| IMPORT_C TBool | NextItem (SFoundItem &aItem) |
| Gets the next found item relative to the currently selected item and moves the selection to point to the next item in the array of found items. | |
| IMPORT_C TBool | PrevItem (SFoundItem &aItem) |
| Gets the previous found item relative to the currently selected item and moves the selection to point to the previous item in the array of found items. | |
| IMPORT_C const CArrayFixFlat< SFoundItem > * | ItemArray () const |
| Gets the array of found items. | |
| IMPORT_C TInt | Position () const |
| Gets the current position (or the position of the currently selected item) in the found items array. | |
| IMPORT_C void | ResetPosition () |
| Resets the position in item array to zero (beginning of the array). | |
| IMPORT_C TInt | ItemCount () const |
| Gets the number of items in the found items array. | |
| IMPORT_C TInt | DoNewSearchL (const TDesC &aText, const TFindItemSearchCase aSearchCase) |
| Executes a new search with the already created CFindItemEngine instance. | |
| IMPORT_C TInt | DoNewSearchL (const TDesC &aText, const TFindItemSearchCase aSearchCase, const TInt aMinNumbers) |
| Executes a new search with the already created CFindItemEngine instance. | |
Static Public Member Functions | |
| static IMPORT_C CFindItemEngine * | NewL (const TDesC &aText, const TFindItemSearchCase aSearchCase) |
| Two-phase constructor method that is used to create a new instance of the CFindItemEngine class. | |
| static IMPORT_C CFindItemEngine * | NewL (const TDesC &aText, const TFindItemSearchCase aSearchCase, const TInt aMinNumbers) |
| Two-phase constructor method that is used to create a new instance of the CFindItemEngine class. | |
Data Structures | |
| struct | SFoundItem |
| Struct to contain an item. More... | |
|
|
|
Destructor. |
| ||||||||||||||||
|
Executes a new search with the already created CFindItemEngine instance. The position in the found items array is reset to the beginning of the array. Public since 3rd Ed FP1
|
| ||||||||||||
|
Executes a new search with the already created CFindItemEngine instance. The position in the found items array is reset to the beginning of the array.
|
|
|
Gets the currently 'selected' item in the array of found items.
|
|
|
Gets the array of found items. Returns a constant pointer to the found items array of the CFindItemEngine instance. The items cannot be modified through this pointer, only accessed. The ownership of the array stays with CFindItemEngine.
|
|
|
Gets the number of items in the found items array.
|
| ||||||||||||||||
|
Two-phase constructor method that is used to create a new instance of the CFindItemEngine class. This instance can then be queried for the items defined by the second parameter. The actual search is executed during construction. Public since 3rd Ed FP1
|
| ||||||||||||
|
Two-phase constructor method that is used to create a new instance of the CFindItemEngine class. This instance can then be queried for the items defined by the second parameter. The actual search is executed during construction.
|
|
|
Gets the next found item relative to the currently selected item and moves the selection to point to the next item in the array of found items.
|
|
|
Gets the current position (or the position of the currently selected item) in the found items array.
|
|
|
Gets the previous found item relative to the currently selected item and moves the selection to point to the previous item in the array of found items.
|
|
|
Resets the position in item array to zero (beginning of the array). |