RDKit
Open-source cheminformatics and machine learning.
SanitException.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2002-2019 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 
11 #include <RDGeneral/export.h>
12 #ifndef RD_SANITEXCEPTION_H
13 #define RD_SANITEXCEPTION_H
14 
15 #include <RDGeneral/types.h>
16 #include <GraphMol/GraphMol.h>
17 #include <GraphMol/Atom.h>
18 #include <GraphMol/Bond.h>
19 
20 #include <string>
21 #include <utility>
22 #include <vector>
23 #include <exception>
24 
25 namespace RDKit {
26 
27 //! class for flagging sanitization errors
28 class RDKIT_GRAPHMOL_EXPORT MolSanitizeException : public std::exception {
29  public:
30  MolSanitizeException(const char *msg) : d_msg(msg) {}
31  MolSanitizeException(std::string msg) : d_msg(std::move(msg)) {}
33  : d_msg(other.d_msg) {}
34  const char *what() const noexcept override { return d_msg.c_str(); }
35  ~MolSanitizeException() noexcept override {}
36  virtual MolSanitizeException *copy() const {
37  return new MolSanitizeException(*this);
38  }
39  virtual std::string getType() const { return "MolSanitizeException"; }
40 
41  protected:
42  std::string d_msg;
43 };
44 
46  : public MolSanitizeException {
47  public:
48  AtomSanitizeException(const char *msg, unsigned int atomIdx)
49  : MolSanitizeException(msg), d_atomIdx(atomIdx) {}
50  AtomSanitizeException(const std::string &msg, unsigned int atomIdx)
51  : MolSanitizeException(msg), d_atomIdx(atomIdx) {}
53  : MolSanitizeException(other), d_atomIdx(other.d_atomIdx) {}
54  unsigned int getAtomIdx() const { return d_atomIdx; }
55  ~AtomSanitizeException() noexcept override {}
56  MolSanitizeException *copy() const override {
57  return new AtomSanitizeException(*this);
58  }
59  std::string getType() const override { return "AtomSanitizeException"; }
60 
61  protected:
62  unsigned int d_atomIdx;
63 };
64 
66  : public AtomSanitizeException {
67  public:
68  AtomValenceException(const char *msg, unsigned int atomIdx)
69  : AtomSanitizeException(msg, atomIdx) {}
70  AtomValenceException(const std::string &msg, unsigned int atomIdx)
71  : AtomSanitizeException(msg, atomIdx) {}
73  : AtomSanitizeException(other) {}
74  ~AtomValenceException() noexcept override {}
75  MolSanitizeException *copy() const override {
76  return new AtomValenceException(*this);
77  }
78  std::string getType() const override { return "AtomValenceException"; }
79 };
80 
82  : public AtomSanitizeException {
83  public:
84  AtomKekulizeException(const char *msg, unsigned int atomIdx)
85  : AtomSanitizeException(msg, atomIdx) {}
86  AtomKekulizeException(const std::string &msg, unsigned int atomIdx)
87  : AtomSanitizeException(msg, atomIdx) {}
89  : AtomSanitizeException(other) {}
90  ~AtomKekulizeException() noexcept override {}
91  MolSanitizeException *copy() const override {
92  return new AtomKekulizeException(*this);
93  }
94  std::string getType() const override { return "AtomKekulizeException"; }
95 };
96 
98  public:
99  KekulizeException(const char *msg, std::vector<unsigned int> indices)
100  : MolSanitizeException(msg), d_atomIndices(std::move(indices)) {}
101  KekulizeException(const std::string &msg, std::vector<unsigned int> indices)
102  : MolSanitizeException(msg), d_atomIndices(std::move(indices)) {}
104  : MolSanitizeException(other), d_atomIndices(other.d_atomIndices) {}
105  const std::vector<unsigned int> &getAtomIndices() const {
106  return d_atomIndices;
107  }
108  ~KekulizeException() noexcept override {}
109  MolSanitizeException *copy() const override {
110  return new KekulizeException(*this);
111  }
112  std::string getType() const override { return "KekulizeException"; }
113 
114  protected:
115  std::vector<unsigned int> d_atomIndices;
116 };
117 
118 } // namespace RDKit
119 
120 #endif
Defines the Atom class and associated typedefs.
pulls in RWMol and ROMol
AtomKekulizeException(const std::string &msg, unsigned int atomIdx)
~AtomKekulizeException() noexcept override
AtomKekulizeException(const char *msg, unsigned int atomIdx)
std::string getType() const override
AtomKekulizeException(const AtomKekulizeException &other)
MolSanitizeException * copy() const override
unsigned int getAtomIdx() const
AtomSanitizeException(const AtomSanitizeException &other)
MolSanitizeException * copy() const override
~AtomSanitizeException() noexcept override
AtomSanitizeException(const std::string &msg, unsigned int atomIdx)
AtomSanitizeException(const char *msg, unsigned int atomIdx)
std::string getType() const override
AtomValenceException(const char *msg, unsigned int atomIdx)
AtomValenceException(const std::string &msg, unsigned int atomIdx)
MolSanitizeException * copy() const override
~AtomValenceException() noexcept override
std::string getType() const override
AtomValenceException(const AtomValenceException &other)
KekulizeException(const KekulizeException &other)
std::string getType() const override
std::vector< unsigned int > d_atomIndices
const std::vector< unsigned int > & getAtomIndices() const
~KekulizeException() noexcept override
KekulizeException(const char *msg, std::vector< unsigned int > indices)
KekulizeException(const std::string &msg, std::vector< unsigned int > indices)
MolSanitizeException * copy() const override
class for flagging sanitization errors
MolSanitizeException(std::string msg)
MolSanitizeException(const MolSanitizeException &other)
~MolSanitizeException() noexcept override
virtual std::string getType() const
virtual MolSanitizeException * copy() const
const char * what() const noexcept override
MolSanitizeException(const char *msg)
#define RDKIT_GRAPHMOL_EXPORT
Definition: export.h:209
Std stuff.
Definition: Abbreviations.h:18