/// <summary> /// /// </summary> /// <param name="dict"></param> public void CompleteDefn(HfaDictionary dict) { // Get a reference to the type object if we have a type name // for this field (not a build in). if (_itemObjectTypeString != null) { _itemObjectType = dict[_itemObjectTypeString]; } // Figure out the size if (_pointer == 'p') { _numBytes = -1; } else if (_itemObjectType != null) { _itemObjectType.CompleteDefn(dict); if (_itemObjectType.NumBytes == -1) { _numBytes = -1; } else { _numBytes = (short)(_itemObjectType.NumBytes * _itemCount); } if (_pointer == '*' && _numBytes != -1) { _numBytes += 8; } } else { _numBytes = (short)(HfaDictionary.GetItemSize(_itemType) * _itemCount); } }
/// <summary> /// Completes the defenition of this type based on the existing dictionary. /// </summary> /// <param name="dictionary">Dictionary used for completion.</param> public void CompleteDefn(HfaDictionary dictionary) { // This may already be done, if an earlier object required this // object (as a field), and forced and early computation of the size if (NumBytes != 0) { return; } // Complete each fo the fields, totaling up the sizes. This // isn't really accurate for objects with variable sized // subobjects. foreach (HfaField field in Fields) { field.CompleteDefn(dictionary); if (field.NumBytes < 0 || NumBytes == -1) { NumBytes = -1; } else { NumBytes += field.NumBytes; } } }
/// <summary> /// Scans through the array and estimates the byte size of the field in this case. /// </summary> /// <param name="data">The data.</param> /// <param name="dataOffset">The data offset.</param> /// <returns>The byte size of the field.</returns> public int GetInstBytes(byte[] data, long dataOffset) { int nCount; int nInstBytes = 0; long offset = dataOffset; // Hard sized fields just return their constant size if (NumBytes > -1) { return(NumBytes); } // Pointers have a 4 byte integer count and a 4 byte uint offset if (Pointer != '\0') { nCount = Hfa.ReadInt32(data, offset); offset += 8; nInstBytes += 8; } else { // Anything other than a pointer only can have one item. nCount = 1; } if (ItemType == 'b' && nCount != 0) { // BASEDATA int nRows = Hfa.ReadInt32(data, offset); offset += 4; int nColumns = Hfa.ReadInt32(data, offset); offset += 4; HfaEpt baseItemType = (HfaEpt)Hfa.ReadInt16(data, offset); nInstBytes += 12; nInstBytes += ((baseItemType.GetBitCount() + 7) / 8) * nRows * nColumns; } else if (ItemObjectType == null) { nInstBytes += nCount * HfaDictionary.GetItemSize(ItemType); } else { for (int i = 0; i < nCount; i++) { nInstBytes += ItemObjectType.GetInstBytes(data, offset + nInstBytes); } } return(nInstBytes); }