Module Interface XML:UnicodeBuffer

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

# XML:UnicodeBuffer

### Import List

        IO
        Msg
        XML:UnicodeCodec

Class List
Input |
Output |

Class Summary: Input [Detail]
      +--XML:UnicodeBuffer.Input
Field Summary
autoDetectedCodec-: BOOLEAN
chars-: CharArray Character data from input channel.
codec-: Codec
codecFactory-: Factory
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 Input.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
InitInput(Input, BOOLEAN, ByteChannel, Factory, MsgList)
NewInput(ByteChannel, Factory, MsgList): Input Create new input buffer for reader reader and try to read the first block of data from it.
Method Summary
Close() Closes the channel associated with buffer in.
NextBlock(): BOOLEAN Tries to read additional data from in's channel.
SetCodec(Factory, BOOLEAN)

Class Summary: Output [Detail]
      +--XML:UnicodeBuffer.Output
Field Summary
codec-: Codec Any encoding errors are signalled by incrementing Codec.Codec.invalidChars.
codecFactory-: Factory
error-: Error
writer-: ByteChannel
Constructor Summary
InitOutput(Output, BOOLEAN, ByteChannel, Factory, BOOLEAN)
NewOutput(ByteChannel, Factory, BOOLEAN): Output Creates new output buffer for writer writer.
Method Summary
Flush() Flushes the contents of the output buffer to the channel.
Write16(ARRAY OF Char)
Write16I(ARRAY OF Char, CharPos, CharPos)
Write8(ARRAY OF CHAR)
Write8I(ARRAY OF CHAR, CharPos, CharPos)

Type Summary
Char = LONGCHAR Character type used to represent the Unicode 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 end of the Unicode buffer.
markerEOD This character value marks the end of the document.
markerError This character is inserted into the processor output for characters that are not valid in XML.
sizeOfInputBuffer

Class Detail: Input

Field Detail

### autoDetectedCodec

    FIELD autoDetectedCodec-: BOOLEAN

### chars

    FIELD chars-: CharArray

> Character data from input channel.

### codec

    FIELD codec-: Codec

### codecFactory

    FIELD codecFactory-: Factory

### 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 Input.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

### InitInput

    PROCEDURE InitInput(input: Input;
                        new: BOOLEAN;
                        reader: ByteChannel;
                        codecFactory: Factory;
                        errList: MsgList)
      RAISES Error;

### NewInput

    PROCEDURE NewInput(reader: ByteChannel;
                       codecFactory: Factory;
                       errList: MsgList): Input
      RAISES Error;

> Create new input buffer for reader reader and try to read the first block of data from it. Returns an initialized input buffer with up to sizeOfInputBuffer characters of input.

Method Detail

### Close

    PROCEDURE (in: Input) Close()
      RAISES Error;

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

### NextBlock

    PROCEDURE (in: Input) NextBlock(): BOOLEAN
      RAISES Error;

> Tries to read additional data from in's channel. If at least one character could be read, result is TRUE. FALSE means that not a single character 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 in's error list.

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

### SetCodec

    PROCEDURE (in: Input) SetCodec(cf: Factory;
                       autoDetect: BOOLEAN)
      RAISES Error;

Class Detail: Output

Field Detail

### codec

    FIELD codec-: Codec

> Any encoding errors are signalled by incrementing Codec.Codec.invalidChars.

### codecFactory

    FIELD codecFactory-: Factory

### error

    FIELD error-: Error

### writer

    FIELD writer-: ByteChannel

Constructor Detail

### InitOutput

    PROCEDURE InitOutput(out: Output;
                         new: BOOLEAN;
                         writer: ByteChannel;
                         codecFactory: Factory;
                         createBOM: BOOLEAN)

### NewOutput

    PROCEDURE NewOutput(writer: ByteChannel;
                        codecFactory: Factory;
                        createBOM: BOOLEAN): Output

> Creates new output buffer for writer writer.

Method Detail

### Flush

    PROCEDURE (out: Output) Flush()
      RAISES Error;

> Flushes the contents of the output buffer to the channel. Then, flush is called on the channel itself.

### Write16

    PROCEDURE (out: Output) Write16(str: ARRAY OF Char)

### Write16I

    PROCEDURE (out: Output) Write16I(str: ARRAY OF Char;
                       start: CharPos;
                       end: CharPos)

### Write8

    PROCEDURE (out: Output) Write8(str: ARRAY OF CHAR)

### Write8I

    PROCEDURE (out: Output) Write8I(str: ARRAY OF CHAR;
                      start: CharPos;
                      end: CharPos)

Type Detail

### Char

    TYPE Char = LONGCHAR

> Character type used to represent the Unicode 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 end of the Unicode buffer. It is the first non-input character after the last valid document character in the buffer. Because this character code is never produced by the Unicode decoders, testing against this character code gives a definitive answer. Calling Input.NextBlock will replace the character with a valid character from the input document, or with markerEOD.

### markerEOD

    CONST markerEOD

> This character value marks the end of the document. It is the first non-input character after the last valid document character in the buffer. This character is never emitted by the Unicode decoders, and it is never replaced with another value.

### markerError

    CONST markerError

> This character is inserted into the processor output for characters that are not valid in XML.

### sizeOfInputBuffer

    CONST sizeOfInputBuffer