private T read_element <T>(SprotoTypeReader reader, UInt32 sz, out UInt32 read_size) where T : SprotoTypeBase, new() { read_size = 0; if (sz < SprotoTypeSize.sizeof_length) { SprotoTypeSize.error("error array size."); } UInt32 hsz = this.read_dword(); sz -= (UInt32)SprotoTypeSize.sizeof_length; read_size += (UInt32)SprotoTypeSize.sizeof_length; if (hsz > sz) { SprotoTypeSize.error("error array object."); } reader.Init(this.reader.Buffer, this.reader.Offset, (int)hsz); this.reader.Seek(this.reader.Position + (int)hsz); T obj = new T(); obj.init(reader); read_size += hsz; return(obj); }
public List <T> read_obj_list <T>() where T : SprotoTypeBase, new() { UInt32 sz = this.read_array_size(); List <T> obj_list = new List <T> (); SprotoTypeReader reader = new SprotoTypeReader(); for (UInt32 i = 0; sz > 0; i++) { if (sz < SprotoTypeSize.sizeof_length) { SprotoTypeSize.error("error array size."); } UInt32 hsz = this.read_dword(); sz -= (UInt32)SprotoTypeSize.sizeof_length; if (hsz > sz) { SprotoTypeSize.error("error array object."); } reader.Init(this.reader.Buffer, this.reader.Offset, (int)hsz); this.reader.Seek(this.reader.Position + (int)hsz); T obj = new T(); obj.init(reader); obj_list.Add(obj); sz -= hsz; } return(obj_list); }