Oberon || Library || Module Index || Search Engine || Definition || Module

Ulm's Oberon Library:


StreamDisciplines - general-purpose disciplines for streams


TYPE LineTerminator = ARRAY 4 OF CHAR;
VAR badfieldsepset: Events.EventType;
PROCEDURE SetLineTerm(s: Streams.Stream; lineterm: LineTerminator);
PROCEDURE GetLineTerm(s: Streams.Stream; VAR lineterm: LineTerminator);
PROCEDURE GetWhiteSpace(s: Streams.Stream; VAR whitespace: Sets.CharSet);
PROCEDURE SetWhiteSpace(s: Streams.Stream; whitespace: Sets.CharSet);
PROCEDURE SetFieldSepSet(s: Streams.Stream; fieldsepset: Sets.CharSet);
PROCEDURE GetFieldSepSet(s: Streams.Stream; VAR fieldsepset: Sets.CharSet);
PROCEDURE SetFieldSep(s: Streams.Stream; fieldsep: CHAR);
PROCEDURE GetFieldSep(s: Streams.Stream; VAR fieldsep: CHAR);
PROCEDURE SetIndentationWidth(s: Streams.Stream; indentwidth: INTEGER);
PROCEDURE GetIndentationWidth(s: Streams.Stream; VAR indentwidth: INTEGER);
PROCEDURE IncrIndentationWidth(s: Streams.Stream; incr: INTEGER);


StreamDisciplines exports some general characteristics of streams which are used by scanning and printing modules like Read or Write.

Line terminators are strings up to four characters which must be pairwise different. 0X as line terminator is to be encoded as empty line terminator (i.e. first element equals 0X). Default is ASCII.EOL and may be modified by SetLineTerm. The line terminator of StreamDisciplines is independent of the line terminator of Streams which is used for line buffered streams.

White space is the set of characters which is to be skipped on read operations (e.g. Read.Int). By default it contains ASCII.tab, ASCII.nl, ASCII.np, and ASCII.sp. SetWhiteSpace and GetWhiteSpace allow to access the white space character set.

Lines could be viewed as records which consists of fields which are separated by field separators. The default field separators are ASCII.tab, ASCII.nl, ASCII.np and ASCII.sp. SetFieldSetSet and GetFieldSepSet allow to set and retrieve the set of separators.

GetFieldSep returns one of the field separators which is intended to be the output field separator. SetFieldSep adds fieldsep to the set of field separators and selects fieldsep to be the one returned by GetFieldSep. GetFieldSep returns the field separator with the lowest ordinal value if no separator has been selected by SetFieldSep.

The set of separators should be interpreted as set of skipping characters between fields if the set of whitespace characters is a subset of the set of field separators. In all other cases each field separator works as delimiter between two fields, i.e. empty fields are possible.

Field extracting procedures are expected to strip off surrounding white space. The set of white space charactes should be set to the empty set if this behaviour is not preferred.

Some streams maintain an actual non-negative indentation width. In this case each line should be preceded by a call of Write.Indent. The indentation width may be set, retrieved and modified by SetIndentationWidth, GetIndentationWidth, and IncrIndentationWidth. StreamDisciplines silently ignores calls which try to set the indentation width to a negative value.


SetFieldSepSet raises badfieldsepset on empty sets with priority Priorities.liberrors.


shortnames for ASCII characters
attachments of additional data structures to objects
event and error handling
formatted input
handling of larger sets
general stream operations
formatted output

Edited by: borchert, last change: 2003/07/10, revision: 1.7, converted to HTML: 2003/07/10

Oberon || Library || Module Index || Search Engine || Definition || Module