# Section 8.10.3.7:
BIN_FILE_CURSOR

###### class BIN_FILE_CURSOR < $FILE_CURSORS{OCTET,BINSTR}

#### Formal Types

types
SAME = BIN_FILE_CURSOR ;

This class implements a model of a cursor (and associated buffer) into a binary file, inheriting all but one feature definition from the abstract class $FILE_CURSORS{OCTET,BINSTR}.

#### External specifications

The following routines are required to be implemented for this class in accordance with the specifications given in the abstract class $FILE_CURSORS of which $FILE_CURSORS{OCTET,BINSTR} is a sub-type :-

- position : CARD
- position(at : CARD) : SAME
- forward(cnt : CARD) : SAME
- skip(cnt : CARD) : SAME
- backward(cnt : CARD) : SAME
- size : CARD
- readable : BOOL
- writable : BOOL
- at_end : BOOL
- flush
- error : BOOL
- error_message : STR
- clear

The following 'output' routines are required to be implemented for this class in accordance with the specifications given in the abstract class $FILE_CURSORS{OCTET,BINSTR} :-

- plus(elem : OCTET)
- plus(elem : OCTET) : SAME
- plus(str : BINSTR)
- plus(str : BINSTR) : SAME

#### get

This is the single 'input' feature associated with the binary file cursor. It allows for arbitrary reading of octets from the current position, updating that position as reading continues.

get | (
| count : CARD
| ) : FBINSTR

##### Formal Signature

get(self : SAME, count : CARD) res : [FBINSTR]

##### Pre-condition

pre readable(self)
and (count > 0)

##### Post-condition

post (at_end
and res = nil)
or let idx = position(self) in
res = buffer(idx, ..., (idx + count))

This routine returns the next count items in the file in a binary string buffer. If there is insufficient data in the file then void is returned.

| Language Index |  | Library Index |  | Input/Output Index

Comments or enquiries should be made to Keith Hopper. Page last modified: Friday, 17 November 2000. |