#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 |
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 )
Here is an example:
#include <openbabel/obiter.h> #include <openbabel/mol.h> 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(); }
| OBMolAtomIter | ( | ) | [inline] |
| OBMolAtomIter | ( | OBMol * | mol | ) |
| OBMolAtomIter | ( | OBMol & | mol | ) |
| OBMolAtomIter | ( | const OBMolAtomIter & | ai | ) |
| ~OBMolAtomIter | ( | ) | [inline] |
| OBMolAtomIter & operator= | ( | const OBMolAtomIter & | ai | ) |
| operator bool | ( | ) | const [inline] |
| OBMolAtomIter & operator++ | ( | ) |
Preincrement iterator -- advance to next atom and return.
| OBMolAtomIter operator++ | ( | int | ) |
Postincrement iterator -- return the current atom and advance.
| OBAtom* operator-> | ( | ) | const [inline] |
| OBAtom& operator * | ( | ) | const [inline] |