.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2020 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc



.. _wx.InputStream:

==========================================================================================================================================
|phoenix_title|  **wx.InputStream**
==========================================================================================================================================

:ref:`wx.InputStream`  is an abstract base class which may not be used directly.          

It is the base class of all streams which provide a :meth:`~wx.InputStream.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 :meth:`~wx.InputStream.OnSysRead`  function only. 







|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>InputStream</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.InputStream_inheritance.png" alt="Inheritance diagram of InputStream" usemap="#dummy" class="inheritance"/></center>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.InputStream.html" title="wx.InputStream" alt="" coords="5,83,131,112"/> <area shape="rect" id="node2" href="wx.StreamBase.html" title="wx.StreamBase" alt="" coords="6,5,130,35"/> </map> 
   </p>
   </div>

|


|sub_classes| Known Subclasses
==============================

:ref:`FFileInputStream`, :ref:`FileInputStream`, :ref:`FilterInputStream`, :ref:`MemoryInputStream`, :ref:`SocketInputStream`, :ref:`StringInputStream`

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.InputStream.__init__`                                                 Creates a dummy input stream.
:meth:`~wx.InputStream.CanRead`                                                  Returns ``True`` if some data is available in the stream right now, so that calling :meth:`~InputStream.Read`   wouldn't block.
:meth:`~wx.InputStream.Eof`                                                      Returns ``True`` after an attempt has been made to read past the end of the stream.
:meth:`~wx.InputStream.GetC`                                                     Returns the first character in the input queue and removes it, blocking until it appears if necessary.
:meth:`~wx.InputStream.LastRead`                                                 Returns the last number of bytes read.
:meth:`~wx.InputStream.Peek`                                                     Returns the first character in the input queue without removing it.
:meth:`~wx.InputStream.Read`                                                     Reads the specified amount of bytes and stores the data in buffer.
:meth:`~wx.InputStream.ReadAll`                                                  Reads exactly the specified number of bytes into the buffer.
:meth:`~wx.InputStream.SeekI`                                                    Changes the stream current position.
:meth:`~wx.InputStream.TellI`                                                    Returns the current stream position or :meth:`~InputStream.InvalidOffset`   if it's not available (e.g.
:meth:`~wx.InputStream.Ungetch`                                                  This function is only useful in read mode.
:meth:`~wx.InputStream.close`                                                    
:meth:`~wx.InputStream.eof`                                                      
:meth:`~wx.InputStream.flush`                                                    
:meth:`~wx.InputStream.read`                                                     
:meth:`~wx.InputStream.readline`                                                 
:meth:`~wx.InputStream.readlines`                                                
:meth:`~wx.InputStream.seek`                                                     
:meth:`~wx.InputStream.tell`                                                     
================================================================================ ================================================================================


|


|property_summary| Properties Summary
=====================================

================================================================================ ================================================================================
:attr:`~wx.InputStream.C`                                                        See :meth:`~wx.InputStream.GetC`
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: wx.InputStream(StreamBase)

   **Possible constructors**::

       InputStream()
       
   
   InputStream is an abstract base class which may not be used
   directly.



   .. method:: __init__(self)

      Creates a dummy input stream.                   





   .. method:: CanRead(self)

      Returns ``True`` if some data is available in the stream right now, so that calling :meth:`Read`   wouldn't block.                  

      :rtype: `bool`








   .. method:: Eof(self)

      Returns ``True`` after an attempt has been made to read past the end of the stream.                  

      :rtype: `bool`








   .. method:: 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`` .                   

      :rtype: `int`








   .. method:: LastRead(self)

      Returns the last number of bytes read.                  

      :rtype: `int`








   .. method:: Peek(self)

      Returns the first character in the input queue without removing it.                  

      :rtype: `int`








   .. method:: Read(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **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 :meth:`LastRead`   to check if this call did actually read `size`  bytes (if it didn't, :meth:`GetLastError`   should return a meaningful value). 
      
                      
      
      
      :param `buffer`: 
      :param `size`: 
      :type `size`: int
      
      
      
      
      :rtype: :ref:`wx.InputStream`
      
      
      
      
      
      
      
      :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.  
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **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. 
      
                      
      
      
      :param `stream_out`: 
      :type `stream_out`: wx.OutputStream
      
      
      
      
      :rtype: :ref:`wx.InputStream`
      
      
      
      
      
      
      
      :returns: 
      
         This function returns a reference on the current object, so the user can test any states of the stream right away.   
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: 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 :meth:`LastRead` , as with :meth:`Read` . 

      This method uses repeated calls to :meth:`Read`   (which may return after reading less than the requested number of bytes) if necessary. 

                


      :param `buffer`: 
      :param `size`: 
      :type `size`: int




      :rtype: `bool`







      .. versionadded:: 2.9.5 
     







      .. warning:: The buffer absolutely needs to have at least the specified size.  








   .. method:: SeekI(self, pos, mode=FromStart)

      Changes the stream current position.                  

      This operation in general is possible only for seekable streams (see :meth:`wx.StreamBase.IsSeekable` ); non-seekable streams support only seeking positive amounts in mode  ``FromCurrent``   (this is implemented by reading data and simply discarding it). 




      :param `pos`: Offset to seek to.   
      :type `pos`: wx.FileOffset
      :param `mode`: One of FromStart, FromEnd, FromCurrent.  
      :type `mode`: wx.SeekMode








      :rtype: :ref:`wx.FileOffset`



                  



      :returns: 

         The new stream position or :meth:`InvalidOffset`   on error.   








   .. method:: TellI(self)

      Returns the current stream position or :meth:`InvalidOffset`   if it's not available (e.g.                  

      socket streams do not have a size nor a current stream position).                  

      :rtype: :ref:`wx.FileOffset`








   .. method:: Ungetch(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **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 :meth:`SeekI`   on the same stream. Any call to :meth:`SeekI`   will invalidate any previous call to this method (otherwise you could :meth:`SeekI`   to one position, "unread" a few bytes there, :meth:`SeekI`   to another position and data would be either lost or corrupted). 
      
                      
      
      
      :param `buffer`: 
      :param `size`: 
      :type `size`: int
      
      
      
      
      :rtype: `int`
      
      
      
      
      
      
      
      :returns: 
      
         Returns the amount of bytes saved in the Write-Back buffer.   
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **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.                  
      
      
      :param `c`: 
      :type `c`: int
      
      
      
      
      :rtype: `bool`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: close(self)






   .. method:: eof(self)



      :rtype: `bool`








   .. method:: flush(self)






   .. method:: read(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **read** `(self)`
      
      
      
      :rtype: :ref:`PyObject`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **read** `(self, size)`
      
      
      
      :rtype: :ref:`PyObject`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: readline(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **readline** `(self)`
      
      
      
      :rtype: :ref:`PyObject`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **readline** `(self, size)`
      
      
      
      :rtype: :ref:`PyObject`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: readlines(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **readlines** `(self)`
      
      
      
      :rtype: :ref:`PyObject`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **readlines** `(self, sizehint)`
      
      
      
      :rtype: :ref:`PyObject`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: seek(self, offset, whence=0)






   .. method:: tell(self)



      :rtype: :ref:`wx.FileOffset`








   .. attribute:: C

      See :meth:`~wx.InputStream.GetC`

