<commit_before>.. _c-api:

C interface reference
=====================

The C interface is define in the ``chemfiles.h`` header, which should be included in
all the programs using chemfiles. All the functions and enums have a ``chfl_``
prefix indicating the provenance of the functions. The types are defined as
opaque pointer types, in all caps. The following types are defined:

* :ref:`CHFL_TRAJECTORY <capi-trajectory>` maps to the :ref:`Trajectory <overview-trajectory>` class;
* :ref:`CHFL_FRAME <capi-frame>` maps to the :ref:`Frame  <overview-frame>` class;
* :ref:`CHFL_ATOM <capi-atom>` maps to the :ref:`Atom  <overview-atom>` class;
* :ref:`CHFL_CELL <capi-cell>` maps to the :ref:`UnitCell  <overview-cell>` class;
* :ref:`CHFL_TOPOLOGY <capi-topology>` maps to the :ref:`Topology  <overview-topology>` class.

The user is reponsible for memory management when using these types. Constructors
functions (functions returning pointers to types defined above) return freshly
allocated memory, and calling the ``chfl_*_free`` functions return the corresponding
memory to the operating system.

Functions for errors handling
-----------------------------

Apart from the *constructor* functions (the functions returning pointers to the
types defined above); all the functions return a status code, which is 0 if
nothing went wrong, and another value in case of error. The following function
allow for error handling from the C side.

.. doxygenfunction:: chfl_strerror

.. doxygenfunction:: chfl_last_error

.. doxygenenum:: CHFL_LOG_LEVEL

.. doxygenfunction:: chfl_loglevel

.. doxygenfunction:: chfl_set_loglevel

.. doxygenfunction:: chfl_logfile

.. doxygenfunction:: chfl_log_stderr

.. _capi-trajectory:

Function manipulating ``CHFL_TRAJECTORY``
-----------------------------------------

The Trajectory type is the main entry point when using chemfiles. A trajectory
behave a bit like a ``FILE*`` pointer, and the ``chfl_close`` free the memory
associated with the file.

.. doxygenfunction:: chfl_trajectory_open

.. doxygenfunction:: chfl_trajectory_with_format

.. doxygenfunction:: chfl_trajectory_read

.. doxygenfunction:: chfl_trajectory_read_step

.. doxygenfunction:: chfl_trajectory_write

.. doxygenfunction:: chfl_trajectory_set_topology

.. doxygenfunction:: chfl_trajectory_set_topology_file

.. doxygenfunction:: chfl_trajectory_nsteps

.. doxygenfunction:: chfl_trajectory_close

.. _capi-frame:

Function manipulating ``CHFL_FRAME``
------------------------------------

.. doxygenfunction:: chfl_frame

.. doxygenfunction:: chfl_frame_atoms_count

.. doxygenfunction:: chfl_frame_positions

.. doxygenfunction:: chfl_frame_set_positions

.. doxygenfunction:: chfl_frame_has_velocities

.. doxygenfunction:: chfl_frame_velocities

.. doxygenfunction:: chfl_frame_set_velocities

.. doxygenfunction:: chfl_frame_set_cell

.. doxygenfunction:: chfl_frame_set_topology

.. doxygenfunction:: chfl_frame_step

.. doxygenfunction:: chfl_frame_set_step

.. doxygenfunction:: chfl_frame_guess_topology

.. doxygenfunction:: chfl_frame_free

.. _capi-cell:

Function manipulating ``CHFL_CELL``
-----------------------------------

.. doxygenfunction:: chfl_cell

.. doxygenfunction:: chfl_cell_from_frame

.. doxygenfunction:: chfl_cell_lengths

.. doxygenfunction:: chfl_cell_set_lengths

.. doxygenfunction:: chfl_cell_angles

.. doxygenfunction:: chfl_cell_set_angles

.. doxygenfunction:: chfl_cell_matrix

.. doxygenenum:: CHFL_CELL_TYPES

.. doxygenfunction:: chfl_cell_type

.. doxygenfunction:: chfl_cell_set_type

.. doxygenfunction:: chfl_cell_periodicity

.. doxygenfunction:: chfl_cell_set_periodicity

.. doxygenfunction:: chfl_cell_free

.. _capi-topology:

Function manipulating ``CHFL_TOPOLOGY``
---------------------------------------

.. doxygenfunction:: chfl_topology

.. doxygenfunction:: chfl_topology_from_frame

.. doxygenfunction:: chfl_topology_atoms_count

.. doxygenfunction:: chfl_topology_append

.. doxygenfunction:: chfl_topology_remove

.. doxygenfunction:: chfl_topology_isbond

.. doxygenfunction:: chfl_topology_isangle

.. doxygenfunction:: chfl_topology_isdihedral

.. doxygenfunction:: chfl_topology_bonds_count

.. doxygenfunction:: chfl_topology_angles_count

.. doxygenfunction:: chfl_topology_dihedrals_count

.. doxygenfunction:: chfl_topology_bonds

.. doxygenfunction:: chfl_topology_angles

.. doxygenfunction:: chfl_topology_dihedrals

.. doxygenfunction:: chfl_topology_add_bond

.. doxygenfunction:: chfl_topology_remove_bond

.. doxygenfunction:: chfl_topology_free

.. _capi-atom:

Function manipulating ``CHFL_ATOM``
-----------------------------------

.. doxygenfunction:: chfl_atom

.. doxygenfunction:: chfl_atom_from_frame

.. doxygenfunction:: chfl_atom_from_topology

.. doxygenfunction:: chfl_atom_mass

.. doxygenfunction:: chfl_atom_set_mass

.. doxygenfunction:: chfl_atom_charge

.. doxygenfunction:: chfl_atom_set_charge

.. doxygenfunction:: chfl_atom_name

.. doxygenfunction:: chfl_atom_set_name

.. doxygenfunction:: chfl_atom_full_name

.. doxygenfunction:: chfl_atom_vdw_radius

.. doxygenfunction:: chfl_atom_covalent_radius

.. doxygenfunction:: chfl_atom_atomic_number

.. doxygenenum:: CHFL_ATOM_TYPES

.. doxygenfunction:: chfl_atom_type

.. doxygenfunction:: chfl_atom_set_type

.. doxygenfunction:: chfl_atom_free
<commit_msg>[doc] Add missing C functions<commit_after>.. _c-api:

C interface reference
=====================

The C interface is define in the ``chemfiles.h`` header, which should be included in
all the programs using chemfiles. All the functions and enums have a ``chfl_``
prefix indicating the provenance of the functions. The types are defined as
opaque pointer types, in all caps. The following types are defined:

* :ref:`CHFL_TRAJECTORY <capi-trajectory>` maps to the :ref:`Trajectory <overview-trajectory>` class;
* :ref:`CHFL_FRAME <capi-frame>` maps to the :ref:`Frame  <overview-frame>` class;
* :ref:`CHFL_ATOM <capi-atom>` maps to the :ref:`Atom  <overview-atom>` class;
* :ref:`CHFL_CELL <capi-cell>` maps to the :ref:`UnitCell  <overview-cell>` class;
* :ref:`CHFL_TOPOLOGY <capi-topology>` maps to the :ref:`Topology  <overview-topology>` class.

The user is reponsible for memory management when using these types. Constructors
functions (functions returning pointers to types defined above) return freshly
allocated memory, and calling the ``chfl_*_free`` functions return the corresponding
memory to the operating system.

Functions for errors handling
-----------------------------

Apart from the *constructor* functions (the functions returning pointers to the
types defined above); all the functions return a status code, which is 0 if
nothing went wrong, and another value in case of error. The following function
allow for error handling from the C side.

.. doxygenfunction:: chfl_strerror

.. doxygenfunction:: chfl_last_error

.. doxygenenum:: CHFL_LOG_LEVEL

.. doxygenfunction:: chfl_loglevel

.. doxygenfunction:: chfl_set_loglevel

.. doxygenfunction:: chfl_logfile

.. doxygenfunction:: chfl_log_stderr

.. _capi-trajectory:

Function manipulating ``CHFL_TRAJECTORY``
-----------------------------------------

The Trajectory type is the main entry point when using chemfiles. A trajectory
behave a bit like a ``FILE*`` pointer, and the ``chfl_close`` free the memory
associated with the file.

.. doxygenfunction:: chfl_trajectory_open

.. doxygenfunction:: chfl_trajectory_with_format

.. doxygenfunction:: chfl_trajectory_read

.. doxygenfunction:: chfl_trajectory_read_step

