wx.InputStream is an abstract base class which may not be used directly.
It is the base class of all streams which provide a Read
function, i.e. which can be used to read data from a source (e.g. a file, a socket, etc).
If you want to create your own input stream, you’ll need to derive from this class and implement the protected OnSysRead
function only.
FFileInputStream , FileInputStream , FilterInputStream , MemoryInputStream , SocketInputStream , StringInputStream
Creates a dummy input stream. |
|
Returns |
|
Returns |
|
Returns the first character in the input queue and removes it, blocking until it appears if necessary. |
|
Returns the last number of bytes read. |
|
Returns the first character in the input queue without removing it. |
|
Reads the specified amount of bytes and stores the data in buffer. |
|
Reads exactly the specified number of bytes into the buffer. |
|
Changes the stream current position. |
|
Returns the current stream position or |
|
This function is only useful in read mode. |
|
See |
wx.
InputStream
(StreamBase)¶Possible constructors:
InputStream()
InputStream is an abstract base class which may not be used directly.
__init__
(self)¶Creates a dummy input stream.
CanRead
(self)¶Returns True
if some data is available in the stream right now, so that calling Read
wouldn’t block.
bool
Eof
(self)¶Returns True
after an attempt has been made to read past the end of the stream.
bool
GetC
(self)¶Returns the first character in the input queue and removes it, blocking until it appears if necessary.
On success returns a value between 0 - 255; on end of file returns EOF
.
int
LastRead
(self)¶Returns the last number of bytes read.
int
Peek
(self)¶Returns the first character in the input queue without removing it.
int
Read
(self, *args, **kw)¶Read (self, buffer, size)
Reads the specified amount of bytes and stores the data in buffer.
To check if the call was successful you must use LastRead
to check if this call did actually read size bytes (if it didn’t, GetLastError
should return a meaningful value).
buffer –
size (int) –
This function returns a reference on the current object, so the user can test any states of the stream right away.
Warning
The buffer absolutely needs to have at least the specified size.
Read (self, stream_out)
Reads data from the input queue and stores it in the specified output stream.
The data is read until an error is raised by one of the two streams.
stream_out (wx.OutputStream) –
This function returns a reference on the current object, so the user can test any states of the stream right away.
ReadAll
(self, buffer, size)¶Reads exactly the specified number of bytes into the buffer.
Returns True
only if the entire amount of data was read, otherwise False
is returned and the number of bytes really read can be retrieved using LastRead
, as with Read
.
This method uses repeated calls to Read
(which may return after reading less than the requested number of bytes) if necessary.
buffer –
size (int) –
bool
New in version 2.9.5.
Warning
The buffer absolutely needs to have at least the specified size.
SeekI
(self, pos, mode=FromStart)¶Changes the stream current position.
This operation in general is possible only for seekable streams (see wx.StreamBase.IsSeekable
); non-seekable streams support only seeking positive amounts in mode FromCurrent
(this is implemented by reading data and simply discarding it).
pos (wx.FileOffset) – Offset to seek to.
mode (SeekMode) – One of FromStart, FromEnd, FromCurrent.
wx.FileOffset
The new stream position or InvalidOffset
on error.
TellI
(self)¶Returns the current stream position or InvalidOffset
if it’s not available (e.g.
socket streams do not have a size nor a current stream position).
wx.FileOffset
Ungetch
(self, *args, **kw)¶Ungetch (self, buffer, size)
This function is only useful in read mode.
It is the manager of the “Write-Back” buffer. This buffer acts like a temporary buffer where data which has to be read during the next read IO
call are put. This is useful when you get a big block of data which you didn’t want to read: you can replace them at the top of the input queue by this way.
Be very careful about this call in connection with calling SeekI
on the same stream. Any call to SeekI
will invalidate any previous call to this method (otherwise you could SeekI
to one position, “unread” a few bytes there, SeekI
to another position and data would be either lost or corrupted).
buffer –
size (int) –
int
Returns the amount of bytes saved in the Write-Back buffer.
Ungetch (self, c)
This function acts like the previous one except that it takes only one character: it is sometimes shorter to use than the generic function.
c (int) –
bool
close
(self)¶eof
(self)¶bool
flush
(self)¶read
(self, *args, **kw)¶read (self)
PyObject
read (self, size)
PyObject
readline
(self, *args, **kw)¶readline (self)
PyObject
readline (self, size)
PyObject
readlines
(self, *args, **kw)¶readlines (self)
PyObject
readlines (self, sizehint)
PyObject
seek
(self, offset, whence=0)¶tell
(self)¶wx.FileOffset