.. oe:namespace:: OEPlatform



.. meta::
   :keywords: oeifstream, ifstream


.. _OEPlatform_oeifstream:

.. oe:class:: oeifstream

   .. oe:api::


      class oeifstream : public oeistream

   This class represents `oeifstream`.

   Implements an input stream capable of reading from a specified file
   or from any generic data source with an associated file descriptor.


   The following methods are publicly inherited from :ref:`oeistream <OEPlatform_oeistream>`:

   ======================================================== ======================================================= =======================================================
   :oe:meth:`operator>><OEPlatform::oeistream::operator>>>` :oe:meth:`gettoken<OEPlatform::oeistream::gettoken>`    :oe:meth:`skipbyte<OEPlatform::oeistream::skipbyte>`   
   :oe:meth:`close<OEPlatform::oeistream::close>`           :oe:meth:`open<OEPlatform::oeistream::open>`            :oe:meth:`skipline<OEPlatform::oeistream::skipline>`   
   :oe:meth:`get<OEPlatform::oeistream::get>`               :oe:meth:`peekbyte<OEPlatform::oeistream::peekbyte>`                                                           
   :oe:meth:`getbyte<OEPlatform::oeistream::getbyte>`       :oe:meth:`read<OEPlatform::oeistream::read>`                                                                   
   :oe:meth:`getline<OEPlatform::oeistream::getline>`       :oe:meth:`skip<OEPlatform::oeistream::skip>`                                                                   
   ======================================================== ======================================================= =======================================================

   The following methods are publicly inherited from :ref:`oestream <OEPlatform_oestream>`:

   ============================================================= ============================================================ ============================================================
   :oe:meth:`operator bool<OEPlatform::oestream::operator bool>` :oe:meth:`rewind<OEPlatform::oestream::rewind>`              :oe:meth:`tell<OEPlatform::oestream::tell>`                 
   :oe:meth:`eof<OEPlatform::oestream::eof>`                     :oe:meth:`seek<OEPlatform::oestream::seek>`                                                                              
   :oe:meth:`length<OEPlatform::oestream::length>`               :oe:meth:`size<OEPlatform::oestream::size>`                                                                              
   ============================================================= ============================================================ ============================================================


   .. oe:method:: Constructors

      .. oe:language:: c++ java csharp

         .. oe:api::

            oeifstream()
            oeifstream(int ifd)
            oeifstream(const char* filename)
            oeifstream(const std::string& filename)

      .. oe:language:: python

         .. oe:api:: python

            oeifstream() -> oeifstream
            oeifstream(ifd: int) -> oeifstream
            oeifstream(filename: str) -> oeifstream


      Creates a new :ref:`oeifstream <OEPlatform_oeifstream>`. If a valid file descriptor ('ifd')
      is passed to the constructor, the stream will use the associated data source
      for input. Otherwise, the constructors expect the name of an
      existing file from which to read. If no parameter is passed to the
      constructor, the stream can later be opened using the open command
      defined in :ref:`oeistream <OEPlatform_oeistream>` or the
      :oe:meth:`OEPlatform::oeifstream::openfd` 
      command defined in this class.

   .. oe:method:: fd

      .. oe:language:: c++ java csharp

         .. oe:api::

            int fd() const

      .. oe:language:: python

         .. oe:api:: python

            fd() -> int

      Returns the system dependent file descriptor associated with the
      stream's data source.

   .. oe:method:: openfd

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool openfd(int ifd, bool closefd)

      .. oe:language:: python

         .. oe:api:: python

            openfd(ifd: int, closefd: bool) -> bool

      Sets the data source of the stream to the specified file descriptor
      'ifd'. If 'closefd' is ``false``, the underlying data source 
      is not closed before changing to the new data source.

   .. oe:method:: pread

      .. oe:language:: c++ java csharp

         .. oe:api::

            oesize_t pread(char* buffer, oesize_t len, oefpos_t offset) const

      .. oe:language:: python

         .. oe:api:: python

            pread(buffer: str, len: oesize_t, offset: oefpos_t) -> oesize_t

      Reads 'len' bytes into 'buffer' at the specified 'offset' in the
      file. Returns the number of bytes actually read. This method
      allows multiple threads to safely read from a single file
      descriptor. 

      .. warning:: 
         
         It is undefined behavior to mix calls to 'pread' other
         :ref:`oeistream <OEPlatform_oeistream>` read method calls on the same object.
