示例#1
0
void KVReader2::Dump(KeyValue* inNode, unsigned int startAddress)
{
	KeyValue* cur = inNode;

	while(cur!=0) 
	{
	
		for(int i=0;i<cur->depth;i++)
		{
			printf("    ");
		}
		if(cur->key!=0)
		{
			//printf("= '%s' [%X] :",cur->key,cur->keyHash);
			printf("'%s' : ",cur->key);
		}
		else 
		{
			//printf(" : ");
		}
		if(cur->value != 0)
		{
			if(cur->type==NTRO_DATA_TYPE_HANDLE || cur->type==NTRO_DATA_TYPE_NAME)
			{
				printf("(str) '%s'",cur->AsHandle());
			}
			else if(cur->type==NTRO_DATA_TYPE_INTEGER)
			{
				printf("(int) %d",cur->AsInt());
			}
			else if(cur->type==NTRO_DATA_TYPE_UINTEGER)
			{
				printf("(uint) %u",cur->AsUint());
			}
			else if(cur->type==NTRO_DATA_TYPE_SHORT)
			{
				printf("(short) %d",cur->AsShort());
			}
			else if(cur->type==NTRO_DATA_TYPE_USHORT)
			{
				printf("(ushort) %u",cur->AsUshort());
			}
			else if(cur->type==NTRO_DATA_TYPE_BYTE)
			{
				printf("(byte) %2X",cur->AsByte());
			}
			else if(cur->type==NTRO_DATA_TYPE_BOOLEAN)
			{
				printf("(bool) %2X",cur->AsByte());
			}
			else if(cur->type==NTRO_DATA_TYPE_FLOAT)
			{
				printf("(float) %f",cur->AsFloat());
			}
			else if(cur->type==10)	// not sure what it is, but it's used as image format
			{
				printf("(format 10) %u",cur->AsByte());
			}
			else if(cur->type==NTRO_DATA_TYPE_VECTOR3)
			{
				glm::vec3 v(cur->AsVec3());
				printf("(vec3) [%f, %f, %f]",v[0],v[1],v[2]);
			}
			else if(cur->type==NTRO_DATA_TYPE_VECTOR4)
			{
				glm::vec4 v(cur->AsVec4());
				printf("(vec4) [%f, %f, %f, %f]",v[0],v[1],v[2],v[3]);
			}
			else if(cur->type==NTRO_DATA_TYPE_QUATERNION)
			{
				glm::vec4 v(cur->AsVec4());
				printf("(quat) [%f, %f, %f, %f]",v[0],v[1],v[2],v[3]);
			}
			else if(cur->type==NTRO_DATA_TYPE_COLOR)
			{
				glm::vec4 v(cur->AsVec4());
				printf("(color) [%f, %f, %f, %f]",v[0],v[1],v[2],v[3]);
			}
			else
			{
				printf("(unknown %d) %2X",cur->type, (unsigned int) cur->value);
			}
			
			printf(" @%X",(unsigned int)cur->value+16 - (unsigned int)startAddress);
		}
		else
		{
			printf("[%d/%d]",cur->childCount,cur->realChildCount);
			printf(" @%X",(unsigned int)cur->childCountAddress+16 - (unsigned int)startAddress);
		}
		printf("\n");
		
		Dump(cur->child, startAddress);
	
		cur = cur->sibling;
	
	}
	
}