public string RetrieveString() { SimpleDB.Entry entry = this.RetrieveEntry(); if (entry.Type != SimpleDB.EntryType.String) { throw new SimpleDB.IOException(entry.Type, this.m_Reader); } return(Conversions.ToString(entry.Value)); }
public int RetrieveInt16() { SimpleDB.Entry entry = this.RetrieveEntry(); if (entry.Type != SimpleDB.EntryType.UInt16) { throw new SimpleDB.IOException(entry.Type, this.m_Reader); } return(Conversions.ToInteger(entry.Value)); }
public byte RetrieveByte() { SimpleDB.Entry entry = this.RetrieveEntry(); if (entry.Type != SimpleDB.EntryType.Byte) { throw new SimpleDB.IOException(entry.Type, this.m_Reader); } return(Conversions.ToByte(entry.Value)); }
private void WriteRecord() { if (this.m_currentRecord.Count >= 1) { this.RawWriteByte(0x4d); this.RawWriteInt16(this.m_currentRecord.Count); int num2 = this.m_currentRecord.Count - 1; for (int i = 0; i <= num2; i++) { SimpleDB.Entry entry = this.m_currentRecord[i]; SimpleDB.EntryType type = entry.Type; if (type == SimpleDB.EntryType.Boolean) { this.RawWriteByte(0x42); this.RawWriteByte(Conversions.ToByte(Conversions.ToBoolean(entry.Value) ? 1 : 0)); } else if (type == SimpleDB.EntryType.Byte) { this.RawWriteByte(0x62); this.RawWriteByte(Conversions.ToByte(entry.Value)); } else if (type == SimpleDB.EntryType.String) { this.RawWriteByte(0x53); SimpleDB.Entry entry2 = entry; string text = Conversions.ToString(entry2.Value); this.RawWriteCString(text); entry2.Value = text; } else if (type == SimpleDB.EntryType.UInt16) { this.RawWriteByte(0x49); this.RawWriteInt16(Conversions.ToInteger(entry.Value)); } else { this.RawWriteByte(0x45); } } this.m_currentRecord.Clear(); } }
public SimpleDB.Entry RetrieveEntry() { SimpleDB.Entry entry = new SimpleDB.Entry(); if (this.RecordComplete()) { throw new SimpleDB.IOException("Read past end of record at " + Conversions.ToString(this.m_Reader.BaseStream.Position)); } this.m_EntriesRead++; byte num = this.m_Reader.ReadByte(); entry.Type = (SimpleDB.EntryType)num; byte num3 = num; if (num3 == 0x45) { entry.Value = ""; } else if (num3 == 0x42) { byte num2 = this.m_Reader.ReadByte(); entry.Value = num2 == 1; } else if (num3 == 0x49) { entry.Value = this.RawReadUInt16(); } else if (num3 == 0x53) { entry.Value = this.RawReadCString(); } else if (num3 == 0x62) { entry.Value = this.m_Reader.ReadByte(); } else { entry.Type = SimpleDB.EntryType.Error; entry.Value = ""; } return(entry); }
// Methods public int Add(SimpleDB.Entry Value) { return(base.Add(Value)); }