.. oe:namespace:: OEChem



.. meta::
   :keywords: OECSVHeader, CSVHeader


.. _OEChem_OECSVHeader:

.. oe:class:: OECSVHeader

   .. oe:api::

      class OECSVHeader

   This class stores the column names to be read or written to a
   :oe:const:`OEChem::OEFormat::CSV` file. It is typically retrieved
   from an :ref:`oemolstreambase <OEChem_oemolstreambase>` through the
   :oe:meth:`OEChem::oemolstreambase::GetCSVHeader` method. The object
   available from that method is initialized during the first read or
   write operation on that stream. 

   .. seealso::

      :oe:func:`OEChem::OECreateCSVHeader` for creating a
      :ref:`OECSVHeader <OEChem_OECSVHeader>` from the SD data tag in a molecule.

   
   .. oe:method:: Constructors

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

         .. oe:api::

            OECSVHeader()
            OECSVHeader(const OECSVHeader& rhs)
            OECSVHeader(const std::vector<std::string>& columnNames)

      .. oe:language:: python

         .. oe:api:: python

            OECSVHeader() -> OECSVHeader
            OECSVHeader(rhs: OECSVHeader) -> OECSVHeader
            OECSVHeader(columnNames: OEStringVector) -> OECSVHeader

      The default constructors initializes the object to an empty
      state. The copy constructor can be used to make a copy from
      about :ref:`OECSVHeader <OEChem_OECSVHeader>` object. The class can also be
      constructed directly from a ``std::vector`` of ``std::string``. 

   .. oe:method:: operator=
      :language: c++

      .. oe:api::

         OECSVHeader &operator=(const OECSVHeader &rhs)

      Assignment operator to copy the contents of ``rhs`` into this class. 

      Assignment operator.


   .. oe:method:: operator bool

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

         .. oe:api::

            operator bool() const

      .. oe:language:: python

         .. oe:api:: python

            IsValid() -> bool

      Returns ``false`` if this class has not been initialized with
      any column names yet. Returns ``true`` if this class does
      contain column names.

   .. oe:method:: Clear

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

         .. oe:api::

            void Clear()

      .. oe:language:: python

         .. oe:api:: python

            Clear() -> None

      Resets the class to an empty uninitialized state. 

   .. oe:method:: GetColumnName

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

         .. oe:api::

            const std::string& GetColumnName(unsigned int fieldIdx) const

      .. oe:language:: python

         .. oe:api:: python

            GetColumnName(fieldIdx: int) -> str

      Return the column name for the particular index, starting at
      zero. If ``fieldIdx`` is not less than
      :oe:meth:`OEChem::OECSVHeader::GetNumColumns`, a reference to an
      empty string is returned.

   .. oe:method:: GetColumnNames

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

         .. oe:api::

            OESystem::OEIterBase<const std::string>* GetColumnNames() const

      .. oe:language:: python

         .. oe:api:: python

            GetColumnNames() -> Iterable[str]

      Returns an iterator over all the column names stored in this class. 

   .. oe:method:: GetNumColumns

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

         .. oe:api::

            unsigned int GetNumColumns() const

      .. oe:language:: python

         .. oe:api:: python

            GetNumColumns() -> int

      Returns the number of column names stored in this class. 

   .. oe:method:: IsValid

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

         .. oe:api::

            bool IsValid() const

      .. oe:language:: python

         .. oe:api:: python

            IsValid() -> bool

      Returns ``false`` if this class has not been initialized with
      any column names yet. Returns ``true`` if this class does
      contain column names.
