Coverage Report

Created: 2026-03-31 06:50

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/rdkit/Code/Query/OrQuery.h
Line
Count
Source
1
//
2
// Copyright (c) 2003-2020 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
#include <RDGeneral/export.h>
11
#ifndef RD_ORQUERY_H
12
#define RD_ORQUERY_H
13
14
#include "Query.h"
15
16
namespace Queries {
17
//! a Query implementing AND: requires any child to be \c true
18
template <class MatchFuncArgType, class DataFuncArgType = MatchFuncArgType,
19
          bool needsConversion = false>
20
class RDKIT_QUERY_EXPORT OrQuery
21
    : public Query<MatchFuncArgType, DataFuncArgType, needsConversion> {
22
 public:
23
  typedef Query<MatchFuncArgType, DataFuncArgType, needsConversion> BASE;
24
47.9k
  OrQuery() { this->df_negate = false; }
Queries::OrQuery<int, RDKit::Atom const*, true>::OrQuery()
Line
Count
Source
24
41.8k
  OrQuery() { this->df_negate = false; }
Queries::OrQuery<int, RDKit::Bond const*, true>::OrQuery()
Line
Count
Source
24
6.08k
  OrQuery() { this->df_negate = false; }
25
26
5.99M
  bool Match(const DataFuncArgType what) const override {
27
5.99M
    bool res = false;
28
5.99M
    typename BASE::CHILD_VECT_CI it1;
29
37.3M
    for (it1 = this->beginChildren(); it1 != this->endChildren(); ++it1) {
30
37.3M
      bool tmp = (*it1)->Match(what);
31
37.3M
      if (tmp) {
32
5.92M
        res = true;
33
5.92M
        break;
34
5.92M
      }
35
37.3M
    }
36
5.99M
    if (this->getNegation()) {
37
5.99M
      res = !res;
38
5.99M
    }
39
5.99M
    return res;
40
5.99M
  }
Queries::OrQuery<int, RDKit::Atom const*, true>::Match(RDKit::Atom const*) const
Line
Count
Source
26
5.99M
  bool Match(const DataFuncArgType what) const override {
27
5.99M
    bool res = false;
28
5.99M
    typename BASE::CHILD_VECT_CI it1;
29
37.3M
    for (it1 = this->beginChildren(); it1 != this->endChildren(); ++it1) {
30
37.3M
      bool tmp = (*it1)->Match(what);
31
37.3M
      if (tmp) {
32
5.92M
        res = true;
33
5.92M
        break;
34
5.92M
      }
35
37.3M
    }
36
5.99M
    if (this->getNegation()) {
37
5.99M
      res = !res;
38
5.99M
    }
39
5.99M
    return res;
40
5.99M
  }
Unexecuted instantiation: Queries::OrQuery<int, RDKit::Bond const*, true>::Match(RDKit::Bond const*) const
41
42
  Query<MatchFuncArgType, DataFuncArgType, needsConversion> *copy()
43
35.7k
      const override {
44
35.7k
    OrQuery<MatchFuncArgType, DataFuncArgType, needsConversion> *res =
45
35.7k
        new OrQuery<MatchFuncArgType, DataFuncArgType, needsConversion>();
46
47
35.7k
    typename BASE::CHILD_VECT_CI i;
48
218k
    for (i = this->beginChildren(); i != this->endChildren(); ++i) {
49
183k
      res->addChild(typename BASE::CHILD_TYPE(i->get()->copy()));
50
183k
    }
51
35.7k
    res->setNegation(this->getNegation());
52
35.7k
    res->d_description = this->d_description;
53
35.7k
    res->d_queryType = this->d_queryType;
54
35.7k
    return res;
55
35.7k
  }
Queries::OrQuery<int, RDKit::Atom const*, true>::copy() const
Line
Count
Source
43
32.6k
      const override {
44
32.6k
    OrQuery<MatchFuncArgType, DataFuncArgType, needsConversion> *res =
45
32.6k
        new OrQuery<MatchFuncArgType, DataFuncArgType, needsConversion>();
46
47
32.6k
    typename BASE::CHILD_VECT_CI i;
48
209k
    for (i = this->beginChildren(); i != this->endChildren(); ++i) {
49
176k
      res->addChild(typename BASE::CHILD_TYPE(i->get()->copy()));
50
176k
    }
51
32.6k
    res->setNegation(this->getNegation());
52
32.6k
    res->d_description = this->d_description;
53
32.6k
    res->d_queryType = this->d_queryType;
54
32.6k
    return res;
55
32.6k
  }
Queries::OrQuery<int, RDKit::Bond const*, true>::copy() const
Line
Count
Source
43
3.10k
      const override {
44
3.10k
    OrQuery<MatchFuncArgType, DataFuncArgType, needsConversion> *res =
45
3.10k
        new OrQuery<MatchFuncArgType, DataFuncArgType, needsConversion>();
46
47
3.10k
    typename BASE::CHILD_VECT_CI i;
48
9.30k
    for (i = this->beginChildren(); i != this->endChildren(); ++i) {
49
6.20k
      res->addChild(typename BASE::CHILD_TYPE(i->get()->copy()));
50
6.20k
    }
51
3.10k
    res->setNegation(this->getNegation());
52
3.10k
    res->d_description = this->d_description;
53
3.10k
    res->d_queryType = this->d_queryType;
54
3.10k
    return res;
55
3.10k
  }
56
};
57
}  // namespace Queries
58
#endif