.. oe:namespace:: OEPlatform



.. meta::
   :keywords: oeofstream, ofstream


.. _OEPlatform_oeofstream:

.. oe:class:: oeofstream

   .. oe:api::


      class oeofstream : public oeostream

   This class represents `oeofstream`.

   
   Implements an output stream capable of writing to a specified file
   or to any generic data source with an associated file descriptor.

   The following methods are publicly inherited from :ref:`oeostream <OEPlatform_oeostream>`:


   ========================================================= ======================================================= =======================================================
   :oe:meth:`operator\< <OEPlatform::oeostream::operator<<>` :oe:meth:`flush<OEPlatform::oeostream::flush>`          :oe:meth:`putbyte<OEPlatform::oeostream::putbyte>`     
   :oe:meth:`close<OEPlatform::oeostream::close>`            :oe:meth:`open<OEPlatform::oeostream::open>`            :oe:meth:`write<OEPlatform::oeostream::write>`         
   ========================================================= ======================================================= =======================================================

   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::

            oeofstream()
            oeofstream(int ofd)
            oeofstream(const char* filename)
            oeofstream(const std::string& filename)

      .. oe:language:: python

         .. oe:api:: python

            oeofstream() -> oeofstream
            oeofstream(ofd: int) -> oeofstream
            oeofstream(filename: str) -> oeofstream

      Creates a new :ref:`oeofstream <OEPlatform_oeofstream>`.
      If a valid file descriptor ('fd') is passed
      to the constructor, the stream will use the associated data target
      for output. Otherwise, the constructors expect the name of file to
      be written to. If the named file does not exist, it will be
      created. If no parameter is passed to the constructor, the stream
      can later be opened using the open command defined in
      :ref:`oeostream <OEPlatform_oeostream>` or the
      :oe:meth:`OEPlatform::oeofstream::openfd` command defined in this class.



   .. oe:method:: append

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

         .. oe:api::

            bool append(const char* filename)
            bool append(const std::string& filename)

      .. oe:language:: python

         .. oe:api:: python

            append(filename: str) -> bool

      Opens the specified file to which data will be appended. Returns
      whether or not the file was successfully opened (or created as
      necessary).



   .. 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 target.


   .. oe:method:: openfd

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

         .. oe:api::

            bool openfd(int ofd, bool closefd)

      .. oe:language:: python

         .. oe:api:: python

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

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

