This file is indexed.

/usr/include/openbabel-2.0/openbabel/obiter.h is in libopenbabel-dev 2.3.2+dfsg-2.2build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
/**********************************************************************
obiter.h - STL-style iterators for Open Babel.

Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc.
Some portions Copyright (C) 2001-2006 by Geoffrey R. Hutchison

This file is part of the Open Babel project.
For more information, see <http://openbabel.org/>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation version 2 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
***********************************************************************/

#ifndef OB_OBITER_H
#define OB_OBITER_H

#include <openbabel/babelconfig.h>
#include <openbabel/base.h>
#include <openbabel/bitvec.h>

#include <vector>
#include <stack>
#include <queue>

namespace OpenBabel
{

  class OBMol;
  class OBAtom;
  class OBBond;
  class OBResidue;

  // more detailed descriptions and documentation in obiter.cpp

  //! \brief Iterate over all atoms in an OBMol
  class OBAPI OBMolAtomIter {
    std::vector<OBAtom*>::iterator _i;
    OBMol *_parent;
    OBAtom *_ptr;
  public:

    OBMolAtomIter() :_parent(NULL), _ptr(NULL) { }
    OBMolAtomIter(OBMol *mol);
    OBMolAtomIter(OBMol &mol);
    OBMolAtomIter(const OBMolAtomIter &ai);
    ~OBMolAtomIter() { }

    OBMolAtomIter& operator=(const OBMolAtomIter &ai);
    //! \return Whether the iterator can still advance (i.e., visit more atoms)
    operator bool() const        { return _ptr != NULL; }
    //! Preincrement iterator -- advance to next atom and return
    OBMolAtomIter& operator++();
    //! Postincrement iterator -- return the current atom and advance
    OBMolAtomIter  operator++(int);
    //! \return a pointer to the current atom
    OBAtom* operator->() const   { return _ptr;      }
    //! \return a reference to the current atom
    OBAtom& operator*() const    { return *_ptr;     }
  };

  //! \brief Iterate over all atoms in an OBMol in a depth-first search (DFS)
  class OBAPI OBMolAtomDFSIter {
    OBMol               *_parent;
    OBAtom              *_ptr;
    OBBitVec             _notVisited;
    std::stack<OBAtom *> _stack;
  public:

    OBMolAtomDFSIter() : _parent(NULL), _ptr(NULL) { }
    OBMolAtomDFSIter(OBMol *mol, int StartIndex=1);
    OBMolAtomDFSIter(OBMol &mol, int StartIndex=1);
    OBMolAtomDFSIter(const OBMolAtomDFSIter &ai);
    ~OBMolAtomDFSIter() { }

    OBMolAtomDFSIter& operator=(const OBMolAtomDFSIter &ai);
    //! \return Whether the iterator can still advance (i.e., visit more atoms)
    operator bool() const        { return _ptr != NULL; }
    //! Preincrement -- advance to the next atom in the DFS list and return
    OBMolAtomDFSIter& operator++();
    //! Postincrement -- return the current atom and advance to the next atom
    OBMolAtomDFSIter  operator++(int);
    //! \return a pointer to the current atom
    OBAtom* operator->() const   { return _ptr;      }
    //! \return a reference to the current atom
    OBAtom& operator*() const    { return *_ptr;     }
    /// \return NULL if at the last atom in a fragment, else the next atom
    OBAtom* next()
    {
      if(_stack.empty())
        return NULL; //end of a disconnected fragment
      else
        return _stack.top(); //the next atom
    }
  };

  //! \brief Iterate over all atoms in an OBMol in a breadth-first search (BFS)
  class OBAPI OBMolAtomBFSIter {
    OBMol               *_parent;
    OBAtom              *_ptr;
    OBBitVec             _notVisited;
    std::queue<OBAtom *> _queue;
    std::vector<int>     _depth;
  public:

    OBMolAtomBFSIter(): _parent(NULL), _ptr(NULL) { }
    OBMolAtomBFSIter(OBMol *mol, int StartIndex = 1);
    OBMolAtomBFSIter(OBMol &mol, int StartIndex = 1);
    OBMolAtomBFSIter(const OBMolAtomBFSIter &ai);
    ~OBMolAtomBFSIter() { }

