.. include:: ../../toolkit-substitutions

.. oe:namespace:: OEBio

.. oe:function:: OEWriteDesignUnit

   .. attention::

      |TWOLANGUAGE|

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

      .. oe:api::

         bool OEWriteDesignUnit(const std::string& fname,
                                const OEDesignUnit& du)
         bool OEWriteDesignUnit(OEPlatform::oeostream& ofs,
                                const OEDesignUnit& du)

   .. oe:language:: python

      .. oe:api:: python

         OEWriteDesignUnit(fname: str, du: OEDesignUnit) -> bool
         OEWriteDesignUnit(ofs: oeostream, du: OEDesignUnit) -> bool


   Write an :ref:`OEDesignUnit <OEBio_OEDesignUnit>` named
   ``du`` to an OEDesignUnit (.oedu) file ``fname``. This will overwrite the
   previous file if it existed.

   The overload that takes an :oe:func:`OEPlatform::oeostream` can be
   used to write multiple :oe:cls:`OEDesignUnits<OEBio::OEDesignUnit>`
   to the same destination.
   Note that the format must be specified by a constant from the
   :oe:const:`OEBio::OEDesignUnitFileType` namespace as the type
   argument.

   The function returns ``true`` if the file was written
   successfully, and ``false`` otherwise.

   .. seealso::

      * :ref:`OEDesignUnit <OEBio_OEDesignUnit>` class
      * :oe:func:`OEBio::OEIsWriteableDesignUnit` function
      * :oe:func:`OEBio::OEReadDesignUnit` function
