internal void pack(Page pg, int i) { byte[] dst = pg.data; switch (key.type) { case ClassDescriptor.FieldType.tpBoolean: case ClassDescriptor.FieldType.tpSByte: case ClassDescriptor.FieldType.tpByte: dst[BtreePage.firstKeyOffs + i] = (byte)key.ival; break; case ClassDescriptor.FieldType.tpShort: case ClassDescriptor.FieldType.tpUShort: case ClassDescriptor.FieldType.tpChar: Bytes.pack2(dst, BtreePage.firstKeyOffs + i * 2, (short)key.ival); break; case ClassDescriptor.FieldType.tpInt: case ClassDescriptor.FieldType.tpUInt: case ClassDescriptor.FieldType.tpEnum: case ClassDescriptor.FieldType.tpObject: case ClassDescriptor.FieldType.tpOid: Bytes.pack4(dst, BtreePage.firstKeyOffs + i * 4, key.ival); break; case ClassDescriptor.FieldType.tpLong: case ClassDescriptor.FieldType.tpULong: case ClassDescriptor.FieldType.tpDate: Bytes.pack8(dst, BtreePage.firstKeyOffs + i * 8, key.lval); break; case ClassDescriptor.FieldType.tpFloat: Bytes.packF4(dst, BtreePage.firstKeyOffs + i * 4, (float)key.dval); break; case ClassDescriptor.FieldType.tpDouble: Bytes.packF8(dst, BtreePage.firstKeyOffs + i * 8, key.dval); break; case ClassDescriptor.FieldType.tpDecimal: Bytes.packDecimal(dst, BtreePage.firstKeyOffs + i * 16, key.dec); break; case ClassDescriptor.FieldType.tpGuid: Bytes.packGuid(dst, BtreePage.firstKeyOffs + i * 16, key.guid); break; default: Debug.Assert(false, "Invalid type"); break; } Bytes.pack4(dst, BtreePage.firstKeyOffs + (BtreePage.maxItems - i - 1) * 4, oid); }
public int packF4(int offs, float val) { extend(offs + 4); Bytes.packF4(arr, offs, val); return(offs + 4); }