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 <vector>
22 #include <exception>
23 
24 namespace RDKit {
25 
26 //! class for flagging sanitization errors
27 class RDKIT_GRAPHMOL_EXPORT MolSanitizeException : public std::exception {
28  public:
29  MolSanitizeException(const char *msg) : d_msg(msg){};
30  MolSanitizeException(const std::string &msg) : d_msg(msg){};
32  : d_msg(other.d_msg){};
33  virtual const char *message() const { return d_msg.c_str(); };
34  virtual ~MolSanitizeException() throw(){};
35  virtual MolSanitizeException *copy() const {
36  return new MolSanitizeException(*this);
37  };
38  virtual std::string getType() const { return "MolSanitizeException"; };
39 
40  protected:
41  std::string d_msg;
42 };
43 
45  : public MolSanitizeException {
46  public:
47  AtomSanitizeException(const char *msg, unsigned int atomIdx)
48  : MolSanitizeException(msg), d_atomIdx(atomIdx){};
49  AtomSanitizeException(const std::string &msg, unsigned int atomIdx)
50  : MolSanitizeException(msg), d_atomIdx(atomIdx){};
52  : MolSanitizeException(other), d_atomIdx(other.d_atomIdx){};
53  unsigned int getAtomIdx() const { return d_atomIdx; };
54  virtual ~AtomSanitizeException() throw(){};
55  virtual MolSanitizeException *copy() const {
56  return new AtomSanitizeException(*this);
57  };
58  virtual std::string getType() const { return "AtomSanitizeException"; };
59 
60  protected:
61  unsigned int d_atomIdx;
62 };
63 
65  : public AtomSanitizeException {
66  public:
67  AtomValenceException(const char *msg, unsigned int atomIdx)
68  : AtomSanitizeException(msg, atomIdx){};
69  AtomValenceException(const std::string &msg, unsigned int atomIdx)
70  : AtomSanitizeException(msg, atomIdx){};
72  : AtomSanitizeException(other){};
73  virtual ~AtomValenceException() throw(){};
75  return new AtomValenceException(*this);
76  };
77  std::string getType() const { return "AtomValenceException"; };
78 };
79 
81  : public AtomSanitizeException {
82  public:
83  AtomKekulizeException(const char *msg, unsigned int atomIdx)
84  : AtomSanitizeException(msg, atomIdx){};
85  AtomKekulizeException(const std::string &msg, unsigned int atomIdx)
86  : AtomSanitizeException(msg, atomIdx){};
88  : AtomSanitizeException(other){};
89  virtual ~AtomKekulizeException() throw(){};
91  return new AtomKekulizeException(*this);
92  };
93  std::string getType() const { return "AtomKekulizeException"; };
94 };
95 
97  public:
98  KekulizeException(const char *msg, const std::vector<unsigned int> &indices)
99  : MolSanitizeException(msg), d_atomIndices(indices){};
100  KekulizeException(const std::string &msg,
101  const std::vector<unsigned int> &indices)
102  : MolSanitizeException(msg), d_atomIndices(indices){};
104  : MolSanitizeException(other), d_atomIndices(other.d_atomIndices){};
105  const std::vector<unsigned int> &getAtomIndices() const {
106  return d_atomIndices;
107  };
108  virtual ~KekulizeException() throw(){};
109  MolSanitizeException *copy() const { return new KekulizeException(*this); };
110  std::string getType() const { return "KekulizeException"; };
111 
112  protected:
113  std::vector<unsigned int> d_atomIndices;
114 };
115 
116 } // namespace RDKit
117 
118 #endif
AtomKekulizeException(const char *msg, unsigned int atomIdx)
AtomSanitizeException(const char *msg, unsigned int atomIdx)
class for flagging sanitization errors
virtual MolSanitizeException * copy() const
KekulizeException(const std::string &msg, const std::vector< unsigned int > &indices)
AtomKekulizeException(const std::string &msg, unsigned int atomIdx)
AtomSanitizeException(const AtomSanitizeException &other)
std::string getType() const
AtomKekulizeException(const AtomKekulizeException &other)
#define RDKIT_GRAPHMOL_EXPORT
Definition: export.h:307
virtual MolSanitizeException * copy() const
MolSanitizeException * copy() const
MolSanitizeException * copy() const
KekulizeException(const char *msg, const std::vector< unsigned int > &indices)
virtual std::string getType() const
pulls in RWMol and ROMol
Std stuff.
Definition: Atom.h:30
std::string getType() const
unsigned int getAtomIdx() const
virtual std::string getType() const
const std::vector< unsigned int > & getAtomIndices() const
AtomValenceException(const AtomValenceException &other)
virtual const char * message() const
MolSanitizeException(const std::string &msg)
AtomSanitizeException(const std::string &msg, unsigned int atomIdx)
MolSanitizeException(const MolSanitizeException &other)
Defines the Atom class and associated typedefs.
MolSanitizeException * copy() const
KekulizeException(const KekulizeException &other)
AtomValenceException(const char *msg, unsigned int atomIdx)
AtomValenceException(const std::string &msg, unsigned int atomIdx)
std::string getType() const
MolSanitizeException(const char *msg)