using System.IO; namespace Com.Xagasoft.Gats { public abstract class GatsObject { public abstract void Read( Stream s, char type ); public abstract void Write( Stream s ); public static GatsObject Read( Stream s ) { int b = s.ReadByte(); if( b == -1 ) throw new GatsException( GatsException.Type.PrematureEnd ); char type = (char)b; GatsObject ret = null; switch( type ) { case 'i': ret = new GatsInteger(); break; case 's': ret = new GatsString(); break; case '0': case '1': ret = new GatsBoolean(); break; case 'l': ret = new GatsList(); break; case 'd': ret = new GatsDictionary(); break; case 'f': case 'F': ret = new GatsFloat(); break; case 'n': ret = new GatsNull(); break; case 'e': return null; default: throw new GatsException( GatsException.Type.InvalidType ); } ret.Read( s, type ); return ret; } } }