str_stream.sa
Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
---------------------------> Sather 1.1 source file <--------------------------
-- Author: Benedict A. Gomes <gomes@samosa.ICSI.Berkeley.EDU>
-- Copyright (C) 1995, International Computer Science Institute
-- $Id: str_stream.sa,v 1.2 1996/04/09 10:05:57 borisv Exp $
--
-- COPYRIGHT NOTICE: This code is provided WITHOUT ANY WARRANTY
-- and is subject to the terms of the SATHER LIBRARY GENERAL PUBLIC
-- LICENSE contained in the file: Sather/Doc/License of the
-- Sather distribution. The license is also available from ICSI,
-- 1947 Center St., Suite 600, Berkeley CA 94704, USA.
class STR_STREAM < $OSTREAM, $STR
class STR_STREAM < $OSTREAM, $STR is
-- An output stream that writes out to a string (an FSTR, for
-- efficiency). Very similar to a file.
--
-- Usage:
-- write_to_stream(o: $OUTSTREAM) is
-- o + "this is a test";
-- end;
-- Which can be invoked using:
-- s: STR_STREAM := #;
-- write_to_stream(s);
-- write_to_stream(s);
-- s.str then would have two copies of "this is a test" in it.
private attr f: FSTR;
create: SAME is
-- Create a new stream
res ::= new;
res.f := #FSTR("");
return res;
end;
plus(s: $STR): SAME is
-- Append the string "s" to self
f := f+s.str;
return self;
end;
plus(s: $STR) is discard ::= plus(s) end;
str: STR is return f.str; end;
end; -- class STR_STREAM