Esempio n. 1
0
 public virtual void SetTableType(DBTableHeader.TableType tableType)
 {
     this.tableType = tableType;
 }
Esempio n. 2
0
        /// <summary>read (little endian)</summary>
        /// <exception cref="System.Exception"/>
        public virtual void Read(LittleEndianDataInputStream littleEndianDataInputStream)
        {
            try
            {
                recordBufferSize = littleEndianDataInputStream.ReadUnsignedShort();
                headerBlockSize  = littleEndianDataInputStream.ReadUnsignedShort();
                int tableType = littleEndianDataInputStream.ReadUnsignedByte();
                if (0 == tableType)
                {
                    this.tableType = DBTableHeader.TableType.keyed;
                }
                else
                {
                    if (2 == tableType)
                    {
                        this.tableType = DBTableHeader.TableType.unkeyed;
                    }
                    else
                    {
                        throw new Exception("Unknown table type '" + tableType + "'");
                    }
                }
                dataBlockSizeCode = littleEndianDataInputStream.ReadUnsignedByte();
                if (1 == dataBlockSizeCode)
                {
                    blockSize = DBTableHeader.BlockSize.oneK;
                }
                else
                {
                    if (2 == dataBlockSizeCode)
                    {
                        blockSize = DBTableHeader.BlockSize.twoK;
                    }
                    else
                    {
                        if (3 == dataBlockSizeCode)
                        {
                            blockSize = DBTableHeader.BlockSize.threeK;
                        }
                        else
                        {
                            if (4 == dataBlockSizeCode)
                            {
                                blockSize = DBTableHeader.BlockSize.fourK;
                            }
                            else
                            {
                                throw new Exception("Unknown block size code '" + dataBlockSizeCode + "'");
                            }
                        }
                    }
                }
                numberRecords     = littleEndianDataInputStream.ReadInt();
                blocksInUse       = littleEndianDataInputStream.ReadUnsignedShort();
                totalBlocksInFile = littleEndianDataInputStream.ReadUnsignedShort();
                firstDataBlock    = littleEndianDataInputStream.ReadUnsignedShort();
                lastDataBlock     = littleEndianDataInputStream.ReadUnsignedShort();
                littleEndianDataInputStream.SkipBytes(15);
                // byte 0x21
                numberFields = littleEndianDataInputStream.ReadUnsignedByte();
                // byte 0x22
                littleEndianDataInputStream.SkipBytes(1);
                // byte 0x23
                numberKeyFields = littleEndianDataInputStream.ReadUnsignedByte();
                littleEndianDataInputStream.SkipBytes(unchecked ((int)(0x54)));
                // byte 0x78
                ReadFieldTypesAndSizes(littleEndianDataInputStream);
                // name
                littleEndianDataInputStream.SkipBytes(20);
                embeddedFilename = StringUtil.ReadString(littleEndianDataInputStream);

                /*
                 * skip forward 250 bytes
                 */
                int skipBytes = 250;
                // dumpBytes(skipBytes, littleEndianDataInputStream);
                littleEndianDataInputStream.SkipBytes(skipBytes);
                ReadFieldNames(littleEndianDataInputStream);
            }
            catch (Exception e)
            {
                throw new Exception("Exception in read", e);
            }
        }