.. oe:namespace:: OEChem

.. oe:language:: c++

   .. meta::
      :keywords: OEWriteMolToString

   ..   _oechem_oewritemoltostring:

   .. oe:function:: OEWriteMolToString

      .. oe:api:: c++

         std::string OEWriteMolToString(const std::string& format,
                                        const OEMolBase& mol)
         std::string OEWriteMolToString(unsigned format, bool gzip,
                                        const OEMolBase& mol)
         std::string OEWriteMolToString(unsigned format, unsigned flavor,
                                        bool gzip, const OEMolBase& mol)

         std::string OEWriteMolToString(const std::string& format,
                                        const OEMCMolBase& mol)
         std::string OEWriteMolToString(unsigned format, bool gzip,
                                        const OEMCMolBase& mol)
         std::string OEWriteMolToString(unsigned format, unsigned flavor,
                                        bool gzip, const OEMCMolBase& mol)

         bool OEWriteMolToString(std::string& molstring, unsigned format,
                                 bool gzip, const OEMolBase& mol)
         bool OEWriteMolToString(std::string& molstring, unsigned format,
                                 unsigned flavor, bool gzip,
                                 const OEMolBase& mol)
         bool OEWriteMolToString(std::string& molstring, unsigned format,
                                 bool gzip, const OEMCMolBase& mol)
         bool OEWriteMolToString(std::string& molstring, unsigned format,
                                 unsigned flavor, bool gzip,
                                 const OEMCMolBase& mol)

.. oe:language:: java

   .. meta::
      :keywords: OEWriteMolToByteArray

   ..   _oechem_oewritemoltobytearray:

   .. oe:function:: OEWriteMolToByteArray

      .. oe:api:: java

         byte[] OEWriteMolToByteArray(String format, OEMolBase mol)
         byte[] OEWriteMolToByteArray(int format, boolean gzip, OEMolBase mol)
         byte[] OEWriteMolToByteArray(int format, int flavor, boolean gzip,
                                      OEMolBase mol)

         byte[] OEWriteMolToByteArray(String format, OEMCMolBase mol)
         byte[] OEWriteMolToByteArray(int format, boolean gzip, OEMCMolBase mol)
         byte[] OEWriteMolToByteArray(int format, int flavor, boolean gzip,
                                      OEMCMolBase mol)

.. oe:language:: python

   .. meta::
      :keywords: OEWriteMolToBytes

   ..   _oechem_oewritemoltobytes:

   .. oe:function:: OEWriteMolToBytes

      .. oe:api:: python

         OEWriteMolToBytes(format, oemol) -> bytes
         OEWriteMolToBytes(format, gzip, oemol) -> bytes
         OEWriteMolToBytes(format, flavor, gzip, oemol) -> bytes

         OEWriteMolToBytes(format, oemcmol) -> bytes
         OEWriteMolToBytes(format, gzip, oemcmol) -> bytes
         OEWriteMolToBytes(format, flavor, gzip, oemcmol) -> bytes

.. oe:language:: csharp

   .. meta::
      :keywords: OEWriteMolToBytes, OEWriteMolToByteArray, OEWriteMolToString

   ..   _oechem_oewritemoltobytes:

   .. oe:function:: OEWriteMolToBytes

      .. oe:api:: csharp

         OEIntArray OEWriteMolToByteArray(String format, OEMolBase mol)
         OEIntArray OEWriteMolToByteArray(String format, OEMCMolBase mol)

         byte[] OEWriteMolToBytes(String format, OEMolBase mol)
         byte[] OEWriteMolToBytes(int format, int flavor, boolean gzip,
                                  OEMolBase mol)

         byte[] OEWriteMolToBytes(String format, OEMCMolBase mol)
         byte[] OEWriteMolToBytes(int format, int flavor, boolean gzip,
                                  OEMCMolBase mol)

.. oe:language:: python c++ java

   Encodes a molecule in terms of 'format'. 'format' must be a file extension
   that is writeable by OpenEye, for example: ".oeb.gz". The overloads which take
   a Boolean 'gzip' parameter or an unsigned 'flavor' and Boolean 'gzip' parameters expect
   the format or the format and flavor to be specified by one of the constants 
   in :oe:constns:`OEChem::OEFormat` and :oe:constns:`OEChem::OEOFlavor`.

.. oe:language:: csharp

   Encodes a molecule in terms of 'format'. 'format' must be a file extension
   that is writeable by OpenEye, for example: ".oeb.gz". Overloads which take
   an unsigned 'format', unsigned 'flavor' and Boolean 'gzip' parameters expect
   the format or the format and flavor to be specified by one of the constants
   in :oe:constns:`OEChem::OEFormat` and :oe:constns:`OEChem::OEOFlavor`.

   .. warning::

      The overload that takes an :ref:`OEIntArray <OEChem_OEIntArray>` is deprecated as of 2018.Feb and will be removed in a future
      version of **OEChem TK**, please use :oe:func:`OEChem::OEWriteMolToBytes` instead.

.. oe:language:: c++

   Overloads which take an extra string reference and return a boolean status write
   the result in the provided string and return `true` if encoding into
   the given string was successful.

   Otherwise, a non-empty std::string is returned if the encoding was successful.

.. oe:language:: java

   Returns a non-empty byte[] if encoding was successful.

.. oe:language:: python

   Returns bytes if encoding was successful, otherwise ''None''.

.. oe:language:: c++

   .. oe:source:: EncodeMols.cpp
      :language: c++
      :frag:     SNIPPET-WRITEMOL
      :noindent:

   .. oe:source:: EncodeMols.cpp
      :language: c++
      :frag:     SNIPPET-WRITEMOL2
      :noindent:

   .. oe:source:: EncodeMols.cpp
      :language: c++
      :frag:     SNIPPET-WRITEMOL3
      :noindent:

   .. oe:source:: EncodeMols.cpp
      :language: c++
      :frag:     SNIPPET-WRITEMOL4
      :noindent:

.. oe:language:: python

   .. oe:source:: EncodeMols.py
      :language: python
      :frag:     SNIPPET-WRITEMOL
      :noindent:

   .. oe:source:: EncodeMols.py
      :language: python
      :frag:     SNIPPET-WRITEMOL2
      :noindent:

   .. oe:source:: EncodeMols.py
      :language: python
      :frag:     SNIPPET-WRITEMOL3
      :noindent:

.. oe:language:: java

   .. oe:source:: EncodeMols.java
      :language: java
      :frag:     SNIPPET-WRITEMOL
      :noindent:

   .. oe:source:: EncodeMols.java
      :language: java
      :frag:     SNIPPET-WRITEMOL2
      :noindent:

   .. oe:source:: EncodeMols.java
      :language: java
      :frag:     SNIPPET-WRITEMOL3
      :noindent:

.. oe:language:: csharp

   .. oe:source:: EncodeMols.cs
      :language: csharp
      :frag:     SNIPPET-WRITEMOL
      :noindent:

   .. oe:source:: EncodeMols.cs
      :language: csharp
      :frag:     SNIPPET-WRITEMOL3
      :noindent:
