Stream Implementation
GetProc:
TYPE ~
UNSAFE
PROC [clientData:
REF, offset:
CARD, block:
IO.UnsafeBlock]
RETURNS [nBytesRead:
INT, atEnd:
BOOL];
Read from specified offset in underlying data object into memory specified by block.
May raise errors (e.g. IO.Error) itself, or may return a negative number for interpretation by a GetErrorProc.
PutProc:
TYPE ~
PROC [clientData:
REF, offset:
CARD, block:
IO.UnsafeBlock]
RETURNS [nBytesWritten:
INT];
Write to specified offset in undeflying data object from memory specified by block.
Return number of bytes actually written (which should be equal to the number of bytes specified in block).
May raise errors (e.g. IO.Error) itself, or may return a negative number for interpretation by a GetErrorProc.
CloseProc:
TYPE ~
PROC [clientData:
REF, abort:
BOOL]
RETURNS [ok:
INT];
Called by IO.Close to release underlying data object.
Return 0.
May raise IO.Error, or may return a negative number for interpretation by a GetErrorProc.
GetErrorProc:
TYPE ~
PROC [clientData:
REF, code:
INT]
RETURNS [ec:
IO.ErrorCode, msg: Rope.
ROPE];
Translate client error code to human-and-Cedar-comprehensible stuff.
PIS:
PROC [clientData:
REF, get: GetProc, close: CloseProc ¬
NIL, getError: GetErrorProc ¬
NIL, oldStream:
IO.
STREAM ¬
NIL, canSetIndex:
BOOL ¬
TRUE]
RETURNS [in:
IO.
STREAM];
Create an input stream.
If oldStream is non-NIL, it is reused instead of allocating new stream data structures.
If canSetIndex is TRUE, IO.SetIndex is allowed.
POS:
PROC [clientData:
REF, put: PutProc, close: CloseProc ¬
NIL, getError: GetErrorProc ¬
NIL, oldStream:
IO.
STREAM ¬
NIL, canSetIndex:
BOOL ¬
TRUE]
RETURNS [out:
IO.
STREAM];
Create an output stream.
If oldStream is non-NIL, it is reused instead of allocating new stream data structures.
If canSetIndex is TRUE, IO.SetIndex is allowed.
PIOS:
PROC [clientData:
REF, get: GetProc, put: PutProc, close: CloseProc ¬
NIL, getError: GetErrorProc ¬
NIL, oldStream:
IO.
STREAM ¬
NIL, canSetIndex:
BOOL ¬
TRUE, shared:
BOOL ¬
TRUE]
RETURNS [inOut:
IO.
STREAM];
Create an input/output stream.
If oldStream is non-NIL, it is reused instead of allocating new stream data structures.
If canSetIndex is TRUE, IO.SetIndex is allowed.
If shared is TRUE, IO.read operations will always see the result of previous (flushed) IO.write operations on the same stream.
GetClientData:
PROC [self:
IO.
STREAM]
RETURNS [clientData:
REF];
Return clientData that was supplied to PIS/POS/PIOS call.
GetErrorDetails:
PROC [self:
IO.
STREAM]
RETURNS [ec:
IO.ErrorCode, code:
INT, msg: Rope.
ROPE];
Return details of most recent error on stream.
}.