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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 651 - (view) (download)

1 : monnier 496 (*
2 :     * The basis seems to be missing a string (out)stream type.
3 :     * This is it.
4 :     *
5 :     * -- Allen.
6 :     *)
7 :     structure StringOutStream :> STRING_OUTSTREAM =
8 :     struct
9 :    
10 :     structure TextIO = TextIO
11 :     structure TextPrimIO = TextPrimIO
12 :    
13 :     type streambuf = string list ref
14 :    
15 :     fun mkStreamBuf () = ref [] : streambuf
16 :     fun getString (ref s) = String.concat(List.rev s)
17 :     fun setString (r,s) = r := [s]
18 :    
19 :     fun openStringOut buffer =
20 :     let
21 :     val writer =
22 :     TextPrimIO.WR
23 :     { name = "string stream",
24 :     chunkSize = 512,
25 :     writeVec = SOME (fn {buf, i, sz = SOME n} =>
26 :     (buffer := buf :: !buffer; n)
27 :     | {buf, i, sz = NONE} =>
28 :     (buffer := buf :: !buffer; size buf)),
29 :     writeArr = NONE,
30 :     writeVecNB = NONE,
31 :     writeArrNB = NONE,
32 :     block = NONE,
33 :     canOutput = NONE,
34 :     getPos = NONE,
35 :     setPos = NONE,
36 :     endPos = NONE,
37 :     verifyPos = NONE,
38 :     close = fn () => (),
39 :     ioDesc = NONE
40 :     }
41 :     val outstream = TextIO.mkOutstream
42 :     (TextIO.StreamIO.mkOutstream (writer,IO.NO_BUF))
43 :     in outstream
44 :     end
45 :    
46 :     end
47 :    

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