Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /sml/trunk/src/MLRISC/library/stringOutStream.sml
ViewVC logotype

View of /sml/trunk/src/MLRISC/library/stringOutStream.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 651 - (download) (annotate)
Thu Jun 1 18:34:03 2000 UTC (19 years ago) by monnier
File size: 1379 byte(s)
bring revisions from the vendor branch to the trunk
(* 
 * The basis seems to be missing a string (out)stream type.
 * This is it.
 *
 * -- Allen.
 *)
structure StringOutStream :> STRING_OUTSTREAM =
struct

   structure TextIO = TextIO
   structure TextPrimIO = TextPrimIO

   type streambuf = string list ref

   fun mkStreamBuf ()    = ref [] : streambuf
   fun getString (ref s) = String.concat(List.rev s)
   fun setString (r,s)   = r := [s]     

   fun openStringOut buffer =
   let 
       val writer =
           TextPrimIO.WR 
                { name       = "string stream",
                chunkSize  = 512,
                writeVec   = SOME (fn {buf, i, sz = SOME n} => 
                                      (buffer := buf :: !buffer; n)
                                   |  {buf, i, sz = NONE} =>
                                      (buffer := buf :: !buffer; size buf)),
                writeArr   = NONE,
                writeVecNB = NONE,
                writeArrNB = NONE,
                block      = NONE,
                canOutput  = NONE,
                getPos     = NONE,
                setPos     = NONE,
                endPos     = NONE,
                verifyPos  = NONE,
                close      = fn () => (),
                ioDesc     = NONE
              }
       val outstream = TextIO.mkOutstream 
              (TextIO.StreamIO.mkOutstream (writer,IO.NO_BUF))
   in  outstream
   end

end


root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0