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

Ulm's Oberon Library:


MemStreams - streams representing a memory area


CONST read = 0; write = 1; rdwr = 2;
TYPE Mode = SHORTINT; (* read..rdwr *)

CONST beyondEndOfStream = 0; CONST posOutOfRange = 1; CONST invalidRange = 2; CONST errors = 3; TYPE ErrorCode = SHORTINT; (* illegalMode..beyondEndOfStream *) TYPE ErrorEvent = POINTER TO ErrorEventRec; TYPE ErrorEventRec = RECORD (Events.EventRec) errorcode: ErrorCode; END; VAR error: Events.EventType; VAR errormsg: ARRAY errors OF Events.Message;

PROCEDURE Open(VAR s: Streams.Stream; addr: Types.Address; length: Types.Size; mode: Mode);

PROCEDURE OpenU(VAR s: Streams.Stream; addr: Types.UntracedAddress; length: Types.Size; mode: Mode);


MemStreams allows to access a memory area by stream operations. Memory streams may be created for any allocated area of the virtual address space of the current process. Areas which are under the control of the garbage collector (see SysStorage) are to be passed to Open, otherwise OpenU is to be taken for untraced addresses.

MemStreams may be particularly useful for other stream implementations which keep their stream contents in-memory in a contiguous buffer as substream implementation (see SubStreams). MemStreams itself supports SubStreams as well.

It is in the responsibility of the stream creator to assure that the validity of the memory area is associated with the validity of the stream, i.e. if the memory area should become deallocated (no matter by which method), the stream should terminate (see Resources). Note that this link will be established automatically if MemStreams is used as a substream implementation (see SubStreams and Forwarders).

Besides the read and write operations, seek and tell, also trunc operations are permitted which allow to reduce the length of the stream.


Following error events may be generated by MemStreams:
Seek operations outside the valid range from 0 to length are not valid. Trunc operations are not permitted which are outside the valid range or which exclude the current position.
A write operation was attempted beyond the stream length. In this case, even a partial write will not be done, and 0 or FALSE will be returned instead.
This error will be returned on creation of substreams with a range which is not inside [0..length].

Note that passing an invalid mode to Open or OpenU will result in a runtime error.


filter objects
termination of objects and inter-object dependencies
general stream operations
general interface for substreams
base types including address types

Edited by: borchert, last change: 2004/02/19, revision: 1.2, converted to HTML: 2004/02/19

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