19 Streams

Streams are sources or targets of data, generally accessed in a sequential way. CEF uses them as a means of passing data of arbitrary length between components. The basic stream component is TCOM_Stream. TCEF_Stream is a descendant class. TCEF_Stream should be used in all cases where a TCOM_Stream is required, however TCOM_Stream is assumed for backwards compatibility. The assembler can be told if it is using a TCEF_Stream instead of a TCOM_Stream. In most other cases, it doesn't matter which type is used.

TCOM_Stream contains the following methods:

TUEC Initialize

Initialize the object. Returns result of initialization attempt.

TUEC Terminate

Terminate the use of the object. Returns result of termination. This generally should not be used - instead, use the Detach method.

void Attach

Increments the reference count for the object.

void Detach

Decrements the reference count for the object. When count reaches 0, the object is destroyed.

integer Interface_Version

Version of the COM interface for this object.

integer Facility_ID

Facility ID for the facility represented by this object. Returns -1 if no facility assigned.

integer Facility_Version

Facility version. Result only has meaning if Facility_ID doesn't return -1.

TDebug_Interface* Debugger

Returns a debugging interface for the object. Returns nil if not supported.

void* Extension

Returns a pointer to an object with extended common COM methods for object. Always returns nil for now.

boolean At_End

Returns True if there is no more data in the stream to read.

void Last_Error( TUEC &UEC )

Returns last error code, and resets the error code.

void Read( void &Buffer, integer &Size )

Reads the specified number of bytes from the stream. Size is modified to be the actual bytes transferred.

void Read_Line( void &Buffer. integer &Size )

Reads one line of input, up to the size of the buffer. The line is assumed to end at an ASCII 13 code. The ASCII 13 code is not included in the returned data. Size is modified to be the actual bytes transferred.

void Seek( integer Position )

Position to specified byte within streamed data.

integer Size

Returns size of stream data, in bytes. -1 indicate that the size is unknown or larger than 2^31.

void Write( void &Buffer, integer Size )

Writes the specified buffer, of the specified size in bytes, to the stream.

void Write_Line( string Buffer )

Writes the specified null-terminated text to the stream. An ASCII code 13 is appended to the text on output.

TCEF_Stream provides a stream with a means of changing the target of output for assembly. Streams passed to the master assembler by the main CEF application are connected to main memory so that assembled code is written there. However, some CPUs direct assembled code to other components, and assembler code can switch between CPUs (in applicable cases). CEF_Streams allow the assembler to appropriately redirect the assembled code. A TCEF_Stream that ignores Set_Component (and return null for Get_Component) operates as a TCOM_Stream and directs streamed data to whatever target was defined by the creator of the class. TCEF_Stream descends from TCOM_Stream and adds the following methods:

TComponent* Get_Component

void Set_Component( TComponent* Value )