maxon.BaseStreamInterface

Description

Interface is the base interface for all stream interfaces.
It contains the general functions to work with streams (e.g. error handling).

Inheritance diagram

Inheritance

Parent Class:

Children Classes:

Methods Signature

Close()

Closes the stream.

DisableBuffering()

The stream may disable buffering when this routine is called (if it supports it).

GetPosition()

Returns the current stream position.

GetStreamLength()

Returns the length of the stream/file.

Seek(position)

Sets the read/write position to this absolute position from the beginning of the stream.

SeekSupported()

Returns if the stream supports BaseStreamInterface.Seek().

close()

seek(offset[, whence])

seekable()

tell()

Methods Definition

BaseStreamInterface.Close()

Closes the stream.

BaseStreamInterface.DisableBuffering()
The stream may disable buffering when this routine is called (if it supports it).
This method is typically used when the buffering is done from the outside.
BaseStreamInterface.GetPosition()
Returns the current stream position.
This is the position where the next bytes will be read to or written from.
Returns

The current stream position.

Return type

int

BaseStreamInterface.GetStreamLength()
Returns the length of the stream/file.
Be aware that some streams cannot return the file size (e.g. http streams with gzip+chunked transfer encoding).

With this example code you can handle both cases correctly.
In most cases it’s better to not use maxon.BaseStreamInterface.GetStreamLength() and better use maxon.InputStreamInterface.ReadEOS() to read as much as available.
Return type

Returns the length in bytes.

Return type

int

BaseStreamInterface.Seek(position)

Sets the read/write position to this absolute position from the beginning of the stream.

Note

For maxon.InputStreamInterface: If you want to BaseStreamInterface.Seek() forward InputStreamInterface.Skip() is the preferred method to call from the performance perspective.

Parameters

position (int) – Position to jump to within the stream.

BaseStreamInterface.SeekSupported()

Returns if the stream supports BaseStreamInterface.Seek().

Note

Seeking in stream may effect performance because the caches will be flushed.

Returns

True if the output stream supports BaseStreamInterface.Seek().

Return type

bool

BaseStreamInterface.close()
BaseStreamInterface.seek(offset, whence=0)
BaseStreamInterface.seekable()
BaseStreamInterface.tell()