RDKit: SanitException.h Source File

| 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
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)) {}
32 MolSanitizeException(const MolSanitizeException &other)
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
45 class RDKIT_GRAPHMOL_EXPORT AtomSanitizeException
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) {}
52 AtomSanitizeException(const AtomSanitizeException &other)
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
65 class RDKIT_GRAPHMOL_EXPORT AtomValenceException
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) {}
72 AtomValenceException(const AtomValenceException &other)
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
81 class RDKIT_GRAPHMOL_EXPORT AtomKekulizeException
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) {}
88 AtomKekulizeException(const AtomKekulizeException &other)
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
97 class RDKIT_GRAPHMOL_EXPORT KekulizeException : public MolSanitizeException {
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)) {}
103 KekulizeException(const KekulizeException &other)
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
Atom.h
Defines the Atom class and associated typedefs.
Bond.h
GraphMol.h
pulls in RWMol and ROMol
RDKit::AtomKekulizeException::AtomKekulizeException
AtomKekulizeException(const std::string &msg, unsigned int atomIdx)
Definition SanitException.h:86
RDKit::AtomKekulizeException::~AtomKekulizeException
~AtomKekulizeException() noexcept override
Definition SanitException.h:90
RDKit::AtomKekulizeException::copy
MolSanitizeException * copy() const override
Definition SanitException.h:91
RDKit::AtomKekulizeException::AtomKekulizeException
AtomKekulizeException(const char *msg, unsigned int atomIdx)
Definition SanitException.h:84
RDKit::AtomKekulizeException::getType
std::string getType() const override
Definition SanitException.h:94
RDKit::AtomKekulizeException::AtomKekulizeException
AtomKekulizeException(const AtomKekulizeException &other)
Definition SanitException.h:88
RDKit::AtomSanitizeException::getAtomIdx
unsigned int getAtomIdx() const
Definition SanitException.h:54
RDKit::AtomSanitizeException::copy
MolSanitizeException * copy() const override
Definition SanitException.h:56
RDKit::AtomSanitizeException::AtomSanitizeException
AtomSanitizeException(const AtomSanitizeException &other)
Definition SanitException.h:52
RDKit::AtomSanitizeException::~AtomSanitizeException
~AtomSanitizeException() noexcept override
Definition SanitException.h:55
RDKit::AtomSanitizeException::d_atomIdx
unsigned int d_atomIdx
Definition SanitException.h:62
RDKit::AtomSanitizeException::AtomSanitizeException
AtomSanitizeException(const std::string &msg, unsigned int atomIdx)
Definition SanitException.h:50
RDKit::AtomSanitizeException::AtomSanitizeException
AtomSanitizeException(const char *msg, unsigned int atomIdx)
Definition SanitException.h:48
RDKit::AtomSanitizeException::getType
std::string getType() const override
Definition SanitException.h:59
RDKit::AtomValenceException::AtomValenceException
AtomValenceException(const char *msg, unsigned int atomIdx)
Definition SanitException.h:68
RDKit::AtomValenceException::copy
MolSanitizeException * copy() const override
Definition SanitException.h:75
RDKit::AtomValenceException::AtomValenceException
AtomValenceException(const std::string &msg, unsigned int atomIdx)
Definition SanitException.h:70
RDKit::AtomValenceException::~AtomValenceException
~AtomValenceException() noexcept override
Definition SanitException.h:74
RDKit::AtomValenceException::getType
std::string getType() const override
Definition SanitException.h:78
RDKit::AtomValenceException::AtomValenceException
AtomValenceException(const AtomValenceException &other)
Definition SanitException.h:72
RDKit::KekulizeException::KekulizeException
KekulizeException(const KekulizeException &other)
Definition SanitException.h:103
RDKit::KekulizeException::getAtomIndices
const std::vector< unsigned int > & getAtomIndices() const
Definition SanitException.h:105
RDKit::KekulizeException::getType
std::string getType() const override
Definition SanitException.h:112
RDKit::KekulizeException::d_atomIndices
std::vector< unsigned int > d_atomIndices
Definition SanitException.h:115
RDKit::KekulizeException::~KekulizeException
~KekulizeException() noexcept override
Definition SanitException.h:108
RDKit::KekulizeException::KekulizeException
KekulizeException(const char *msg, std::vector< unsigned int > indices)
Definition SanitException.h:99
RDKit::KekulizeException::KekulizeException
KekulizeException(const std::string &msg, std::vector< unsigned int > indices)
Definition SanitException.h:101
RDKit::KekulizeException::copy
MolSanitizeException * copy() const override
Definition SanitException.h:109
RDKit::MolSanitizeException
class for flagging sanitization errors
Definition SanitException.h:28
RDKit::MolSanitizeException::what
const char * what() const noexcept override
Definition SanitException.h:34
RDKit::MolSanitizeException::copy
virtual MolSanitizeException * copy() const
Definition SanitException.h:36
RDKit::MolSanitizeException::MolSanitizeException
MolSanitizeException(std::string msg)
Definition SanitException.h:31
RDKit::MolSanitizeException::MolSanitizeException
MolSanitizeException(const MolSanitizeException &other)
Definition SanitException.h:32
RDKit::MolSanitizeException::~MolSanitizeException
~MolSanitizeException() noexcept override
Definition SanitException.h:35
RDKit::MolSanitizeException::getType
virtual std::string getType() const
Definition SanitException.h:39
RDKit::MolSanitizeException::d_msg
std::string d_msg
Definition SanitException.h:42
RDKit::MolSanitizeException::MolSanitizeException
MolSanitizeException(const char *msg)
Definition SanitException.h:30
export.h
RDKIT_GRAPHMOL_EXPORT
#define RDKIT_GRAPHMOL_EXPORT
Definition export.h:249
RDKit
Std stuff.
Definition Abbreviations.h:19
types.h