home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / lib / Byte.sig < prev    next >
Encoding:
Text File  |  1997-08-18  |  2.1 KB  |  50 lines  |  [TEXT/Moml]

  1. (* Byte -- SML Basis Library *)
  2.  
  3. val byteToChar      : Word8.word -> Char.char
  4. val charToByte      : Char.char -> Word8.word
  5. val bytesToString   : Word8Vector.vector -> String.string
  6. val stringToBytes   : String.string -> Word8Vector.vector
  7.  
  8. val unpackStringVec : Word8Vector.vector * int * int option -> string
  9. val unpackString    : Word8Array.array * int * int option -> string
  10. val packString      : Substring.substring * Word8Array.array * int -> unit
  11.  
  12. (* Conversions between bytes and characters, and between byte vectors 
  13.    and strings (character vectors).  
  14.  
  15.    [byteToChar w] is the character corresponding to the byte w.
  16.  
  17.    [charToByte c] is the byte corresponding to character c.
  18.  
  19.    [bytesToString v] is the string whose character codes are the bytes 
  20.    from vector v.
  21.  
  22.    [stringToBytes s] is the byte vector of character codes of the string s.
  23.  
  24.    In Moscow ML, all the above operations take constant time.  That
  25.    is, no copying is done.
  26.  
  27.    [unpackStringVec (v, i, NONE)] is the string whose character codes are
  28.    the bytes of v[i..length v-1].  Raises Subscript if i<0 or i>length v.
  29.    Equivalent to bytesToString(Word8Vector.extract (v, i, NONE)).
  30.    
  31.    [unpackStringV (v, i, SOME n)] is the string whose character codes are
  32.    the bytes of v[i..i+n-1].  Raises Subscript if i<0 or n<0 or i+n>length v.
  33.    Equivalent to bytesToString(Word8Vector.extract (v, i, SOME n)).
  34.  
  35.    [unpackString (a, i, NONE)] is the string whose character codes are
  36.    the bytes of a[i..length a-1].  Raises Subscript if i<0 or i>length a.
  37.    Equivalent to bytesToString(Word8Array.extract (v, i, NONE)).
  38.    
  39.    [unpackString (a, i, SOME n)] is the string whose character codes are
  40.    the bytes of a[i..i+n-1].  Raises Subscript if i<0 or n<0 or i+n>length a.
  41.    Equivalent to bytesToString(Word8Array.extract (a, i, SOME n)).
  42.  
  43.    [packString (ss, a, i)] copies the character codes of substring ss into
  44.    the subarray a[i..i+n-1] where n = Substring.size ss.  Raises Subscript 
  45.    if i<0 or i+n > length a.
  46.    Equivalent to Word8Array.copyVec{src=s, si=si, len=SOME n, dst=a, di=i} 
  47.    when (s, si, n) = Substring.base ss.
  48.  
  49. *)
  50.