public TableField(ref RandomAccess ra) { _fieldType = ra.leByte(); _offset = ra.leShort(); _fieldName = ra.zeroTerminatedString(); //remove the table name from the start if it is there if (_fieldName.IndexOf(':') > 0) { _fieldName = _fieldName.Substring(_fieldName.IndexOf(':') + 1); } _elements = ra.leShort(); _length = ra.leShort(); _flags = ra.leShort(); _index = ra.leShort(); switch (_fieldType) { case 0x0a: _bcdDigitsAfterDecimalPoint = ra.leByte(); _bcdLengthOfElement = ra.leByte(); break; case 0x12: case 0x13: case 0x14: _stringLength = ra.leShort(); _stringMask = ra.zeroTerminatedString(); if (_stringMask.Length == 0) { ra.leByte(); } break; } }
public TableMemo(ref RandomAccess ra) { _externalFile = ra.zeroTerminatedString(); if (_externalFile.Length == 0) { if (ra.leByte() != 1) { throw new Exception("Bad Memo Definition, missing 0x01 after zero string:" + _externalFile); } } _name = ra.zeroTerminatedString(); _length = ra.leShort(); _flags = ra.leShort(); }
public TableIndex(ref RandomAccess ra) { _externalFile = ra.zeroTerminatedString(); if (_externalFile.Length == 0) { int read = ra.leByte(); if (read != 1) { throw new Exception("Bad Index Definition, missing 0x01 after zero string (" + ra.toHex2(read) + ")"); } } _name = ra.zeroTerminatedString(); _flags = ra.leByte(); _fieldsInKey = ra.leShort(); _keyField = new int[_fieldsInKey]; _keyFieldFlag = new int[_fieldsInKey]; for (int t = 0; t < _fieldsInKey; t++) { _keyField[t] = ra.leShort(); _keyFieldFlag[t] = ra.leShort(); } }
public object parseField(int type, int ofs, int len, TableField field, RandomAccess ra) { ra.jumpAbs(ofs); switch (type) { case 1: // byte assertEqual(1, len); return(ra.leByte()); case 2: // short assertEqual(2, len); return(ra.leShort()); case 3: // unsigned short assertEqual(2, len); return(ra.leUShort()); case 4: // Date, mask encoded. long date = ra.leULong(); if (date != 0) { long years = (date & 0xFFFF0000) >> 16; long months = (date & 0x0000FF00) >> 8; long days = (date & 0x000000FF); return(new DateTime((int)years, (int)months, (int)days)); } else { return(null); } case 5: // // Time, mask encoded. // So far i've only had values with hours and minutes // but no seconds or milliseconds so I've no way of // knowing how to decode these. // //TODO: Fix the time here based on decaseconds int time = ra.leLong(); int mins = (time & 0x00FF0000) >> 16; int hours = (time & 0x7F000000) >> 24; // return(hours + " " + mins); // case 6: // Long assertEqual(4, len); return(ra.leLong()); case 7: // Unsigned Long assertEqual(4, len); return(ra.leULong()); case 8: // Float assertEqual(4, len); return(ra.leFloat()); case 9: // Double assertEqual(8, len); return(ra.leDouble()); case 0x0A: // BCD encoded. return(ra.binaryCodedDecimal(len, field.BcdLengthOfElement, field.BcdDigitsAfterDecimalPoint)); case 0x12: // Fixed Length String return(ra.fixedLengthString(len)); case 0x13: return(ra.zeroTerminatedString()); case 0x14: return(ra.pascalString()); case 0x16: // Group (an overlay on top of existing data, can be anything). return(ra.leBytes(len)); default: throw new Exception("Unsupported type " + type + " (" + len + ")"); } }