现在的位置: 首页 > 综合 > 正文

嵌套读取

2013年05月03日 ⁄ 综合 ⁄ 共 1025字 ⁄ 字号 评论关闭

RegisterMap的时候,只MapDataField部分的;

所以之后的解码就可以变为:

static int DecodeCurrentLen = 0;
std::ostream OutStream;
std::string m_Str;
std::hash_map<int,std::string> IdStrMap;
char *aBufEnd ;
DecodeLengthDump(char *aBuf,int aContentLen,int aLen)
{
	DecodeVariable(aBuf,aContentLen,aLen);
	DecodeCurrentLen += aContentLen;
	OutStream << m_Str[DecodeCurrentLen] << " Length " << aLen << endl;
}
DecodeIDDump(char *aBuf,int aContentLen,int aID)
{
	DecodeVariable(aBuf,aContentLen,aID);
	DecodeCurrentLen += aContentLen;
	OutStream << m_Str[DecodeCurrentLen] << " " << IdStrMap[aID] << " " << aID << endl;
}

DecodeStructure(char *aBuf,int aContentLen,int aValue)
{
	int lContentLen,lLen,lID;
	DecodeLengthDump(aBuf,aContentLen,lLen);
	DecodeIDDump(aBuf,aContentLen,lID);
}
void MessageDecode(char *aBuf)
{
	int lContentLen,lValue;
	DecodeVersion(aBuf,lContentLen,lValue);
	DecodeStructure(aBuf,aContentLen,aID);
	aBufEnd = aBuf + lContentLen;

	while(aBuf != aBufEnd)
	{
		DecodeStructure(aBuf,aContentLen,aID);
		std::map<int, Fun> lMap;
		std::map<int, Fun>::iterator iter = lMap.find(aID);
		if (iter != lMap.end())
		{
			boost::bind(iter->second,aBuf,aContent,aID);
		}
	}
}

抱歉!评论已关闭.