Coverage Report

Created: 2026-09-28 07:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/rdkit/Code/GraphMol/BondIterators.h
Line
Count
Source
1
//
2
//  Copyright (C) 2002-2006 Greg Landrum and Rational Discovery LLC
3
//
4
//   @@ All Rights Reserved @@
5
//  This file is part of the RDKit.
6
//  The contents are covered by the terms of the BSD license
7
//  which is included in the file license.txt, found at the root
8
//  of the RDKit source tree.
9
//
10
/*! \file BondIterators.h
11
12
  \brief various tools for iterating over a molecule's Bonds
13
14
   <b>WARNING:</b> If you go changing the molecule underneath one of
15
   these iterators you will be sad...
16
*/
17
#include <RDGeneral/export.h>
18
#ifndef _RD_BOND_ITERATORS_H
19
#define _RD_BOND_ITERATORS_H
20
21
#include "ROMol.h"
22
23
namespace RDKit {
24
25
//! \brief iterator for a molecule's bonds, currently BiDirectional,
26
//! but it theoretically ought to be RandomAccess.
27
class RDKIT_GRAPHMOL_EXPORT BondIterator_ {
28
  // FIX: I'm not pleased with the lack of internal testing code
29
  //  (PREs and the like) in here
30
 public:
31
0
  BondIterator_() {}
32
  BondIterator_(ROMol *mol);
33
  BondIterator_(ROMol *mol, ROMol::EDGE_ITER pos);
34
  BondIterator_(const BondIterator_ &other);
35
  BondIterator_ &operator=(const BondIterator_ &other);
36
  bool operator==(const BondIterator_ &other) const;
37
  bool operator!=(const BondIterator_ &other) const;
38
  Bond *operator*() const;
39
  // pre-increment
40
  BondIterator_ &operator++();
41
  BondIterator_ operator++(int);
42
  // pre-decrement
43
  BondIterator_ &operator--();
44
  BondIterator_ operator--(int);
45
46
 private:
47
  ROMol::EDGE_ITER _beg, _end, _pos;
48
  ROMol *_mol{nullptr};
49
};
50
//! \brief const iterator for a molecule's bonds, currently BiDirectional,
51
//! but it theoretically ought to be RandomAccess.
52
class RDKIT_GRAPHMOL_EXPORT ConstBondIterator_ {
53
 public:
54
0
  ConstBondIterator_() {}
55
  ConstBondIterator_(ROMol const *mol);
56
  ConstBondIterator_(ROMol const *mol, ROMol::EDGE_ITER pos);
57
  ConstBondIterator_(const ConstBondIterator_ &other);
58
  ConstBondIterator_ &operator=(const ConstBondIterator_ &other);
59
  bool operator==(const ConstBondIterator_ &other) const;
60
  bool operator!=(const ConstBondIterator_ &other) const;
61
  Bond const *operator*() const;
62
  // pre-increment
63
  ConstBondIterator_ &operator++();
64
  ConstBondIterator_ operator++(int);
65
  // pre-decrement
66
  ConstBondIterator_ &operator--();
67
  ConstBondIterator_ operator--(int);
68
69
 private:
70
  ROMol::EDGE_ITER _beg, _end, _pos;
71
  ROMol const *_mol{nullptr};
72
};
73
}  // namespace RDKit
74
75
#endif