⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recogex.cpp

📁 symbian嵌入程序调用
💻 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 + -