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
__init__ |
Creates a dummy input stream. |
CanRead |
Returns True if some data is available in the stream right now, so that calling Read wouldn’t block. |
Eof |
Returns True after an attempt has been made to read past the end of the stream. |
GetC |
Returns the first character in the input queue and removes it, blocking until it appears if necessary. |
LastRead |
Returns the last number of bytes read. |
Peek |
Returns the first character in the input queue without removing it. |
Read |
Reads the specified amount of bytes and stores the data in buffer. |
ReadAll |
Reads exactly the specified number of bytes into the buffer. |
SeekI |
Changes the stream current position. |
TellI |
Returns the current stream position or InvalidOffset if it’s not available (e.g. |
Ungetch |
This function is only useful in read mode. |
close |
|
eof |
|
flush |
|
read |
|
readline |
|
readlines |
|
seek |
|
tell |
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.
Return type: | bool |
---|
Eof
(self)¶Returns True
after an attempt has been made to read past the end of the stream.
Return type: | 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
.
Return type: | int |
---|
LastRead
(self)¶Returns the last number of bytes read.
Return type: | int |
---|
Peek
(self)¶Returns the first character in the input queue without removing it.
Return type: | 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).
Parameters: |
|
---|---|
Return type: | |
Returns: | 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.
Parameters: | stream_out (wx.OutputStream) – |
---|---|
Return type: | wx.InputStream |
Returns: | 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.
Parameters: |
|
---|---|
Return type: | 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).
Parameters: |
|
---|---|
Return type: | wx.FileOffset |
Returns: | The new stream position or |
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).
Return type: | 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).
Parameters: |
|
---|---|
Return type: | int |
Returns: | 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.
Parameters: | c (int) – |
---|---|
Return type: | bool |
close
(self)¶eof
(self)¶Return type: | bool |
---|
flush
(self)¶read
(self, *args, **kw)¶read (self)
Return type: | PyObject |
---|
read (self, size)
Return type: | PyObject |
---|
readline
(self, *args, **kw)¶readline (self)
Return type: | PyObject |
---|
readline (self, size)
Return type: | PyObject |
---|
readlines
(self, *args, **kw)¶readlines (self)
Return type: | PyObject |
---|
readlines (self, sizehint)
Return type: | PyObject |
---|
seek
(self, offset, whence=0)¶tell
(self)¶Return type: | wx.FileOffset |
---|