    OBMolAtomBFSIter& operator=(const OBMolAtomBFSIter &ai);
    //! \return Whether the iterator can still advance (i.e., visit more atoms)
    operator bool() const        { return _ptr != NULL; }
    //! Preincrement -- advance to the next atom in the BFS list and return
    OBMolAtomBFSIter& operator++();
    //! Postincrement -- return the current atom and advance to the next atom
    OBMolAtomBFSIter  operator++(int);
    //! \return a pointer to the current atom
    OBAtom* operator->() const   { return _ptr;      }
    //! \return a reference to the current atom
    OBAtom& operator*() const    { return *_ptr;     }
    //! \return the current depth of the iterator
    //! \since version 2.2
    int CurrentDepth() const;
  };

  //! \brief Iterate over all bonds in an OBMol in a breadth-first search (BFS)
  class OBAPI OBMolBondBFSIter {
    OBMol               *_parent;
    OBBond              *_ptr;
    OBBitVec             _notVisited;
    std::queue<OBBond *> _queue;
    std::vector<int>     _depth;
  public:

    OBMolBondBFSIter(): _parent(NULL), _ptr(NULL) { }
    OBMolBondBFSIter(OBMol *mol, int StartIndex = 0);
    OBMolBondBFSIter(OBMol &mol, int StartIndex = 0);
    OBMolBondBFSIter(const OBMolBondBFSIter &ai);
    ~OBMolBondBFSIter() { }

    OBMolBondBFSIter& operator=(const OBMolBondBFSIter &ai);
    //! \return Whether the iterator can still advance (i.e., visit more atoms)
    operator bool() const        { return _ptr != NULL; }
    //! Preincrement -- advance to the next atom in the BFS list and return
    OBMolBondBFSIter& operator++();
    //! Postincrement -- return the current atom and advance to the next atom
    OBMolBondBFSIter  operator++(int);
    //! \return a pointer to the current atom
    OBBond* operator->() const   { return _ptr;      }
    //! \return a reference to the current atom
    OBBond& operator*() const    { return *_ptr;     }
    //! \return the current depth of the iterator
    //! \since version 2.2
    int CurrentDepth() const;
  };

  //! \brief Iterate over all bonds in an OBMol
  class OBAPI OBMolBondIter {
    std::vector<OBBond*>::iterator _i;
    OBMol *_parent;
    OBBond *_ptr;
  public:

    OBMolBondIter() : _parent(NULL), _ptr(NULL) {}
    OBMolBondIter(OBMol *mol);
    OBMolBondIter(OBMol &mol);
    OBMolBondIter(const OBMolBondIter &bi);
    ~OBMolBondIter() { }

    OBMolBondIter& operator=(const OBMolBondIter &bi);
    //! \return Whether the iterator can still advance (i.e., visit more bonds)
    operator bool() const        { return _ptr != NULL; }
    //! Preincrement -- advance to the next bond and return
    OBMolBondIter& operator++();
    //! Postincrement -- return the current bond and advance to the next
    OBMolBondIter  operator++(int);
    //! \return a pointer to the current bond
    OBBond* operator->() const   { return _ptr;      }
    //! \return a reference to the current bond
    OBBond& operator*() const    { return *_ptr;     }
  };

  //! \brief Iterate over all neighboring atoms to an OBAtom
  class OBAPI OBAtomAtomIter {
    std::vector<OBBond*>::iterator _i;
    OBAtom *_parent;
    OBAtom *_ptr;
  public:

    OBAtomAtomIter() : _parent(NULL), _ptr(NULL) { }
    OBAtomAtomIter(OBAtom *atm);
    OBAtomAtomIter(OBAtom &atm);
    OBAtomAtomIter(const OBAtomAtomIter &ai);
    ~OBAtomAtomIter() { }

    OBAtomAtomIter& operator=(const OBAtomAtomIter &ai);
     //! \return Whether the iterator can still advance (i.e., visit more neighbors)
    operator bool() const        { return _ptr != NULL; }
    //! Preincrement -- advance to the next neighbor and return
    OBAtomAtomIter& operator++();
    //! Postincrement -- return the current neighbor and advance to the next
    OBAtomAtomIter  operator++(int);
    //! \return a pointer to the current atom
    OBAtom* operator->() const   { return _ptr;      }
    //! \return a reference to the current atom
    OBAtom& operator*() const    { return *_ptr;     }
  };

  //! \brief Iterate over all bonds on an OBAtom
  class OBAPI OBAtomBondIter {
    std::vector<OBBond*>::iterator _i;
    OBAtom *_parent;
    OBBond *_ptr;
  public:

    OBAtomBondIter(): _parent(NULL), _ptr(NULL) { }
    OBAtomBondIter(OBAtom *atm);
    OBAtomBondIter(OBAtom &atm);
    OBAtomBondIter(const OBAtomBondIter &bi);
    ~OBAtomBondIter() { }

