ATSLIB/contrib/libats-hwxi/cstream
This package implements streams of characters.
Synopsis
vtypedef
cstream(tk:tkind) = cstream_vtype(tk)
vtypedef cstream = [tk:tkind] cstream(tk)
Synopsis
absvtype
cstream_vtype(tkind) = ptr
Synopsis
fun{}
cstream_get_char (!cstream): int
Description
If the current position in the character stream represented by a given
cstream-value is not at the end, then this function returns the character
at the position while advancing the position by 1. Otherwise, the function
returns -1.
Synopsis
fun{tk:tk}
cstream_getv_char{n:nat}
(!cstream(tk), &bytes(n) >> _, n: int(n)): natLte(n)
Description
A reference implementation of this function calls
cstream_get_char repeatedly until either the number of calls
reaches the value of its third argument or -1 is returned, and it stores the
characters returned by calls to cstream_get_char in its second
(call-by-reference) argument. The return value of
cstream_getv_char indicates how many characters are actually
stored.
Synopsis
fun{}
cstream_get_charlst (!cstream, n: int): List0_vt(char)
Description
This function calls cstream_get_char repeatedly until either
the number of calls reaches the value of its second argument or -1 is
returned, and it returns a list consisting of all the characters returned
by calls to cstream_get_char. Note that this function returns
a list consisting of all the characters in the character stream associated
with its first argument if its second argument is a negative integer.
Synopsis
fun cstream_make_fun (() -> int): cstream(TKfun)
Synopsis
fun cstream_make_cloref (() -<cloref1> int): cstream(TKcloref)
Synopsis
overload cstream_get_range with cstream_string_get_range
overload cstream_get_range with cstream_strptr_get_range
Synopsis
fun
cstream_string_get_range
{i,j:nat | i <= j} (!cstream(TKstring), int i, int j): Strptr1
Synopsis
fun
cstream_strptr_get_range
{i,j:nat | i <= j} (!cstream(TKstrptr), int i, int j): Strptr1
Synopsis
fun cstream_make_string (string): cstream(TKstring)
Synopsis
fun cstream_make_strptr (Strptr1): cstream(TKstrptr)
Synopsis
fun
cstream_make_fileref (FILEref): cstream(TKfileref)
Synopsis
fun
cstream_make_fileptr
{l:agz}{m:fmode}
(file_mode_lte (m, r) | FILEptr(l, m)): cstream(TKfileptr)