/////////////////////////////////////////////////////////////////////////////// // string-bundle /////////////////////////////////////////////////////////////////////////////// import "base/types" import "base/memory" import "text/string" import "memory-bundle" //----------------------------------------------------------------------------- // Construct a string from a raw buffer //----------------------------------------------------------------------------- public func new string (bundle: memory bundle, s: string) def len = size (s) + 1 def buf = allocate (bundle, len):string copy (buf:mem, s:mem, len) return buf end //----------------------------------------------------------------------------- // Construct a string from a raw buffer //----------------------------------------------------------------------------- public func new string (bundle: memory bundle, s: string, len: dword) def buf = allocate (bundle, len+1):string copy (buf:mem, s:mem, len) buf[len] = \0 return buf end //----------------------------------------------------------------------------- // Reserve space for a string //----------------------------------------------------------------------------- public func new string (bundle: memory bundle, len: dword) return allocate (bundle, len+1):string end