Node::Node(const Block &blk) { // notice here char* mem = (char*)malloc(BLOCK_SIZE); memcpy(mem, blk.data, BLOCK_SIZE); isleaf = mem[0]; isroot = mem[1]; mem += 2*sizeof(char); int pSize = readi(mem), kSize = readi(mem), typeId = readi(mem), strLen = readi(mem); //system("pause"); int p = 0; for( int i = 0; i < pSize; i++ ) { p = readi(mem); P.push_back(p); } for( int i = 0; i < kSize; i++ ) { AttrType k; if( typeId == 0 ) { // int k = AttrType(readi(mem)); } else if( typeId == 1 ) { // float k = AttrType(readf(mem)); } else if( typeId == 2 ) { // string k = AttrType(reads(mem, strLen)); } K.push_back(k); } }
static AttrType findGenericAttribute(U2AttributeDbi* adbi, const U2DataId& objectId, const QString& attrName, U2DataType type, U2OpStatus& os) { QList<U2DataId> attributeIds = adbi->getObjectAttributes(objectId, attrName, os); if (attributeIds.isEmpty() || os.hasError()) { return AttrType(); } U2Dbi* dbi = adbi->getRootDbi(); foreach(const U2DataId& id, attributeIds) { if (dbi->getEntityTypeById(id) == type) { return getAttribute<AttrType>(adbi, id, os); } } return AttrType(); }
AttrType string_to_max_attr(String const& rString) { long const max_attr = long(rString); ASSERT(max_attr + 1 >= Combo::VALUE_CNT_MIN); ASSERT(max_attr + 1<= Combo::VALUE_CNT_MAX); AttrType const result = AttrType(max_attr); return result; }
void Node::resetByBlock(const Block &blk) { char* mem = (char*)malloc(BLOCK_SIZE); memcpy(mem, blk.data, BLOCK_SIZE); isleaf = mem[0]; isroot = mem[1]; mem += 2*sizeof(char); int pSize = readi(mem), kSize = readi(mem), typeId = readi(mem), strLen = readi(mem); //system("pause"); std::vector<AttrType>::iterator iter_K=K.begin(); for ( ;iter_K!=K.end();) iter_K=K.erase(iter_K); std::vector<int>::iterator iter_P=P.begin(); for ( ;iter_P!=P.end();) iter_P=P.erase(iter_P); int p = 0; for( int i = 0; i < pSize; i++ ) { p = readi(mem); P.push_back(p); } for( int i = 0; i < kSize; i++ ) { AttrType k; if( typeId == 0 ) { // int k = AttrType(readi(mem)); } else if( typeId == 1 ) { // float k = AttrType(readf(mem)); } else if( typeId == 2 ) { // string k = AttrType(reads(mem, strLen)); } K.push_back(k); } }
/* static */ AttrType Combo::CharToAttr(AttrModeType display_mode, char ch) { AttrType result = 0; switch (display_mode) { case ATTR_MODE_ABC: result = AttrType(ch - 'A'); break; case ATTR_MODE_RST: result = AttrType(ch - 'R'); break; case ATTR_MODE_123: result = AttrType(ch - '1'); break; default: FAIL(); } if (result >= VALUE_CNT_MAX) { result = 0; } return result; }