File: SanitException.h

package info (click to toggle)
rdkit 202009.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 129,624 kB
  • sloc: cpp: 288,030; python: 75,571; java: 6,999; ansic: 5,481; sql: 1,968; yacc: 1,842; lex: 1,254; makefile: 572; javascript: 461; xml: 229; fortran: 183; sh: 134; cs: 93
file content (118 lines) | stat: -rw-r--r-- 4,180 bytes parent folder | download
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
//
//  Copyright (C) 2002-2019 Greg Landrum and Rational Discovery LLC
//
//   @@ All Rights Reserved @@
//  This file is part of the RDKit.
//  The contents are covered by the terms of the BSD license
//  which is included in the file license.txt, found at the root
//  of the RDKit source tree.
//

#include <RDGeneral/export.h>
#ifndef RD_SANITEXCEPTION_H
#define RD_SANITEXCEPTION_H

#include <RDGeneral/types.h>
#include <GraphMol/GraphMol.h>
#include <GraphMol/Atom.h>
#include <GraphMol/Bond.h>

#include <string>
#include <vector>
#include <exception>

namespace RDKit {

//! class for flagging sanitization errors
class RDKIT_GRAPHMOL_EXPORT MolSanitizeException : public std::exception {
 public:
  MolSanitizeException(const char *msg) : d_msg(msg){};
  MolSanitizeException(const std::string &msg) : d_msg(msg){};
  MolSanitizeException(const MolSanitizeException &other)
      : d_msg(other.d_msg){};
  virtual const char *what() const noexcept override { return d_msg.c_str(); };
  virtual ~MolSanitizeException() noexcept {};
  virtual MolSanitizeException *copy() const {
    return new MolSanitizeException(*this);
  };
  virtual std::string getType() const { return "MolSanitizeException"; };

 protected:
  std::string d_msg;
};

class RDKIT_GRAPHMOL_EXPORT AtomSanitizeException
    : public MolSanitizeException {
 public:
  AtomSanitizeException(const char *msg, unsigned int atomIdx)
      : MolSanitizeException(msg), d_atomIdx(atomIdx){};
  AtomSanitizeException(const std::string &msg, unsigned int atomIdx)
      : MolSanitizeException(msg), d_atomIdx(atomIdx){};
  AtomSanitizeException(const AtomSanitizeException &other)
      : MolSanitizeException(other), d_atomIdx(other.d_atomIdx){};
  unsigned int getAtomIdx() const { return d_atomIdx; };
  virtual ~AtomSanitizeException() noexcept {};
  virtual MolSanitizeException *copy() const {
    return new AtomSanitizeException(*this);
  };
  virtual std::string getType() const { return "AtomSanitizeException"; };

 protected:
  unsigned int d_atomIdx;
};

class RDKIT_GRAPHMOL_EXPORT AtomValenceException
    : public AtomSanitizeException {
 public:
  AtomValenceException(const char *msg, unsigned int atomIdx)
      : AtomSanitizeException(msg, atomIdx){};
  AtomValenceException(const std::string &msg, unsigned int atomIdx)
      : AtomSanitizeException(msg, atomIdx){};
  AtomValenceException(const AtomValenceException &other)
      : AtomSanitizeException(other){};
  virtual ~AtomValenceException() noexcept {};
  MolSanitizeException *copy() const {
    return new AtomValenceException(*this);
  };
  std::string getType() const { return "AtomValenceException"; };
};

class RDKIT_GRAPHMOL_EXPORT AtomKekulizeException
    : public AtomSanitizeException {
 public:
  AtomKekulizeException(const char *msg, unsigned int atomIdx)
      : AtomSanitizeException(msg, atomIdx){};
  AtomKekulizeException(const std::string &msg, unsigned int atomIdx)
      : AtomSanitizeException(msg, atomIdx){};
  AtomKekulizeException(const AtomKekulizeException &other)
      : AtomSanitizeException(other){};
  virtual ~AtomKekulizeException() noexcept {};
  MolSanitizeException *copy() const {
    return new AtomKekulizeException(*this);
  };
  std::string getType() const { return "AtomKekulizeException"; };
};

class RDKIT_GRAPHMOL_EXPORT KekulizeException : public MolSanitizeException {
 public:
  KekulizeException(const char *msg, const std::vector<unsigned int> &indices)
      : MolSanitizeException(msg), d_atomIndices(indices){};
  KekulizeException(const std::string &msg,
                    const std::vector<unsigned int> &indices)
      : MolSanitizeException(msg), d_atomIndices(indices){};
  KekulizeException(const KekulizeException &other)
      : MolSanitizeException(other), d_atomIndices(other.d_atomIndices){};
  const std::vector<unsigned int> &getAtomIndices() const {
    return d_atomIndices;
  };
  virtual ~KekulizeException() noexcept {};
  MolSanitizeException *copy() const { return new KekulizeException(*this); };
  std::string getType() const { return "KekulizeException"; };

 protected:
  std::vector<unsigned int> d_atomIndices;
};

}  // namespace RDKit

#endif