SUMMARY: MODULE | CLASS | TYPE | PROC | VAR | CONST | DETAIL: TYPE | PROC | VAR | CONST

# IO:Memory

### Import List

        IO

Class List
Channel |

Class Summary: Channel [Detail]
      +---IO.Channel
           |
           +---IO.ByteChannel
                |
                +--IO:Memory.Channel
Field Summary
data-: Data
length-: LONGINT
Inherited Fields
From IO.Channel: readyOps
Constructor Summary
Open(): Channel
Method Summary
FileDescriptor(): FileDescriptor Return the file descriptor of the channel.
Fingerprint(VAR ARRAY OF BYTE, LONGINT, LONGINT) Generates fingerprint value over the data of ch, over the byte range ``[start..end[`'.
INIT()
Read(VAR ARRAY OF BYTE, LONGINT, LONGINT): LONGINT Read a sequence of bytes from the channel into the buffer.
SetBlocking(BOOLEAN) Change the channel's blocking mode.
SetPos(LONGINT)
Truncate(LONGINT)
Write(ARRAY OF BYTE, LONGINT, LONGINT): LONGINT Write a sequence of bytes to this channel from the buffer.
Inherited Methods
From IO.Channel: Close, CloseAndRegister, FileDescriptor, KeyForSelector, RegisterWithSelector, SetBlocking, SetPos From IO.ByteChannel: Flush, INIT, Read, TransferTo, Write

Type Summary
[Data] = POINTER TO ARRAY OF CHAR

Class Detail: Channel

Field Detail

### data

    FIELD data-: Data

### length

    FIELD length-: LONGINT

Constructor Detail

### Open

    PROCEDURE Open(): Channel

Method Detail

### FileDescriptor

    PROCEDURE (ch: Channel) FileDescriptor(): FileDescriptor

> Return the file descriptor of the channel. This is the integer number that is used to identify the channel on the level of the C library. If the channel is not associated with a file descriptor, result is ``-1`'.

> [Description inherited from FileDescriptor]

> Redefines: FileDescriptor, FileDescriptor

### Fingerprint

    PROCEDURE (ch: Channel) Fingerprint(VAR key: ARRAY OF BYTE;
                          start: LONGINT;
                          end: LONGINT)

> Generates fingerprint value over the data of ch, over the byte range ``[start..end[`'. The argument passed to key must be a LONGINT variable. To fingerprint the whole file, use a start value of ``0`' and an end of ``ch.file.length`'.

> See Structured Programming(1993) 14: 136-147.

> Pre-condition: ``LEN(key) = fpSize`'

### INIT

    PROCEDURE (ch: Channel) INIT()

> Redefines: INIT, INIT

### Read

    PROCEDURE (ch: Channel) Read(VAR buffer: ARRAY OF BYTE;
                   start: LONGINT;
                   length: LONGINT): LONGINT

> Read a sequence of bytes from the channel into the buffer.

> An attempt is made to read up to length bytes from the channel. The bytes are written to buffer, starting at position start. Result is the number of bytes actually read, or ``-1`' if the read position is at the end of the channel, and length is not zero.

> A read operation might not read length bytes, and in fact it might not read any bytes at all. Whether or not it does so depends upon the nature and state of the channel. A socket channel in non-blocking mode, for example, cannot read any more bytes than are immediately available from the socket's input buffer; similarly, a file channel cannot read any more bytes than remain in the file. It is guaranteed, however, that if a channel is in blocking mode and there is at least one byte remaining in the buffer then this method will block until at least one byte is read.

> Pre-condition: ``0 <= start <= start+length <= LEN(buffer)`' and ``length >= 0`'.

> [Description inherited from Read]

> Redefines: Read

### SetBlocking

    PROCEDURE (ch: Channel) SetBlocking(block: BOOLEAN)

> Change the channel's blocking mode. Channels typically default to blocking mode on creation.

> If a channel does not support non-blocking operation, then any call to this method is ignored. Rider implementations from IO:BinaryRider and IO:TextRider only work with blocking channels.

> [Description inherited from SetBlocking]

> Redefines: SetBlocking, SetBlocking

### SetPos

    PROCEDURE (ch: Channel) SetPos(pos: LONGINT)

> Pre-condition: ``0 <= pos <= ch.length`'

> Redefines: SetPos, SetPos

### Truncate

    PROCEDURE (ch: Channel) Truncate(newLength: LONGINT)

> Pre-condition: ``0 <= newLength <= ch.length`'

### Write

    PROCEDURE (ch: Channel) Write(buffer: ARRAY OF BYTE;
                    start: LONGINT;
                    length: LONGINT): LONGINT

> Write a sequence of bytes to this channel from the buffer.

> An attempt is made to write up to length bytes to the channel. The bytes are taken from buffer, beginning at position start.

> A write operation can return after writing less than length bytes. That is, some types of channels, depending upon their state, may write only some of the bytes or possibly none at all. A socket channel in non-blocking mode, for example, cannot write any more bytes than are free in the socket's output buffer. Result is the number of bytes actually written.

> Pre-condition: ``0 <= start <= start+length <= LEN(buffer)`' and ``length >= 0`'.

> [Description inherited from Write]

> Redefines: Write

Type Detail

### Data

    TYPE [Data] = POINTER TO ARRAY OF CHAR