×
Namespaces

Variants
Actions

使用CFindItemEngine分析本文内容

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

文章
hoolee 在 21 Jul 2008 创建
最后由 hamishwillee 在 15 Dec 2011 编辑

CS000931


设备, 软件 版本: S60 3rd Edition, MR


  • 详细描述

下列代码片段演示了如何使用CFindItemEngine分析不同类型的内容。如一段给定文本中的电话号码,电子邮件地址,或URL地址,当构造对象要搜索几种类型内容时我们可以将需要分析的类型做为参数传递到CFindItemEngine中。

// 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));

代码自签名即可执行

MMP文件

需要下列链接库

LIBRARY  CommonEngine.lib


源文件

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;


后继条件

特定文本中的每个电子邮件地址都会显示在屏幕上

This page was last modified on 15 December 2011, at 08:54.
104 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×