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

📄 lxdad.cpp

📁 Symbian工程 九宫格界面
💻 CPP
字号:
/*
============================================================================
 Name        : LxdAD.cpp
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : LxdAD.cpp - source file
============================================================================
*/

// INCLUDE FILES
// Class include
//#include "LxdAD.h"
// System includes
//#include <e32base.h>  // For CBase, link against euser.lib
//#include <ResourceFile.rsg>
// User includes
//#include "MyHeaderFile.h"

// ================= MEMBER FUNCTIONS =======================
#include "LxdAD.h"
#include "f32file.h" 
#include "UTF.H" 

#include <aknnotewrappers.h> 

CLxdAD::CLxdAD()
{
	iLxdADId=0;
/*	LxdReadFileAD();*/
}
CLxdAD::~CLxdAD()
{
    iLxdADPointerArr.ResetAndDestroy();
}
void CLxdAD::ConstructL()
{
}
void CLxdAD::LxdReadFileAD()
{
	RFs	fs;
	fs.Connect();
	RFile file;
	CleanupClosePushL(file);

	TInt err = file.Open(fs,_L("C:\\ADInfo.xml"),EFileStream);
	if (err == KErrNone)
	{
		TInt size = 0;
		file.Size(size);
		HBufC8* pBuf8 = HBufC8::NewL(size+1);
		TPtr8 ptr8 = pBuf8->Des();
		User::LeaveIfError(file.Read(ptr8, size));
		HBufC16* pBuf16 = HBufC::NewL(size+1);
		TPtr16 ptr16 = pBuf16->Des();
		CnvUtfConverter::ConvertToUnicodeFromUtf8(ptr16, ptr8);
		if (pBuf8)
		{
			delete pBuf8;
			pBuf8=NULL;
		}
		
		DoXmlParse(*pBuf16);
		if (pBuf16)
		{
			delete pBuf16;
			pBuf16=NULL;
		}
		
	}

	CleanupStack::PopAndDestroy();
	fs.Close();

}
void CLxdAD::DoXmlParse(const TDesC& aString)
{
	TPtrC ptrSting(aString);
	while (ptrSting.Length())
	{
		TInt posBegin = ptrSting.Find(_L("<ADInfo>"));
		TInt posEnd = ptrSting.Find(_L("</ADInfo>"));
		if (posBegin != KErrNotFound && posEnd != KErrNotFound)
		{
			HBufC* pBuf = HBufC::NewL(posEnd-posBegin-8);
			TPtr ptr = pBuf->Des();
			ptr = ptrSting.Mid(posBegin+8, posEnd-posBegin-8);
			ptrSting.Set(ptrSting.Mid(posEnd+9));
			iLxdADPointerArr.AppendL(pBuf);

		}
		else
		{
			ptrSting.Set(KNullDesC);
		}
	}
}
HBufC* CLxdAD::LxdGetAD(TInt aId)
{
    return iLxdADPointerArr[aId];
}
// End of File

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -