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

# XML:InputBuffer

### Import List

        IO
        Msg

Class List
Buffer |

Class Summary: Buffer [Detail]
      +--XML:InputBuffer.Buffer
Field Summary
chars-: CharArray Character data from input channel.
discardable: CharPos The client can define here how many bytes that have been read into the buffer will not be inspected again later, and can therefore be discarded by Buffer.NextBlock.
endOfBuffer-: CharPos Number of valid characters in chars.
errList-: MsgList Error messages are appended to this list.
offsetFromPos0-: CharPos Offset of ``chars[0]`' from the beginning of the input text.
Constructor Summary
New(ByteChannel, MsgList): Buffer Creates a new input buffer for reader reader and tries to read the first block of data from it.
Method Summary
Close() Closes the channel associated with buffer b.
EndOfBuffer(CharPos): BOOLEAN Returns TRUE iff character position cpos refers to the position after the last valid byte in the buffer.
NextBlock(): BOOLEAN Tries to read additional data from b's channel.

Type Summary
Char = CHAR Character type used to represent the input data.
CharArray = POINTER TO ARRAY OF Char Character array of arbitrary length.
CharPos = LONGINT Character position for a channel.

Constant Summary
markerEOB This is the character value that is used to mark the first invalid character after the buffer.
sizeOfBuffer

Class Detail: Buffer

Field Detail

### chars

    FIELD chars-: CharArray

> Character data from input channel.

### discardable

    FIELD discardable: CharPos

> The client can define here how many bytes that have been read into the buffer will not be inspected again later, and can therefore be discarded by Buffer.NextBlock. Possible values for this field are [0..endOfBuffer].

### endOfBuffer

    FIELD endOfBuffer-: CharPos

> Number of valid characters in chars. All index values in the range [0..endOfBuffer-1] hold valid characters. The value of ``chars[endOfBuffer]`' is markerEOB.

### errList

    FIELD errList-: MsgList

> Error messages are appended to this list.

### offsetFromPos0

    FIELD offsetFromPos0-: CharPos

> Offset of ``chars[0]`' from the beginning of the input text.

Constructor Detail

### New

    PROCEDURE New(reader: ByteChannel;
                  errList: MsgList): Buffer
      RAISES Error;

> Creates a new input buffer for reader reader and tries to read the first block of data from it. Returns an initialized input buffer with up to sizeOfBuffer characters of input.

Method Detail

### Close

    PROCEDURE (b: Buffer) Close()
      RAISES Error;

> Closes the channel associated with buffer b. Afterwards, no further operations are permitted on b, except for reading the field Buffer.errList.

### EndOfBuffer

    PROCEDURE (b: Buffer) EndOfBuffer(cpos: CharPos): BOOLEAN

> Returns TRUE iff character position cpos refers to the position after the last valid byte in the buffer.

> Pre-condition: ``0`' <= cpos <= ``b.endOfBuffer`' and ``b. chars[cpos] = markerEOB`'

### NextBlock

    PROCEDURE (b: Buffer) NextBlock(): BOOLEAN
      RAISES Error;

> Tries to read additional data from b's channel. If at least one byte could be read, result is TRUE. FALSE means that not a single byte was added to the buffer, either because the end of the file was reached, or because of a read error. In the latter case, an message is added to b's error list.

> A call to this buffer may change the fields Buffer.chars, Buffer.offsetFromPos0, and Buffer.endOfBuffer. If part of the buffer is discarded, Buffer.discardable is set to zero.

Type Detail

### Char

    TYPE Char = CHAR

> Character type used to represent the input data.

### CharArray

    TYPE CharArray = POINTER TO ARRAY OF Char

> Character array of arbitrary length. This type is used for the character data of the input buffer.

### CharPos

    TYPE CharPos = LONGINT

> Character position for a channel. The very first byte that would be read from the channel has position 0.

Constant Detail

### markerEOB

    CONST markerEOB

> This is the character value that is used to mark the first invalid character after the buffer. Use Buffer.EndOfBuffer to determine, whether the character position is indeed the end of the buffer.

### sizeOfBuffer

    CONST sizeOfBuffer