//[of]:description //[c]Read contiguous data from memory //[cf] //[of]:imports //[c] import "base/types" import "base/memory" import "base/memory-allocator" import "text/string" //[cf] //[of]:structures //[c] public struct memory reader private p: [] byte end //[cf] //[c] //[of]:initialize - release //[of]:memory reader (base) //[c] public equ memory reader (p: [] byte, return s: memory reader) = initialize (s, p) //[cf] //[of]:initialize (s, base) //[c] public func initialize (s: memory reader, p: [] byte) p (s) = p end //[cf] //[cf] //[of]:accessing //[of]:get char (s) //[c] public func get char (s: memory reader) def p = p (s) p (s) += 1 return p : [] char [] end //[cf] //[of]:get string (s) //[c] public func get string (s: memory reader) def p = p (s) def size = size (p : string) + 1 p (s) += size return p : string end //[cf] //[of]:get dword (s) //[c] public func get dword (s: memory reader) def p = p (s) p (s) += sizeof dword return p : [] dword [] end //[cf] //[of]:get word (s) //[c] public func get word (s: memory reader) def p = p (s) p (s) += sizeof word return p : [] word [] end //[cf] //[of]:get byte (s) //[c] public func get byte (s: memory reader) def p = p (s) p (s) += sizeof byte return p : [] byte [] end //[cf] //[cf]