本文整理汇总了C++中PVFieldPtr::getNumberFields方法的典型用法代码示例。如果您正苦于以下问题:C++ PVFieldPtr::getNumberFields方法的具体用法?C++ PVFieldPtr::getNumberFields怎么用?C++ PVFieldPtr::getNumberFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PVFieldPtr
的用法示例。
在下文中一共展示了PVFieldPtr::getNumberFields方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkBitSetPVField
static bool checkBitSetPVField(
PVFieldPtr const &pvField,BitSetPtr const &bitSet,int32 initialOffset)
{
int32 offset = initialOffset;
int32 nbits = static_cast<int32>(pvField->getNumberFields());
if(nbits==1) return bitSet->get(offset);
int32 nextSetBit = bitSet->nextSetBit(offset);
if(nextSetBit>=(offset+nbits)) return false;
if(nextSetBit<0) return false;
if(bitSet->get(offset)) {
if(nbits>1) {
for(int32 i=offset+1; i<offset+nbits; i++) bitSet->clear(i);
}
return true;
}
bool atLeastOneBitSet = false;
bool allBitsSet = true;
PVStructurePtr pvStructure = static_pointer_cast<PVStructure>(pvField);
offset = static_cast<int32>(pvStructure->getFieldOffset()) + 1;
while(offset<initialOffset + nbits) {
PVFieldPtr pvSubField = pvStructure->getSubField(offset);
int32 nbitsNow = static_cast<int32>(pvSubField->getNumberFields());
if(nbitsNow==1) {
if(bitSet->get(offset)) {
atLeastOneBitSet = true;
} else {
allBitsSet = false;
}
offset++;
} else {
bool result = checkBitSetPVField(pvSubField,bitSet,offset);
if(result) {
atLeastOneBitSet = true;
if(!bitSet->get(offset)) {
allBitsSet = false;
}
} else {
allBitsSet = false;
}
offset += static_cast<int32>(pvSubField->getNumberFields());
}
}
if(allBitsSet) {
if(nbits>1) {
for(int32 i=initialOffset+1; i<initialOffset+nbits; i++) {
bitSet->clear(i);
}
}
bitSet->set(initialOffset);
}
return atLeastOneBitSet;
}
示例2: deserialize
void PVStructure::deserialize(ByteBuffer *pbuffer,
DeserializableControl *pcontrol, BitSet *pbitSet) {
size_t offset = getFieldOffset();
size_t numberFields = getNumberFields();
int32 next = pbitSet->nextSetBit(offset);
// no more changes or no changes in this structure
if(next<0||next>=static_cast<int32>(offset+numberFields)) return;
// entire structure
if(static_cast<int32>(offset)==next) {
deserialize(pbuffer, pcontrol);
return;
}
size_t fieldsSize = pvFields.size();
for(size_t i = 0; i<fieldsSize; i++) {
PVFieldPtr pvField = pvFields[i];
offset = pvField->getFieldOffset();
int32 inumberFields = pvField->getNumberFields();
next = pbitSet->nextSetBit(offset);
// no more changes
if(next<0) return;
// no change in this pvField
if(next>=static_cast<int32>(offset+inumberFields)) continue;
// deserialize field or fields
if(inumberFields==1) {
pvField->deserialize(pbuffer, pcontrol);
} else {
PVStructurePtr pvStructure = std::tr1::static_pointer_cast<PVStructure>(pvField);
pvStructure->deserialize(pbuffer, pcontrol, pbitSet);
}
}
}