    OBAtomBondIter& operator=(const OBAtomBondIter &bi);
    //! \return Whether the iterator can still advance (i.e., visit more bonds)
    operator bool() const        { return _ptr != NULL; }
    //! Preincrement -- advance to the next bond and return
    OBAtomBondIter& operator++();
    //! Postincrement -- return the current state and advance to the next bond
    OBAtomBondIter  operator++(int);
    //! \return a pointer to the current bond
    OBBond* operator->() const   { return _ptr; }
    //! \return a reference to the current bond
    OBBond& operator*() const    { return *_ptr;}
  };

  //! \brief Iterate over all residues in an OBMol
  class OBAPI OBResidueIter {
    std::vector<OBResidue*>::iterator _i;
    OBResidue *_ptr;
    OBMol *_parent;
  public:

    OBResidueIter() : _ptr(NULL), _parent(NULL) { }
    OBResidueIter(OBMol *mol);
    OBResidueIter(OBMol &mol);
    OBResidueIter(const OBResidueIter &ri);
    ~OBResidueIter() { }

    OBResidueIter& operator=(const OBResidueIter &ri);
    //! \return Whether the iterator can still advance (i.e., visit more residues)
    operator bool() const        { return _ptr != NULL; }
    //! Preincrement -- advance to the next residue and return
    OBResidueIter& operator++();
    //! Postincrement -- return the current state and advance to the next residue
    OBResidueIter  operator++(int);
    //! \return a pointer to the current residue
    OBResidue* operator->() const{ return _ptr; }
    //! \return a reference to the current residue
    OBResidue& operator*() const { return *_ptr;}
  };

  //! \brief Iterate over all atoms in an OBResidue
  class OBAPI OBResidueAtomIter {
    std::vector<OBAtom*>::iterator _i;
    OBResidue *_parent;
    OBAtom    *_ptr;
  public:

    OBResidueAtomIter() : _parent(NULL), _ptr(NULL) { }
    OBResidueAtomIter(OBResidue *res);
    OBResidueAtomIter(OBResidue &res);
    OBResidueAtomIter(const OBResidueAtomIter &ri);
    ~OBResidueAtomIter() { }

    OBResidueAtomIter &operator = (const OBResidueAtomIter &ri);
    //! \return Whether the iterator can still advance (i.e., visit more atoms in this residue)
    operator bool() const        { return _ptr != NULL; }
    //! Preincrement -- advance to the next atom (if any) and return
    OBResidueAtomIter& operator++ ();
    //! Postincrement -- return the current state and advance to the next atom (if any)
    OBResidueAtomIter  operator++ (int);
    //! \return a pointer to the current atom
    OBAtom *operator->() const   { return _ptr; }
    //! \return a reference to the current atom
    OBAtom &operator*() const    { return *_ptr;}
  };

  //! \brief Iterate over all angles in an OBMol
  class OBAPI OBMolAngleIter {
    OBMol     *_parent;
    std::vector<std::vector<unsigned int> > _vangle;
    std::vector<std::vector<unsigned int> >::iterator _i;
    std::vector<unsigned int> _angle;
  public:

    OBMolAngleIter() :_parent(NULL) { }
    OBMolAngleIter(OBMol *mol);
    OBMolAngleIter(OBMol &mol);
    OBMolAngleIter(const OBMolAngleIter &ai);
    ~OBMolAngleIter() { }

    OBMolAngleIter& operator=(const OBMolAngleIter &ai);
    //! \return Whether the iterator can still advance (i.e., visit more angles)
    operator bool() const        { return (_i != _vangle.end()); }
    //! Preincrement -- advance to the next angle and return
    OBMolAngleIter& operator++();
    //! \return A vector of three atom indexes specifying the angle
    //! \see OBAtom::GetIdx()
    std::vector<unsigned int> operator*() const    { return _angle;     }
  };

  //! \brief Iterate over all torsions in an OBMol
  class OBAPI OBMolTorsionIter {
    OBMol *_parent;
    std::vector<std::vector<unsigned int> > _vtorsion;
    std::vector<std::vector<unsigned int> >::iterator _i;
    std::vector<unsigned int> _torsion;
  public:

    OBMolTorsionIter() :_parent(NULL) { }
    OBMolTorsionIter(OBMol *mol);
    OBMolTorsionIter(OBMol &mol);
    OBMolTorsionIter(const OBMolTorsionIter &ai);
    ~OBMolTorsionIter() { }

