Open Babel  3.0
Public Member Functions | List of all members
OBMolAtomIter Class Reference

#include <openbabel/obiter.h>

Public Member Functions

 OBMolAtomIter ()
 
 OBMolAtomIter (OBMol *mol)
 
 OBMolAtomIter (OBMol &mol)
 
 OBMolAtomIter (const OBMolAtomIter &ai)
 
 ~OBMolAtomIter ()
 
OBMolAtomIteroperator= (const OBMolAtomIter &ai)
 
 operator bool () const
 
OBMolAtomIteroperator++ ()
 
OBMolAtomIter operator++ (int)
 
OBAtomoperator-> () const
 
OBAtomoperator* () 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 )

Here is an example:

#include <openbabel/mol.h>
double exactMass = 0.0;
{
// 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();
}

Constructor & Destructor Documentation

◆ OBMolAtomIter() [1/4]

OBMolAtomIter ( )
inline

◆ 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.

◆ 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: