?? recogex.cpp
字號:
// RecogEx.CPP
//
// Copyright (C) 2003 Nokia Corporation. All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////
#include "recogex.h"
const TInt KMimeExRecognizerValue=0x01EF0010;
const TUid KUidMimeExRecognizer={KMimeExRecognizerValue};
const TInt KExNumMimeTypes=1;
_LIT8(KDummyMimeType,"text/dum");
/*
-------------------------------------------------------------------------------
Constructor
Return value: N/A
-------------------------------------------------------------------------------
*/
CApaExRecognizer::CApaExRecognizer()
:CApaDataRecognizerType(KUidMimeExRecognizer,CApaDataRecognizerType::ENormal)
// All these mime types have reasonable recognition
{
iCountDataTypes=KExNumMimeTypes;
}
/*
-------------------------------------------------------------------------------
PreferredBufSize
Description: gets the size of buffer preferred for the purpose of
recognizing the data type
Return value: 0 or the size of the buffer
-------------------------------------------------------------------------------
*/
TUint CApaExRecognizer::PreferredBufSize()
{
// no buffer recognition in this example
return 0;
}
/*
-------------------------------------------------------------------------------
SupportedDataTypeL
Description: gets one of the data (MIME) types that the recognizer can
recognize
Return value: "text/dum" in this example
-------------------------------------------------------------------------------
*/
TDataType CApaExRecognizer::SupportedDataTypeL(TInt aIndex) const
{
__ASSERT_DEBUG(aIndex>=0 && aIndex<KExNumMimeTypes,User::Invariant());
switch (aIndex)
{
case 0:
return TDataType(KDummyMimeType);
default:
return TDataType(KDummyMimeType);
}
}
/*
-------------------------------------------------------------------------------
DoRecognizeL
Description: Implements the attempt to recognize data. The function is
called by RecognizeL().
Return value: N/A
-------------------------------------------------------------------------------
*/
void CApaExRecognizer::DoRecognizeL(const TDesC& aName, const TDesC8& /*aBuffer*/)
{
TParse parse;
parse.Set(aName,NULL,NULL);
TPtrC ext=parse.Ext();
_LIT(KDotDummy,".dum");
iConfidence = ENotRecognized;
// To keep the sample code simple, we only try to recognize from the file name
// extension.
if (ext.CompareF(KDotDummy) == 0)
{
iDataType=TDataType(KDummyMimeType);
iConfidence=EPossible;
}
// If you wish to be certain, define a proper preferred buffer size in the
// PreferredBufSize method, then implement the data recognition as follows:
/*
_LIT8(KMyContentHeader,"#!OwnCode\n");
// recognition based on ones own code
if(aBuffer.Length() > 9)
{
if(aBuffer.Left(10).CompareF(KMyContentHeader) == 0)
{
if (iConfidence == EPossible)
iConfidence == ECertain;
}
}
// remember that the "if" loop above is not the best way to implement.
// The intention is only to show you how to compare the data content.
*/
}
/*
-------------------------------------------------------------------------------
Export function
Description: The gate function - ordinal 1
Return value: A pointer to the new recognizer object
-------------------------------------------------------------------------------
*/
EXPORT_C CApaDataRecognizerType* CreateRecognizer()
{
CApaDataRecognizerType* thing=new CApaExRecognizer();
return thing; // NULL if new failed
}
/*
-------------------------------------------------------------------------------
DLL entry point
Return value: KErrNone
-------------------------------------------------------------------------------
*/
GLDEF_C TInt E32Dll(TDllReason /*aReason*/)
{
return KErrNone;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -