Loading...
Searching...
No Matches
OBMolAtomIter Class Reference

`#include <openbabel/obiter.h>`

## Public Member Functions

| OBMolAtomIter ()
| OBMolAtomIter (OBMol *mol)
| OBMolAtomIter (OBMol &mol)
| OBMolAtomIter (const OBMolAtomIter &ai)
| ~OBMolAtomIter ()
OBMolAtomIter & | operator= (const OBMolAtomIter &ai)
| operator bool () const
OBMolAtomIter & | operator++ ()
OBMolAtomIter | operator++ (int)
OBAtom * | operator-> () const
OBAtom & | operator* () const

## Detailed Description

Iterate over all atoms in an OBMol.

To facilitate iteration through all atoms in a molecule, without resorting to atom indexes (which will change in the future), a variety of iterator methods are provided.

This has been made significantly easier by a series of macros in the obiter.h header file:

\#define FOR_ATOMS_OF_MOL(a,m) for( OBMolAtomIter a(m); a; ++a )
OpenBabel::OBMolAtomIter::OBMolAtomIter
OBMolAtomIter()
Definition obiter.h:47
FOR_ATOMS_OF_MOL
#define FOR_ATOMS_OF_MOL(a, m)
Definition obiter.h:398

Here is an example:

#include <openbabel/obiter.h>
#include <openbabel/mol.h>
OpenBabel::OBMol mol;
double exactMass = 0.0;
FOR_ATOMS_OF_MOL(a, mol)
{
// The variable a behaves like OBAtom* when used with -> and * but
// but needs to be explicitly converted when appearing as a parameter
// in a function call - use &*a
exactMass += a->GetExactMass();
}
OpenBabel::OBMol
Molecule Class.
Definition mol.h:121
OpenBabel::OBMol::GetExactMass
double GetExactMass(bool implicitH=true)
Definition mol.cpp:973
mol.h
Handle molecules. Declarations of OBMol, OBAtom, OBBond, OBResidue. (the main header for Open Babel).
obiter.h
STL-style iterators for Open Babel.

## Constructor & Destructor Documentation

## OBMolAtomIter() [1/4]

OBMolAtomIter | ( |  | ) |

inline

Referenced by OBMolAtomIter(), operator++(), operator++(), and operator=().

## OBMolAtomIter() [2/4]

OBMolAtomIter | ( | OBMol * | mol | ) |

## OBMolAtomIter() [3/4]

OBMolAtomIter | ( | OBMol & | mol | ) |

## OBMolAtomIter() [4/4]

OBMolAtomIter | ( | const OBMolAtomIter & | ai | ) |

## ~OBMolAtomIter()

~OBMolAtomIter | ( |  | ) |

inline

## Member Function Documentation

## operator=()

OBMolAtomIter & operator= | ( | const OBMolAtomIter & | ai | ) |

## operator bool()

operator bool | ( |  | ) | const

inline

Returns
  Whether the iterator can still advance (i.e., visit more atoms)

## operator++() [1/2]

OBMolAtomIter & operator++ | ( |  | ) |

Preincrement iterator – advance to next atom and return.

Referenced by operator++().

## operator++() [2/2]

OBMolAtomIter operator++ | ( | int |  | ) |

Postincrement iterator – return the current atom and advance.

## operator->()

OBAtom * operator-> | ( |  | ) | const

inline

Returns
  a pointer to the current atom

## operator*()

OBAtom & operator* | ( |  | ) | const

inline

Returns
  a reference to the current atom

The documentation for this class was generated from the following files:

- obiter.h
- obiter.cpp