bpp-core  2.2.0
Exceptions.cpp
Go to the documentation of this file.
1 //
2 // File Exceptions.cpp
3 // Created by: Guillaume Deuchst
4 // Julien Dutheil
5 // Sylvain Gaillard
6 // Last modification : Thu Jul 22 2004
7 //
8 
9 /*
10 Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)
11 
12 This software is a computer program whose purpose is to provide utilitary
13 classes. This file belongs to the Bio++ Project.
14 
15 This software is governed by the CeCILL license under French law and
16 abiding by the rules of distribution of free software. You can use,
17 modify and/ or redistribute the software under the terms of the CeCILL
18 license as circulated by CEA, CNRS and INRIA at the following URL
19 "http://www.cecill.info".
20 
21 As a counterpart to the access to the source code and rights to copy,
22 modify and redistribute granted by the license, users are provided only
23 with a limited warranty and the software's author, the holder of the
24 economic rights, and the successive licensors have only limited
25 liability.
26 
27 In this respect, the user's attention is drawn to the risks associated
28 with loading, using, modifying and/or developing or reproducing the
29 software by the user in light of its specific status of free software,
30 that may mean that it is complicated to manipulate, and that also
31 therefore means that it is reserved for developers and experienced
32 professionals having in-depth computer knowledge. Users are therefore
33 encouraged to load and test the software's suitability as regards their
34 requirements in conditions enabling the security of their systems and/or
35 data to be ensured and, more generally, to use and operate it in the
36 same conditions as regards security.
37 
38 The fact that you are presently reading this means that you have had
39 knowledge of the CeCILL license and that you accept its terms.
40 */
41 
42 #include "Exceptions.h"
43 #include "Text/TextTools.h"
44 
45 using namespace bpp;
46 using namespace std;
47 
48 /******************************************************************************/
49 
50 BadIntegerException::BadIntegerException(const char* text, int badInt):
51  Exception(string(text) + "(" + TextTools::toString(badInt) + ")"),
52  badInt_(badInt) {}
53 
54 BadIntegerException::BadIntegerException(const std::string& text, int badInt):
55  Exception(text + "(" + TextTools::toString(badInt) + ")"),
56  badInt_(badInt) {}
57 
58 /******************************************************************************/
59 
60 BadNumberException::BadNumberException(const char* text, double badNumber):
61  Exception(string(text) + "(" + TextTools::toString(badNumber) + ")"),
62  badNumber_(badNumber) {}
63 
64 BadNumberException::BadNumberException(const std::string& text, double badNumber):
65  Exception(text + "(" + TextTools::toString(badNumber) + ")"),
66  badNumber_(badNumber) {}
67 
68 /******************************************************************************/
69 
70 NumberFormatException::NumberFormatException(const char* text, const std::string& badNumber):
71  Exception(string(text) + "(" + badNumber + ")"),
72  badNumber_(badNumber) {}
73 
74 NumberFormatException::NumberFormatException(const std::string& text, const std::string& badNumber):
75  Exception(text + "(" + badNumber + ")"),
76  badNumber_(badNumber) {}
77 
78 /******************************************************************************/
79 
80 IndexOutOfBoundsException::IndexOutOfBoundsException(const std::string& text, size_t badInt, size_t lowerBound, size_t upperBound):
81  Exception("out of [" + TextTools::toString(lowerBound) + ", " + TextTools::toString(upperBound) + "])" + text),
82  badIndex_(badInt),
83  lowerBound_(lowerBound),
84  upperBound_(upperBound) {}
85 
87 {
88  vector<size_t> bounds(2);
89  bounds[0] = lowerBound_;
90  bounds[1] = upperBound_;
91  return bounds;
92 }
93 
94 /******************************************************************************/
95 
96 BadSizeException::BadSizeException(const std::string& text, size_t badSize, size_t correctSize):
97  Exception("Incorrect size " + TextTools::toString(badSize) + ", expected " + TextTools::toString(correctSize) + ". " + text),
98  badSize_(badSize),
99  correctSize_(correctSize) {}
100 
101 /******************************************************************************/
102 
103 OutOfRangeException::OutOfRangeException(const std::string& text, double badValue, double lowerBound, double upperBound):
104  Exception(TextTools::toString(badValue) + " out of [" + TextTools::toString(lowerBound) + ", " + TextTools::toString(upperBound) + "])" + text),
105  lowerBound_(lowerBound),
106  upperBound_(upperBound)
107 {}
108 
109 /******************************************************************************/
110 
OutOfRangeException(const std::string &text, double badValue, double lowerBound, double upperBound)
Build a new OutOfRangeException.
Definition: Exceptions.cpp:103
This class allows to perform a correspondence analysis.
STL namespace.
std::vector< size_t > getBounds() const
Get the bounds.
Definition: Exceptions.cpp:86
IndexOutOfBoundsException(const std::string &text, size_t badInt, size_t lowerBound, size_t upperBound)
Build a new IndexOutOfBoundsException.
Definition: Exceptions.cpp:80
BadSizeException(const std::string &text, size_t badSize, size_t correctSize)
Build a new BadSizeException.
Definition: Exceptions.cpp:96
BadIntegerException(const char *text, int badInt)
Build a new BadIntegerException.
Definition: Exceptions.cpp:50
Exception base class.
Definition: Exceptions.h:57
NumberFormatException(const char *text, const std::string &badNumber)
Build a new NumberFormatException.
Definition: Exceptions.cpp:70
BadNumberException(const char *text, double badNumber)
Build a new BadNumberException.
Definition: Exceptions.cpp:60
Some utilitary functions that work on strings.
Definition: TextTools.h:58