(*
    Title:      StringStream - Definitions
    LastEdit:	"Mon Sep 17 14:37:10 1984"
    Author: 	Mick Jordan
		Acorn Research Centre

    This module provides a stream interface to a string,
    in standard language form, i.e as a character array
    terminated by HIGH(array) or a 0C.
    Its primary function is to allow high-level IO packages,
    e.g. formatted I/O, to operate from/to a string data type.
    Low-level access (e.g. with Streams.Get) simply provides
    an alternative means of accessing the string.
*)

DEFINITION MODULE StringStream;

FROM SystemTypes IMPORT String;
FROM Streams IMPORT Stream;

EXPORT QUALIFIED CreateInOutChars, CreateInOutString;


PROCEDURE CreateInOutChars(VAR chars: ARRAY OF CHAR): Stream;
(*  
    Creates a bi-directional stream using the array 'chars'.
    Initial Gets and Puts start at index 0 of the array, but
    the position can be changed by Seek within the range
    0 <= index <= HIGH(s).  
    Get is constrained to the indices 0 <= index < String.LengthC(s), 
    and will set EndOfStream if this is exceeded, and return 0C.
    Put is constrained to to the same range as Seek.
    Access outside the allowed index range, will cause an
    array-bounds fault.
*)
PROCEDURE CreateInOutString(s: String; maxLength: CARDINAL): Stream;
(*  This procedure is similar to CreateInOutChars, except
    that the dynamically allocated string 's' is used.
    Get is constrained to lie within
    0 <= index < String.LengthS(s).
    Put and Seek are constrained to lie within the range
    0 <= index < maxLength.
    A maxLength of zero is taken to mean
    'maxlength := String.LengthS(s)'
*)
END StringStream .
