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

📄 tag.cpp

📁 一个可以加载图片作为下拉菜单的symbian手机示例
💻 CPP
字号:
#include "Tag.h"
//#include "CommonDispatcher.h"
TTagAttribute::TTagAttribute()
{
}

TTagAttribute::TTagAttribute(const TDesC& aName,const TDesC& aValue)
:iAttributeName(aName),iAttributeValue(aValue)
,iIntAttrValue(0)
{
	//iAttributeName.Copy(aName,aName.Length());

}

TTagAttribute::TTagAttribute(const TDesC& aName,const TInt aValue)
:iAttributeName(aName),iIntAttrValue(aValue)
{
	
}
TTagAttribute::~TTagAttribute()
{
}

TTag::TTag():iIntTagValue(0),iTagName(KNullDesC),iTagVale(KNullDesC)
{
	

}


TTag::~TTag()
{
	attributeList.Close();
	//attributeList.
}

void TTag::SetTagName(const TDesC&  aTagName)
{
	iTagName.Set(aTagName);
}

void TTag::SetTagValue(const TDesC&  aTagValue)
{
	iTagVale.Set(aTagValue);
}

void TTag::SetTagIntValue(const TInt  aTagValue)
{
	iIntTagValue = aTagValue;
}

TDesC & TTag::GetTagName()
{
	return iTagName;
}

TDesC &  TTag::GetTagValue()
{
	return iTagVale;
}


void TTag::AppendAttribule(const TDesC& aName,const TDesC& aValue)
{
	TTagAttribute attribute(aName,aValue);
	attributeList.Append(attribute);
}

void TTag::AppendAttribule(const TDesC& aName,const TInt aValue)
{
	TTagAttribute attribute(aName,aValue);
	attributeList.Append(attribute);
}

void TTag::Reset()
{
	iTagVale.Set(KNullDesC);
	iIntTagValue = 0;
	attributeList.Reset();
}

RArray<TTagAttribute>  TTag::GetAttributeList()
{
	return attributeList;
}

//通过指定的属性名称取得该属性的值
TPtrC  TTag::GetTagAttrValue(const TDesC& aAttrName)
{

	for (TInt i = 0; i < attributeList.Count(); ++i) 
	{
	
		TTagAttribute attr = attributeList[i];
		if(attributeList[i].iAttributeName == aAttrName)
			return attr.iAttributeValue;
	} 
	return TPtrC(KNullDesC);
}


//如果属性值是数字格式则取出其对应的整形值
TInt TTag::GetTagAttrIntValue(const TDesC& aAttrName)
{
	TInt val = 0;
	for (TInt i = 0; i < attributeList.Count(); ++i) 
	{
		TTagAttribute attr = attributeList[i];
		if(attr.iAttributeName == aAttrName) 
		{
			val =  attr.iIntAttrValue;
			break;
		}
			
	}
	//从字符串中解析数字类型
	if(val == 0 ) 
	{
		TBufC<10> number(GetTagAttrValue(aAttrName));
		TLex myLexer (number);	
		if(myLexer.Val(val) != KErrNone ) 
		{
			return 0;
		}		
	}

	//User::LeaveIfError ();
	return val;
}

TInt TTag::GetIntValue()
{
	if(iIntTagValue == 0)
	{
		TBufC<10> number(iTagVale);
		TLex myLexer (number);	
		User::LeaveIfError (myLexer.Val(iIntTagValue));
		
	}
	return iIntTagValue;

}

⌨️ 快捷键说明

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