This page was last modified 08:16, 2 May 2008.
CS000931 - Using CFindItemEngine to parse items from text
From Forum Nokia Wiki
| ID | CS000931 | Creation date | May 2, 2008 |
| Platform | S60 3rd Edition, MR | Tested on devices | Nokia E90 Communicator |
| Category | Symbian C++ | Subcategory | Files/Data |
| Keywords (APIs, classes, methods, functions): CFindItemEngine, CFindItemEngine::SFoundItem, CFindItemEngine::ItemCount(), CFindItemEngine::Item(), CFindItemEngine::NextItem() |
Overview
This code snippet demonstrates how to use CFindItemEngine to parse different kinds of items, such as phone numbers, e-mail addresses, or URI addresses, from a given text. The type of the item is given to CFindItemEngine as a parameter when the object is constructed and also several types of items can be searched:
// Parse e-mail addresses from text CFindItemEngine* searchEngine = CFindItemEngine::NewL(text, CFindItemEngine::EFindItemSearchMailAddressBin);
// Parse URLs from text CFindItemEngine* searchEngine = CFindItemEngine::NewL(text, CFindItemEngine::EFindItemSearchURLBin);
// Parse URLs and phone numbers from text CFindItemEngine* searchEngine = CFindItemEngine::NewL(text, (CFindItemEngine::TFindItemSearchCase) (CFindItemEngine::EFindItemSearchURLBin | CFindItemEngine::EFindItemSearchPhoneNumberBin));
This snippet can be self-signed.
MMP file
The following libraries are required:
LIBRARY CommonEngine.lib
Source file
TBuf<256> text = _L("E-mail: foo.bar@invalid.com, Tel: 0700 468833, Www: http://ww2.testsite.net."); // Create an instance of CFindItemEngine to find every e-mail address from the text above CFindItemEngine* searchEngine = CFindItemEngine::NewL(text, CFindItemEngine::EFindItemSearchMailAddressBin); // Retrieve the number of items TInt count = searchEngine->ItemCount(); // Get currently selected item to the item variable CFindItemEngine::SFoundItem item; searchEngine->Item(item); // Display every item for (TInt i = 0; i < count; i++) { TPtrC result = text.Mid(item.iStartPos, item.iLength); CAknInformationNote* note = new (ELeave)CAknInformationNote(ETrue); note->ExecuteLD(result); // Get the next item to the item variable searchEngine->NextItem(item); } delete searchEngine;
Postconditions
Every e-mail address from the specific text is displayed on the screen.
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Parsing output | kkramhoeft | General Symbian C++ | 1 | 2003-05-06 16:39 |
| IllegalStateException when trying a Form.insert() | sandro1972 | Mobile Java General | 2 | 2007-03-18 09:38 |
| Forum description gone ! | croozeus | Feedback on Forum Nokia Services | 2 | 2008-04-07 16:59 |
| Dimmed menu-items (Series 60) | nitinkumar | Symbian User Interface | 2 | 2003-04-15 14:14 |
| Determine Install Location - 3650 | RLord321 | General Symbian C++ | 3 | 2003-08-01 14:49 |

