rasdaman complete source
stdexcept.h
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Rasdaman community is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 /
45 #ifndef _D_EXCEPTION_
46 #define _D_EXCEPTION_
47 
48 class exception
49 {
50 public:
51  exception() throw() : errorString(0) {};
52 
53  exception( const char* s ) throw()
54  {
55  errorString = new char[strlen(s)+1];
56  strcpy( errorString, s );
57  };
58 
59  exception( const exception& ex ) throw()
60  {
61  errorString = new char[strlen(ex.what())+1];
62  strcpy( errorString, ex.what() );
63  };
64 
65  ~exception() throw()
66  {
67  if( errorString ) delete[] errorString;
68  };
69 
70  exception& operator=( const exception& ex ) throw()
71  {
72  if( this != &ex )
73  {
74  if( errorString ) delete[] errorString;
75 
76  errorString = new char[strlen(ex.what())+1];
77  strcpy( errorString, ex.what() );
78  }
79  return *this;
80  };
81 
82  inline virtual const char* what() const throw()
83  {
84  return errorString;
85  };
86 
87 private:
88  char* errorString;
89 };
90 
91 
92 class logic_error : public exception
93 {
94 public:
95  logic_error( const char* what_arg ) throw() : exception( what_arg ) {};
96 };
97 
98 
99 class domain_error : public logic_error
100 {
101 public:
102  domain_error( const char* what_arg ) throw() : logic_error( what_arg ) {};
103 };
104 
105 
106 class invalid_argument : public logic_error
107 {
108 public:
109  invalid_argument( const char* what_arg ) throw() : logic_error( what_arg ) {};
110 };
111 
112 
113 class length_error : public logic_error
114 {
115 public:
116  length_error( const char* what_arg ) throw() : logic_error( what_arg ) {};
117 };
118 
119 
120 class out_of_range : public logic_error
121 {
122 public:
123  out_of_range( const char* what_arg ) throw() : logic_error( what_arg ) {};
124 };
125 
126 
127 class runtime_error : public exception
128 {
129 public:
130  runtime_error( const char* what_arg ) throw() : exception( what_arg ) {};
131 };
132 
133 
134 class range_error : public runtime_error
135 {
136 public:
137  range_error( const char* what_arg ) throw() : runtime_error( what_arg ) {};
138 };
139 
140 
141 class overflow_error : public runtime_error
142 {
143 public:
144  overflow_error( const char* what_arg ) throw() : runtime_error( what_arg ) {};
145 };
146 
147 #endif