bpp-seq3  3.0.0
AlphabetExceptions.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_SEQ_ALPHABET_ALPHABETEXCEPTIONS_H
6 #define BPP_SEQ_ALPHABET_ALPHABETEXCEPTIONS_H
7 
8 #include <Bpp/Exceptions.h>
9 #include "Alphabet.h"
10 
11 // From the STL:
12 #include <vector>
13 #include <memory>
14 
15 namespace bpp
16 {
23  public Exception
24 {
25 private:
27 
28 public:
35  AlphabetException(const std::string& text, const Alphabet* alpha);
36 
43  AlphabetException(const std::string& text, std::shared_ptr<const Alphabet> alpha);
44 
46  Exception(ae),
48  {}
49 
51  {
52  Exception::operator=(ae);
53  alphabet_ = ae.alphabet_;
54  return *this;
55  }
56 
57  virtual ~AlphabetException() {}
58 
59 public:
65  virtual const Alphabet* getAlphabet() const { return alphabet_; }
66 };
67 
72  public AlphabetException
73 {
74 protected:
75  std::string c_;
76 
77 public:
85  BadCharException(const std::string& badChar, const std::string& text, const Alphabet* alpha);
86 
94  BadCharException(const std::string& badChar, const std::string& text, std::shared_ptr<const Alphabet> alpha);
95 
96  virtual ~BadCharException() {}
97 
98 public:
104  virtual std::string getBadChar() const;
105 };
106 
111  public AlphabetException
112 {
113 protected:
114  int i_;
115 
116 public:
123  BadIntException(int badInt, const std::string& text, const Alphabet* alpha);
124 
131  BadIntException(int badInt, const std::string& text, std::shared_ptr<const Alphabet> alpha);
132 
133  virtual ~BadIntException() {}
134 
135 public:
141  virtual int getBadInt() const;
142 };
143 
151  public Exception
152 {
153 private:
156 
157 public:
166  const std::string& text,
167  const Alphabet* alpha1,
168  const Alphabet* alpha2);
169 
178  const std::string& text,
179  std::shared_ptr<const Alphabet> alpha1,
180  std::shared_ptr<const Alphabet> alpha2);
181 
183  Exception(ame),
184  alphabet1_(ame.alphabet1_),
186  {}
187 
189  {
190  Exception::operator=(ame);
191  alphabet1_ = ame.alphabet1_;
192  alphabet2_ = ame.alphabet2_;
193  return *this;
194  }
195 
196 
198 
199 public:
205  const Alphabet* getFirstAlphabet() const { return alphabet1_; }
206 
212  const Alphabet* getSecondAlphabet() const { return alphabet2_; }
213 };
214 
219  public AlphabetException
220 {
221 public:
228  CharStateNotSupportedException(const std::string& text, const Alphabet* alpha);
229 
236  CharStateNotSupportedException(const std::string& text, std::shared_ptr<const Alphabet> alpha);
237 
239 };
240 } // end of namespace bpp.
241 #endif // BPP_SEQ_ALPHABET_ALPHABETEXCEPTIONS_H
The alphabet exception base class.
AlphabetException(const std::string &text, const Alphabet *alpha)
Build a new AlphabetException object.
const Alphabet * alphabet_
AlphabetException(const AlphabetException &ae)
virtual const Alphabet * getAlphabet() const
Get the alphabet that threw the exception.
AlphabetException & operator=(const AlphabetException &ae)
Exception thrown when two alphabets do not match.
AlphabetMismatchException(const std::string &text, const Alphabet *alpha1, const Alphabet *alpha2)
Build a new AlphabetMismatchException object.
const Alphabet * getSecondAlphabet() const
Get the second alphabet.
AlphabetMismatchException & operator=(const AlphabetMismatchException &ame)
AlphabetMismatchException(const AlphabetMismatchException &ame)
const Alphabet * getFirstAlphabet() const
Get the first alphabet.
The Alphabet interface.
Definition: Alphabet.h:99
An alphabet exception thrown when trying to specify a bad char to the alphabet.
virtual std::string getBadChar() const
Get the character that threw the exception.
BadCharException(const std::string &badChar, const std::string &text, const Alphabet *alpha)
Build a new BadCharException.
An alphabet exception thrown when trying to specify a bad int to the alphabet.
virtual int getBadInt() const
Get the integer that threw the exception.
BadIntException(int badInt, const std::string &text, const Alphabet *alpha)
Build a new BadIntException.
Exception thrown in case no character is available for a certain state in an alphabet.
CharStateNotSupportedException(const std::string &text, const Alphabet *alpha)
Build a new CharStateNotSupportedException.
This alphabet is used to deal NumericAlphabet.