.. doxygenfunction:: chfl_trajectory_write

.. doxygenfunction:: chfl_trajectory_set_topology

.. doxygenfunction:: chfl_trajectory_set_topology_file

.. doxygenfunction:: chfl_trajectory_nsteps

.. doxygenfunction:: chfl_trajectory_close

.. _capi-frame:

Function manipulating ``CHFL_FRAME``
------------------------------------

.. doxygenfunction:: chfl_frame

.. doxygenfunction:: chfl_frame_atoms_count

.. doxygenfunction:: chfl_frame_resize

.. doxygenfunction:: chfl_frame_positions

.. doxygenfunction:: chfl_frame_velocities

.. doxygenfunction:: chfl_frame_has_velocities

.. doxygenfunction:: chfl_frame_add_velocities

.. doxygenfunction:: chfl_frame_set_cell

.. doxygenfunction:: chfl_frame_set_topology

.. doxygenfunction:: chfl_frame_step

.. doxygenfunction:: chfl_frame_set_step

.. doxygenfunction:: chfl_frame_guess_topology

.. doxygenfunction:: chfl_frame_free

.. _capi-cell:

Function manipulating ``CHFL_CELL``
-----------------------------------

.. doxygenfunction:: chfl_cell

.. doxygenfunction:: chfl_cell_from_frame

.. doxygenfunction:: chfl_cell_lengths

.. doxygenfunction:: chfl_cell_set_lengths

.. doxygenfunction:: chfl_cell_angles

.. doxygenfunction:: chfl_cell_set_angles

.. doxygenfunction:: chfl_cell_matrix

.. doxygenenum:: CHFL_CELL_TYPES

.. doxygenfunction:: chfl_cell_type

.. doxygenfunction:: chfl_cell_set_type

.. doxygenfunction:: chfl_cell_periodicity

.. doxygenfunction:: chfl_cell_set_periodicity

.. doxygenfunction:: chfl_cell_free

.. _capi-topology:

Function manipulating ``CHFL_TOPOLOGY``
---------------------------------------

.. doxygenfunction:: chfl_topology

.. doxygenfunction:: chfl_topology_from_frame

.. doxygenfunction:: chfl_topology_atoms_count

.. doxygenfunction:: chfl_topology_append

.. doxygenfunction:: chfl_topology_remove

.. doxygenfunction:: chfl_topology_isbond

.. doxygenfunction:: chfl_topology_isangle

.. doxygenfunction:: chfl_topology_isdihedral

.. doxygenfunction:: chfl_topology_bonds_count

.. doxygenfunction:: chfl_topology_angles_count

.. doxygenfunction:: chfl_topology_dihedrals_count

.. doxygenfunction:: chfl_topology_bonds

.. doxygenfunction:: chfl_topology_angles

.. doxygenfunction:: chfl_topology_dihedrals

.. doxygenfunction:: chfl_topology_add_bond

.. doxygenfunction:: chfl_topology_remove_bond

.. doxygenfunction:: chfl_topology_free

.. _capi-atom:

Function manipulating ``CHFL_ATOM``
-----------------------------------

.. doxygenfunction:: chfl_atom

.. doxygenfunction:: chfl_atom_from_frame

.. doxygenfunction:: chfl_atom_from_topology

.. doxygenfunction:: chfl_atom_mass

.. doxygenfunction:: chfl_atom_set_mass

.. doxygenfunction:: chfl_atom_charge

.. doxygenfunction:: chfl_atom_set_charge

.. doxygenfunction:: chfl_atom_name

.. doxygenfunction:: chfl_atom_set_name

.. doxygenfunction:: chfl_atom_full_name

.. doxygenfunction:: chfl_atom_vdw_radius

.. doxygenfunction:: chfl_atom_covalent_radius

.. doxygenfunction:: chfl_atom_atomic_number

.. doxygenenum:: CHFL_ATOM_TYPES

.. doxygenfunction:: chfl_atom_type

.. doxygenfunction:: chfl_atom_set_type

.. doxygenfunction:: chfl_atom_free

{'fraction_non_alphanumeric': 0.1338457212484769, 'fraction_numerical': 0.00018745899334520573, 'mean_word_length': 4.430025445292621, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1720417', 'n_tokens_mistral': 3420, 'n_tokens_neox': 3349, 'n_words': 772}