Loading...
Searching...
No Matches
OBMolBondIter Class Reference

`#include <openbabel/obiter.h>`

## Public Member Functions

| OBMolBondIter ()
| OBMolBondIter (OBMol *mol)
| OBMolBondIter (OBMol &mol)
| OBMolBondIter (const OBMolBondIter &bi)
| ~OBMolBondIter ()
OBMolBondIter & | operator= (const OBMolBondIter &bi)
| operator bool () const
OBMolBondIter & | operator++ ()
OBMolBondIter | operator++ (int)
OBBond * | operator-> () const
OBBond & | operator* () const

## Detailed Description

Iterate over all bonds in an OBMol.

To facilitate iteration through all bonds in a molecule, without resorting to bond indexes (which may change in the future), a variety of iterators are provided.

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

\#define FOR_BONDS_OF_MOL(b,m) for( OBMolBondIter b(m); b; ++b )
OpenBabel::OBMolBondIter::OBMolBondIter
OBMolBondIter()
Definition obiter.h:170
FOR_BONDS_OF_MOL
#define FOR_BONDS_OF_MOL(b, m)
Definition obiter.h:399

Here is an example:

#include <openbabel/obiter.h>
#include <openbabel/mol.h>
OpenBabel::OBMol mol;
unsigned int bondOrderSum = 0;
FOR_BONDS_OF_MOL(b, mol)
{
// The variable b behaves like OBBond* when used with -> and * but
// but needs to be explicitly converted when appearing as a parameter
// in a function call - use &*b
bondOrderSum += b->GetBondOrder();
}
OpenBabel::OBMol
Molecule Class.
Definition mol.h:121
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

## OBMolBondIter() [1/4]

OBMolBondIter | ( |  | ) |

inline

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

## OBMolBondIter() [2/4]

OBMolBondIter | ( | OBMol * | mol | ) |

## OBMolBondIter() [3/4]

OBMolBondIter | ( | OBMol & | mol | ) |

## OBMolBondIter() [4/4]

OBMolBondIter | ( | const OBMolBondIter & | bi | ) |

## ~OBMolBondIter()

~OBMolBondIter | ( |  | ) |

inline

## Member Function Documentation

## operator=()

OBMolBondIter & operator= | ( | const OBMolBondIter & | bi | ) |

## operator bool()

operator bool | ( |  | ) | const

inline

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

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

OBMolBondIter & operator++ | ( |  | ) |

Preincrement – advance to the next bond and return.

Referenced by operator++().

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

OBMolBondIter operator++ | ( | int |  | ) |

Postincrement – return the current bond and advance to the next.

## operator->()

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

inline

Returns
  a pointer to the current bond

## operator*()

OBBond & operator* | ( |  | ) | const

inline

Returns
  a reference to the current bond

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

- obiter.h
- obiter.cpp