当前位置: 首页>>代码示例>>C++>>正文


C++ KeyValue::CalcHash方法代码示例

本文整理汇总了C++中KeyValue::CalcHash方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyValue::CalcHash方法的具体用法?C++ KeyValue::CalcHash怎么用?C++ KeyValue::CalcHash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KeyValue的用法示例。


在下文中一共展示了KeyValue::CalcHash方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

void KVReader2::ApplyStruct(KeyValue* parent, ntroStruct* str, char* dataH, rerlHeader* rerlH, ntroHeader* ntroH)
{
	// variable prepare
	char* data = dataH;
	ntroStruct* sEntries = (ntroStruct*) (((char*) &ntroH->structOffset) + ntroH->structOffset);
	ntroStruct* baseStruct = 0;
	
	// Apply base struct structure
	if(str->baseStructId != 0)
	{
		// Find it in NTRO block (move this to its own function?)
		for(int s=1;s<ntroH->structCount;s++)
		{
			ntroStruct* checking = sEntries + s;
			if(checking->id == str->baseStructId)
			{
				baseStruct = checking;
				break;
			}
		}
		// Now apply it
		ApplyStruct(parent, baseStruct, data, rerlH, ntroH);
		// Don't need to apply size to data because diskOffset of field in derived struct
		// already include this padding
	}
	// Apply our structure
	ntroField* fEntry = (ntroField*) (((char*) &str->fieldOffset) + str->fieldOffset);
	for(int k=0;k<str->fieldCount;k++)
	{
		// variable prepare
		ntroField* f = fEntry + k;
		char* dataF = data + f->diskOffset;
		// create node, assign name, hash, type
		KeyValue* node = new KeyValue();
		char* fieldName = ((char*) &f->nameOffset) + f->nameOffset;
		node->key = fieldName;
		node->CalcHash();
		node->type = f->type;
		parent->Attach(node);
		
		node->childCountAddress = dataF;
		
		// prepare just in case
		char* indirect =  ((char*) &f->indirectOffset) + f->indirectOffset;
		
		// check for special type
		if(f->indirectLevel > 0)
		{
			// Array of data
			
			// structure: { 4:offset, 4:count }
			unsigned int elemPointerOffset = *((unsigned int*) dataF);
			char* elemPointer = dataF + elemPointerOffset;
			node->childCountAddress = dataF + 4;
			unsigned int elemCount = *((unsigned int*) (node->childCountAddress));
			if(indirect[0] == 0x03) 
			{
				elemCount = 1;
				node->childCountAddress = dataF;
			}
			
			node->realChildCount = elemCount;
			
			if(elemPointerOffset == 0)
			{
				//printf("Indirect pointer is 0, skippping\n");
				continue;
			}
			
			//printf("%s is %d deep with i[0] = %d and have %d child\n",node->key,f->indirectLevel,indirect[0],elemCount);
			
			if(elemCount<=0)
			{
				//printf("Got %d size array, skippping\n",elemCount);
				continue;
			}
			
			if(elemCount>1000)
			{
				// why it has to put all vertex in structure ...
				elemCount = 1000;
			}
			
			node->value = 0;
			
			if(f->type==0x01)
			{
				// finding the structure used for this data from NTRO blocks
				baseStruct = 0;
				for(int s=1;s<ntroH->structCount;s++)
				{
					ntroStruct* checking = sEntries + s;
					if(checking->id == f->typeData)
					{
						baseStruct = checking;
						break;
					}
				}
				// loop over each element
				for(int e=0;e<elemCount;e++)
//.........这里部分代码省略.........
开发者ID:d2armory,项目名称:flare,代码行数:101,代码来源:kvreader2.cpp


注:本文中的KeyValue::CalcHash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。