    OBMolTorsionIter& operator=(const OBMolTorsionIter &ai);
    //! \return Whether the iterator can still advance (i.e., visit more torsions)
    operator bool() const        { return (_i != _vtorsion.end()); }
    //! Preincrement -- advance to the next torsion and return
    OBMolTorsionIter& operator++();
    //! \return A vector of four atom indexes specifying the torsion
    //! \see OBAtom::GetIdx()
    std::vector<unsigned int> operator*() const    { return _torsion;     }
  };

  //! \brief Iterate over all pairs of atoms (>1-4) in an OBMol
  class OBAPI OBMolPairIter {
    std::vector<OBAtom*>::iterator _i;
    std::vector<OBAtom*>::iterator _j;
    OBMol *_parent;
    //std::vector<std::vector<unsigned int> > _vpair;
    //std::vector<std::vector<unsigned int> >::iterator _i;
    std::vector<unsigned int> _pair;

  public:

    OBMolPairIter() :_parent(NULL) { }
    OBMolPairIter(OBMol *mol);
    OBMolPairIter(OBMol &mol);
    OBMolPairIter(const OBMolPairIter &ai);
    ~OBMolPairIter() { }

    OBMolPairIter& operator=(const OBMolPairIter &ai);
    //! \return Whether the iterator can still advance (i.e., visit more 1-4 atom pairs)
    operator bool() const        { return _pair.size()>0; }
    //! Preincrement -- advance to the next 1-4 atom pair and return
    OBMolPairIter& operator++();
    //! \return A vector of two atom indexes specifying the 1-4 atom pair
    //! \see OBAtom::GetIdx()
    std::vector<unsigned int> operator*() const    { return _pair;     }
  };

  class OBRing;
  class OBRingData;

  //! \brief Iterate over all rings in an OBMol
  class OBAPI OBMolRingIter {
    std::vector<OBRing*>::iterator _i;
    OBRing *_ptr;
    OBMol *_parent;
    OBRingData *_rings;
  public:

    OBMolRingIter() : _ptr(NULL), _parent(NULL), _rings(NULL) { }
    OBMolRingIter(OBMol *mol);
    OBMolRingIter(OBMol &mol);
    OBMolRingIter(const OBMolRingIter &ri);
    ~OBMolRingIter() { }

    OBMolRingIter& operator=(const OBMolRingIter &ri);
    //! \return Whether the iterator can advance (i.e., there are more rings)
    operator bool()      const { return _ptr != NULL; }
    //! Preincrement -- advance to the next ring (if any) and return
    OBMolRingIter& operator++();
    //! Postincrement -- return the current state and advance to the next ring
    OBMolRingIter  operator++(int);
    //! \return A pointer to the current ring (if any)
    OBRing* operator->() const { return _ptr; }
    //! \return A reference to the current ring (if any)
    OBRing& operator*()  const { return *_ptr;}
  };

#define FOR_ATOMS_OF_MOL(a,m)     for( OpenBabel::OBMolAtomIter     a(m); a; ++a )
#define FOR_BONDS_OF_MOL(b,m)     for( OpenBabel::OBMolBondIter     b(m); b; ++b )
#define FOR_NBORS_OF_ATOM(a,p)    for( OpenBabel::OBAtomAtomIter    a(p); a; ++a )
#define FOR_BONDS_OF_ATOM(b,p)    for( OpenBabel::OBAtomBondIter    b(p); b; ++b )
#define FOR_RESIDUES_OF_MOL(r,m)  for( OpenBabel::OBResidueIter     r(m); r; ++r )
#define FOR_ATOMS_OF_RESIDUE(a,r) for( OpenBabel::OBResidueAtomIter a(r); a; ++a )
#define FOR_DFS_OF_MOL(a,m)       for( OpenBabel::OBMolAtomDFSIter  a(m); a; ++a )
#define FOR_BFS_OF_MOL(a,m)       for( OpenBabel::OBMolAtomBFSIter  a(m); a; ++a )
#define FOR_BONDBFS_OF_MOL(b,m)   for( OpenBabel::OBMolBondBFSIter  b(m); b; ++b )
#define FOR_RINGS_OF_MOL(r,m)     for( OpenBabel::OBMolRingIter     r(m); r; ++r )
#define FOR_ANGLES_OF_MOL(a,m)    for( OpenBabel::OBMolAngleIter    a(m); a; ++a )
#define FOR_TORSIONS_OF_MOL(t,m)  for( OpenBabel::OBMolTorsionIter  t(m); t; ++t )
#define FOR_PAIRS_OF_MOL(p,m)     for( OpenBabel::OBMolPairIter     p(m); p; ++p )

} // namespace OpenBabel
#endif // OB_OBITER_H

//! \file obiter.h
//! \brief STL-style iterators for Open Babel.