OSDN Git Service

Initial revision
[pf3gnuchains/gcc-fork.git] / libstdc++ / stdexcept
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
40 class logic_error : public exception {
41   string _what;
42 public:
43   logic_error(const string& what_arg): _what (what_arg) { }
44   virtual const char* what () const { return _what.c_str (); }
45 };
46
47 class domain_error : public logic_error {
48 public:
49   domain_error (const string& what_arg): logic_error (what_arg) { }
50 };
51
52 class invalid_argument : public logic_error {
53 public:
54   invalid_argument (const string& what_arg): logic_error (what_arg) { }
55 };
56
57 class length_error : public logic_error {
58 public:
59   length_error (const string& what_arg): logic_error (what_arg) { }
60 };
61
62 class out_of_range : public logic_error {
63 public:
64   out_of_range (const string& what_arg): logic_error (what_arg) { }
65 };
66
67 class runtime_error : public exception {
68   string _what;
69 public:
70   runtime_error(const string& what_arg): _what (what_arg) { }
71   virtual const char* what () const { return _what.c_str (); }
72 protected:
73   runtime_error(): exception () { }
74 };
75
76 class range_error : public runtime_error {
77 public:
78   range_error (const string& what_arg): runtime_error (what_arg) { }
79 };
80
81 class overflow_error : public runtime_error {
82 public:
83   overflow_error (const string& what_arg): runtime_error (what_arg) { }
84 };
85
86 class underflow_error : public runtime_error {
87 public:
88   underflow_error (const string& what_arg): runtime_error (what_arg) { }
89 };
90
91 } // extern "C++"
92
93 #endif