Table Of Contents

Previous topic

OutCode

Next topic

Overlay

This Page

phoenix_title OutputStream

OutputStream is an abstract base class which may not be used directly.

It is the base class of all streams which provide a Write function, i.e. which can be used to output data (e.g. to a file, to a socket, etc).

If you want to create your own output stream, you’ll need to derive from this class and implement the protected OnSysWrite function only.


class_hierarchy Inheritance Diagram

Inheritance diagram for class OutputStream

Inheritance diagram of OutputStream


sub_classes Known Subclasses

CountingOutputStream, FFileOutputStream, FileOutputStream, FilterOutputStream, MemoryOutputStream, SocketOutputStream, StringOutputStream, TempFileOutputStream


method_summary Methods Summary

__init__ Creates a dummy OutputStream object.
Close Closes the stream, returning False if an error occurs.
LastWrite Returns the number of bytes written during the last Write .
PutC Puts the specified character in the output queue and increments the stream position.
SeekO Changes the stream current position.
TellO Returns the current stream position.
Write Writes up to the specified amount of bytes using the data of buffer.
close  
eof  
flush  
seek  
tell  
write  

api Class API



class OutputStream(StreamBase)

OutputStream is an abstract base class which may not be used directly.

Possible constructors:

OutputStream()

Methods



__init__(self)

Creates a dummy OutputStream object.



Close(self)

Closes the stream, returning False if an error occurs.

The stream is closed implicitly in the destructor if Close is not called explicitly.

If this stream wraps another stream or some other resource such as a file, then the underlying resource is closed too if it is owned by this stream, or left open otherwise.

Return type:bool


LastWrite(self)

Returns the number of bytes written during the last Write .

It may return 0 even if there is no error on the stream if it is only temporarily impossible to write to it.

Return type:int


PutC(self, c)

Puts the specified character in the output queue and increments the stream position.

Parameters:c (int) –


SeekO(self, pos, mode=FromStart)

Changes the stream current position.

Parameters:
  • pos (int) – Offset to seek to.
  • mode (SeekMode) – One of FromStart, FromEnd, FromCurrent.
Return type:

int

Returns:

The new stream position or InvalidOffset on error.



TellO(self)

Returns the current stream position.

Return type:int


Write(self, *args, **kw)

overload Overloaded Implementations:



Write (self, buffer, size)

Writes up to the specified amount of bytes using the data of buffer.

Note that not all data can always be written so you must check the number of bytes really written to the stream using LastWrite when this function returns.

In some cases (for example a write end of a pipe which is currently full) it is even possible that there is no errors and zero bytes have been written. This function returns a reference on the current object, so the user can test any states of the stream right away.

Parameters:
  • buffer
  • size (int) –
Return type:

OutputStream



Write (self, stream_in)

Reads data from the specified input stream and stores them in the current stream.

The data is read until an error is raised by one of the two streams.

Parameters:stream_in (InputStream) –
Return type: OutputStream





close(self)


eof(self)
Return type:bool


flush(self)


seek(self, offset, whence=0)


tell(self)
Return type:int


write(self, data)