RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
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
25namespace RDKit {
26
27//! class for flagging sanitization errors
28class 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) {}
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) {}
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
MolSanitizeException * copy() const override
AtomKekulizeException(const char *msg, unsigned int atomIdx)
std::string getType() const override
AtomKekulizeException(const AtomKekulizeException &other)
unsigned int getAtomIdx() const
MolSanitizeException * copy() const override
AtomSanitizeException(const AtomSanitizeException &other)
~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)
MolSanitizeException * copy() const override
AtomValenceException(const std::string &msg, unsigned int atomIdx)
~AtomValenceException() noexcept override
std::string getType() const override
AtomValenceException(const AtomValenceException &other)
KekulizeException(const KekulizeException &other)
const std::vector< unsigned int > & getAtomIndices() const
std::string getType() const override
std::vector< unsigned int > d_atomIndices
~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
const char * what() const noexcept override
virtual MolSanitizeException * copy() const
MolSanitizeException(std::string msg)
MolSanitizeException(const MolSanitizeException &other)
~MolSanitizeException() noexcept override
virtual std::string getType() const
MolSanitizeException(const char *msg)
#define RDKIT_GRAPHMOL_EXPORT
Definition export.h:233
Std stuff.