[erlang-questions] how: string stream?

Ulf Wiger (TN/EAB) ulf.wiger@REDACTED
Wed Oct 31 10:34:14 CET 2007


Bengt Kleberg wrote:
> greetings,
> 
> there are at least two string streams that i know of. Ulf Wiger has one 
> and I have one (string_io). his should be better.

I assume you mean this:

http://erlhive.svn.sourceforge.net/viewvc/erlhive/trunk/lib/erlhive/src/erlhive_ram_file_io_server.erl?revision=57&view=markup

used in this fasion:

http://erlhive.svn.sourceforge.net/viewvc/erlhive/trunk/lib/erlhive/src/erlhive_rewrite.erl?revision=64&view=markup

   121 parse_string(Str, Fname) ->
   122     {ok, Fd} = open_ram_file(Fname),
   123     file:write(Fd, Str),
   124     file:position(Fd, 0),
   125     case epp_dodger:parse(Fd) of
   126 	{ok, Tree} ->
   127 	    close_ram_file(Fd),
   128 	    Tree;
   129 	Error ->
   130 	    close_ram_file(Fd),
   131 	    erlang:error(Error)
   132     end.
   133
   134
   135 open_ram_file(Fname) ->
   136     erlhive_ram_file_io_server:start(self(), Fname, [read,write]).
   137
   138 close_ram_file(Fd) ->
   139     file:close(Fd).

It's not exactly a string stream, though.

BR,
Ulf W



More information about the erlang-questions mailing list