Overview  Index  Help 
Standard ML Basis Library

TextIOFn


functor TextIOFn(structure OSPrimIO :
                 sig
                   include OS_PRIM_IO
                   val stdIn : unit -> PrimIO.reader
                   val stdOut : unit -> PrimIO.writer
                   val stdErr : unit -> PrimIO.writer
                   val strReader : string -> PrimIO.reader
                 end
                   where PrimIO = TextPrimIO) : TEXT_IO =
struct
  structure PIO = OSPrimIO.PrimIO
  structure A = CharArray
  structure V = CharVector
  structure AS = CharArraySlice
  structure VS = CharVectorSlice
  structure StreamIO =
  struct
    type vector = V.vector
    type elem = V.elem
    type reader = PIO.reader
    type writer = PIO.writer
    type pos = PIO.pos
    datatype instream = ISTRM of in_buffer * int
    datatype in_buffer =
             IBUF of
             {basePos : pos option, more : more ref, data : vector, info : info}
    datatype more = MORE of in_buffer | EOS of in_buffer | NOMORE | TERMINATED
    datatype info =
             INFO of
             {
               reader : reader,
               readVec : int -> vector,
               readVecNB : (int -> vectoroption,
               closed : bool ref,
               getPos : unit -> pos option,
               tail : more ref ref,
               cleanTag : CleanIO.tag
             }
    datatype outstream =
             OSTRM of
             {
               buf : A.array,
               pos : int ref,
               closed : bool ref,
               bufferMode : IO.buffer_mode ref,
               writer : writer,
               writeArr : {buf : A.array, i : int, sz : int option} -> unit,
               writeVec : {buf : V.vector, i : int, sz : int option} -> unit,
               cleanTag : CleanIO.tag
             }
    datatype out_pos = OUTP of {pos : PIO.pos, strm : outstream}
    exception WouldBlock
    val infoOfIBuf
    val chunkSzOfIBuf
    val readVec
    val inputExn
    val extendStream
    val getBuffer
    val readChunk
    val generalizedInput
    val terminate
    val input : instream -> vector * instream
    val input1 : instream -> (elem * instreamoption
    val inputN : instream * int -> vector * instream
    val inputAll : instream -> vector * instream
    val canInput : instream * int -> int option
    val closeIn : instream -> unit
    val endOfStream : instream -> bool
    val mkInstream : reader * vector -> instream
    val getReader : instream -> reader * vector
    val filePosIn : instream -> pos
    val inputLine : instream -> string * instream
    val outputExn
    val isNL
    val isClosedOut
    val flushBuffer
    val lineBufCopyVec
    val blockBufCopyVec
    val output : outstream * vector -> unit
    val output1 : outstream * elem -> unit
    val flushOut : outstream -> unit
    val closeOut : outstream -> unit
    val mkOutstream : writer * IO.buffer_mode -> outstream
    val getWriter : outstream -> writer * IO.buffer_mode
    val getPosOut : outstream -> out_pos
    val filePosOut : out_pos -> pos
    val setPosOut : out_pos -> unit
    val outputSubstr : outstream * substring -> unit
    val setBufferMode : outstream * IO.buffer_mode -> unit
    val getBufferMode : outstream -> IO.buffer_mode
  end
  type vector = V.vector
  type elem = V.elem
  type instream = StreamIO.instream ref
  type outstream = StreamIO.outstream ref
  val someElem
  val vecExtract
  val vecSub
  val arrUpdate
  val substringBase
  val empty
  val input : instream -> vector
  val input1 : instream -> elem option
  val inputN : instream * int -> vector
  val inputAll : instream -> vector
  val canInput : instream * int -> int option
  val lookahead : instream -> elem option
  val closeIn : instream -> unit
  val endOfStream : instream -> bool
  val output : outstream * vector -> unit
  val output1 : outstream * elem -> unit
  val flushOut : outstream -> unit
  val closeOut : outstream -> unit
  val getPosOut : outstream -> StreamIO.out_pos
  val setPosOut : outstream * StreamIO.out_pos -> unit
  val mkInstream : StreamIO.instream -> instream
  val getInstream : instream -> StreamIO.instream
  val setInstream : instream * StreamIO.instream -> unit
  val mkOutstream : StreamIO.outstream -> outstream
  val getOutstream : outstream -> StreamIO.outstream
  val setOutstream : outstream * StreamIO.outstream -> unit
  val bufferMode
  val openIn : string -> instream
  val openOut : string -> outstream
  val openAppend : string -> outstream
  val inputLine : instream -> string
  val outputSubstr : outstream * substring -> unit
  val openString : string -> instream
  val stdIn : instream
  val stdOut : outstream
  val stdErr : outstream
  val print : string -> unit
  val scanStream
      : ((elemStreamIO.instreamStringCvt.reader ->
           ('a, StreamIO.instreamStringCvt.reader) ->
          instream -> 'a option
end

 
Type detail

vector

type vector = V.vector


elem

type elem = V.elem


instream

type instream = StreamIO.instream ref


outstream

type outstream = StreamIO.outstream ref

     
Value detail

someElem

val someElem


vecExtract

val vecExtract

Fast, but unsafe version (from CharVector) ** val vecSub = InlineT.CharVector.sub val arrUpdate = InlineT.CharArray.update fast vector extract operation. This should never be called with a length of 0. fun vecExtract (v, base, optLen) = let val len = V.length v fun newVec n = let val newV = Assembly.A.create_s n fun fill i = if (i < n) then ( InlineT.CharVector.update(newV, i, vecSub(v, base+i)); fill(i+1)) else () in fill 0; newV end in case (base, optLen) of (0, NONE) => v | (_, NONE) => newVec (len - base) | (_, SOME n) => newVec n end case end


vecSub

val vecSub


arrUpdate

val arrUpdate


substringBase

val substringBase


empty

val empty


input

val input : instream -> vector

Input operations *


input1

val input1 : instream -> elem option


inputN

val inputN : instream * int -> vector


inputAll

val inputAll : instream -> vector


canInput

val canInput : instream * int -> int option


lookahead

val lookahead : instream -> elem option


closeIn

val closeIn : instream -> unit


endOfStream

val endOfStream : instream -> bool


output

val output : outstream * vector -> unit

Output operations *


output1

val output1 : outstream * elem -> unit


flushOut

val flushOut : outstream -> unit


closeOut

val closeOut : outstream -> unit


getPosOut

val getPosOut : outstream -> StreamIO.out_pos


setPosOut

val setPosOut : outstream * StreamIO.out_pos -> unit


mkInstream

val mkInstream : StreamIO.instream -> instream


getInstream

val getInstream : instream -> StreamIO.instream


setInstream

val setInstream : instream * StreamIO.instream -> unit


mkOutstream

val mkOutstream : StreamIO.outstream -> outstream


getOutstream

val getOutstream : outstream -> StreamIO.outstream


setOutstream

val setOutstream : outstream * StreamIO.outstream -> unit


bufferMode

val bufferMode


openIn

val openIn : string -> instream

Open files *


openOut

val openOut : string -> outstream


openAppend

val openAppend : string -> outstream


inputLine

val inputLine : instream -> string

Text stream specific operations *


outputSubstr

val outputSubstr : outstream * substring -> unit


openString

val openString : string -> instream


stdIn

val stdIn : instream


stdOut

val stdOut : outstream


stdErr

val stdErr : outstream


print

val print : string -> unit


scanStream

val scanStream
    : ((elemStreamIO.instreamStringCvt.reader ->
         ('a, StreamIO.instreamStringCvt.reader) ->
        instream -> 'a option

 


Overview  Index  Help 
Standard ML Basis Library

This document may be distributed freely over the internet as long as the copyright notice and license terms below are prominently displayed within every machine-readable copy.

Copyright © 2003 AT&T and Lucent Technologies. All rights reserved.

Permission is granted for internet users to make one paper copy for their own personal use. Further hardcopy reproduction is strictly prohibited. Permission to distribute the HTML document electronically on any medium other than the internet must be requested from the copyright holders by contacting the editors. Printed versions of the SML Basis Manual are available from Cambridge University Press. To order, please visit www.cup.org (North America) or www.cup.cam.ac.uk (outside North America).