本文整理汇总了C++中KeyValue::Attach方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyValue::Attach方法的具体用法?C++ KeyValue::Attach怎么用?C++ KeyValue::Attach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyValue
的用法示例。
在下文中一共展示了KeyValue::Attach方法的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++)
//.........这里部分代码省略.........