]>
Commit | Line | Data |
---|---|---|
6599da04 JM |
1 | // Methods for Exception Support for -*- C++ -*- |
2 | // Copyright (C) 1994, 1995, 1997 Free Software Foundation | |
3 | ||
4 | // This file is part of the GNU ANSI C++ Library. This library is free | |
5 | // software; you can redistribute it and/or modify it under the | |
6 | // terms of the GNU General Public License as published by the | |
7 | // Free Software Foundation; either version 2, or (at your option) | |
8 | // any later version. | |
9 | ||
10 | // This library is distributed in the hope that it will be useful, | |
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | // GNU General Public License for more details. | |
14 | ||
15 | // You should have received a copy of the GNU General Public License | |
16 | // along with this library; see the file COPYING. If not, write to the Free | |
17 | // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 | ||
19 | // As a special exception, if you link this library with files | |
20 | // compiled with a GNU compiler to produce an executable, this does not cause | |
21 | // the resulting executable to be covered by the GNU General Public License. | |
22 | // This exception does not however invalidate any other reasons why | |
23 | // the executable file might be covered by the GNU General Public License. | |
24 | ||
25 | // Written by Mike Stump based upon the specification in the 20 September 1994 | |
26 | // C++ working paper, ANSI document X3J16/94-0158. | |
27 | ||
28 | #ifndef __STDEXCEPT__ | |
29 | #define __STDEXCEPT__ | |
30 | ||
31 | #ifdef __GNUG__ | |
32 | #pragma interface "stdexcept" | |
33 | #endif | |
34 | ||
35 | #include <exception> | |
36 | #include <string> | |
37 | ||
38 | extern "C++" { | |
39 | ||
ef109057 | 40 | namespace std { |
ef109057 | 41 | |
6599da04 JM |
42 | class logic_error : public exception { |
43 | string _what; | |
44 | public: | |
45 | logic_error(const string& what_arg): _what (what_arg) { } | |
46 | virtual const char* what () const { return _what.c_str (); } | |
47 | }; | |
48 | ||
49 | class domain_error : public logic_error { | |
50 | public: | |
51 | domain_error (const string& what_arg): logic_error (what_arg) { } | |
52 | }; | |
53 | ||
54 | class invalid_argument : public logic_error { | |
55 | public: | |
56 | invalid_argument (const string& what_arg): logic_error (what_arg) { } | |
57 | }; | |
58 | ||
59 | class length_error : public logic_error { | |
60 | public: | |
61 | length_error (const string& what_arg): logic_error (what_arg) { } | |
62 | }; | |
63 | ||
64 | class out_of_range : public logic_error { | |
65 | public: | |
66 | out_of_range (const string& what_arg): logic_error (what_arg) { } | |
67 | }; | |
68 | ||
69 | class runtime_error : public exception { | |
70 | string _what; | |
71 | public: | |
72 | runtime_error(const string& what_arg): _what (what_arg) { } | |
73 | virtual const char* what () const { return _what.c_str (); } | |
74 | protected: | |
75 | runtime_error(): exception () { } | |
76 | }; | |
77 | ||
78 | class range_error : public runtime_error { | |
79 | public: | |
80 | range_error (const string& what_arg): runtime_error (what_arg) { } | |
81 | }; | |
82 | ||
83 | class overflow_error : public runtime_error { | |
84 | public: | |
85 | overflow_error (const string& what_arg): runtime_error (what_arg) { } | |
86 | }; | |
87 | ||
88 | class underflow_error : public runtime_error { | |
89 | public: | |
90 | underflow_error (const string& what_arg): runtime_error (what_arg) { } | |
91 | }; | |
92 | ||
ef109057 | 93 | } // namespace std |
ef109057 | 94 | |
6599da04 JM |
95 | } // extern "C++" |
96 | ||
97 | #endif |