Namespaces
Variants
Actions
Revision as of 14:30, 22 August 2012 by lpvalente (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Archived:Using CFindItemEngine to parse items from text

Jump to: navigation, search
Archived.png
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.


Article Metadata

Tested with
Devices(s): Nokia E90 Communicator

Compatibility
Platform(s): S60 3rd Edition

Article
Keywords: CFindItemEngine, CFindItemEngine::SFoundItem, CFindItemEngine::ItemCount(), CFindItemEngine::Item(), CFindItemEngine::NextItem()
Created: tapla (22 Apr 2008)
Last edited: lpvalente (22 Aug 2012)

Contents

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://www.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.

234 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved