1 stdexcept |
1 /* |
|
2 * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved. |
|
3 * |
|
4 * Copyright (c) 1996,1997 |
|
5 * Silicon Graphics Computer Systems, Inc. |
|
6 * |
|
7 * Copyright (c) 1999 |
|
8 * Boris Fomitchev |
|
9 * |
|
10 * This material is provided "as is", with absolutely no warranty expressed |
|
11 * or implied. Any use is at your own risk. |
|
12 * |
|
13 * Permission to use or copy this software for any purpose is hereby granted |
|
14 * without fee, provided the above notices are retained on all copies. |
|
15 * Permission to modify the code and to distribute modified code is granted, |
|
16 * provided the above notices are retained, and a notice that the code was |
|
17 * modified is included with the above copyright notice. |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 # if !defined (_STLP_OUTERMOST_HEADER_ID) |
|
23 # define _STLP_OUTERMOST_HEADER_ID 0x63 |
|
24 # include <stl/_prolog.h> |
|
25 # elif (_STLP_OUTERMOST_HEADER_ID == 0x63) && ! defined (_STLP_DONT_POP_0x63) |
|
26 # define _STLP_DONT_POP_0x63 |
|
27 # endif |
|
28 |
|
29 #ifndef _STLP_STDEXCEPT |
|
30 #define _STLP_STDEXCEPT 1 |
|
31 |
|
32 # ifdef _STLP_PRAGMA_ONCE |
|
33 # pragma once |
|
34 # endif |
|
35 |
|
36 #if defined (_STLP_USE_TRAP_LEAVE) |
|
37 |
|
38 enum { |
|
39 STDEX_bad_alloc = -10000, |
|
40 STDEX_logic_error = -10001, |
|
41 STDEX_runtime_error = -10002, |
|
42 STDEX_domain_error = -10003, |
|
43 STDEX_invalid_argument = -10004, |
|
44 STDEX_length_error = -10005, |
|
45 STDEX_out_of_range = -10006, |
|
46 STDEX_range_error = -10007, |
|
47 STDEX_overflow_error = -10008, |
|
48 STDEX_underflow_error = -10009 |
|
49 }; |
|
50 |
|
51 // User may override this |
|
52 #ifndef STDEX_REPORT_EXCEPTION |
|
53 # define STDEX_REPORT_EXCEPTION(x) |
|
54 #endif |
|
55 |
|
56 #endif |
|
57 |
|
58 # if !defined(_STLP_STDEXCEPT_SEEN) && \ |
|
59 (!defined (_STLP_USE_NATIVE_STDEXCEPT) || defined (_STLP_USE_OWN_NAMESPACE)) |
|
60 |
|
61 # define _STLP_STDEXCEPT_SEEN 1 |
|
62 |
|
63 # include <exception> |
|
64 |
|
65 #if defined(_STLP_USE_EXCEPTIONS) || \ |
|
66 !(defined(_MIPS_SIM) && defined(_ABIO32) && _MIPS_SIM == _ABIO32) |
|
67 |
|
68 # include <cstring> |
|
69 |
|
70 #ifndef _STLP_INTERNAL_ALLOC_H |
|
71 # include <stl/_alloc.h> |
|
72 #endif |
|
73 |
|
74 #ifndef _STLP_STRING_FWD_H |
|
75 # include <stl/_string_fwd.h> |
|
76 #endif |
|
77 |
|
78 # define _STLP_OWN_STDEXCEPT 1 |
|
79 |
|
80 _STLP_BEGIN_NAMESPACE |
|
81 |
|
82 # if ! defined (_STLP_NO_EXCEPTION_HEADER) |
|
83 # if !defined(_STLP_EXCEPTION_BASE) && !defined(_STLP_BROKEN_EXCEPTION_CLASS) && defined (_STLP_USE_NAMESPACES) && defined (_STLP_USE_OWN_NAMESPACE) |
|
84 using _STLP_VENDOR_EXCEPT_STD::exception; |
|
85 # endif |
|
86 # endif |
|
87 # define _STLP_EXCEPTION_BASE exception |
|
88 |
|
89 #ifdef __SYMBIAN32__ |
|
90 class __Named_exception : public _STLP_EXCEPTION_BASE { |
|
91 #else |
|
92 class _STLP_CLASS_DECLSPEC __Named_exception : public _STLP_EXCEPTION_BASE { |
|
93 #endif //__SYMBIAN32__ |
|
94 public: |
|
95 _STLP_DECLSPEC __Named_exception(const string& __str) |
|
96 # ifdef _STLP_OWN_IOSTREAMS |
|
97 ; |
|
98 _STLP_DECLSPEC const char* what() const _STLP_NOTHROW_INHERENTLY; |
|
99 _STLP_DECLSPEC ~__Named_exception() _STLP_NOTHROW_INHERENTLY; |
|
100 # else |
|
101 { |
|
102 strncpy(_M_name, __get_c_string(__str), _S_bufsize); |
|
103 _M_name[_S_bufsize - 1] = '\0'; |
|
104 } |
|
105 const char* what() const _STLP_NOTHROW_INHERENTLY { return _M_name; } |
|
106 # endif |
|
107 |
|
108 private: |
|
109 enum { _S_bufsize = 256 }; |
|
110 char _M_name[_S_bufsize]; |
|
111 }; |
|
112 |
|
113 #ifdef __SYMBIAN32__ |
|
114 class logic_error : public __Named_exception { |
|
115 #else |
|
116 class _STLP_CLASS_DECLSPEC logic_error : public __Named_exception { |
|
117 #endif |
|
118 public: |
|
119 _STLP_DECLSPEC logic_error(const string& __s) |
|
120 #ifdef __SYMBIAN32__ |
|
121 ; |
|
122 #else |
|
123 : __Named_exception(__s) {} |
|
124 #endif |
|
125 # ifdef _STLP_OWN_IOSTREAMS |
|
126 _STLP_DECLSPEC ~logic_error() _STLP_NOTHROW_INHERENTLY; |
|
127 # endif |
|
128 }; |
|
129 |
|
130 #ifdef __SYMBIAN32__ |
|
131 class runtime_error : public __Named_exception { |
|
132 #else |
|
133 class _STLP_CLASS_DECLSPEC runtime_error : public __Named_exception { |
|
134 #endif |
|
135 public: |
|
136 _STLP_DECLSPEC runtime_error(const string& __s) |
|
137 #ifdef __SYMBIAN32__ |
|
138 ; |
|
139 #else |
|
140 : __Named_exception(__s) {} |
|
141 #endif |
|
142 # ifdef _STLP_OWN_IOSTREAMS |
|
143 _STLP_DECLSPEC ~runtime_error() _STLP_NOTHROW_INHERENTLY; |
|
144 # endif |
|
145 }; |
|
146 |
|
147 #ifdef __SYMBIAN32__ |
|
148 class domain_error : public logic_error { |
|
149 #else |
|
150 class _STLP_CLASS_DECLSPEC domain_error : public logic_error { |
|
151 #endif |
|
152 public: |
|
153 _STLP_DECLSPEC domain_error(const string& __arg) |
|
154 #ifdef __SYMBIAN32__ |
|
155 ; |
|
156 #else |
|
157 : logic_error(__arg) {} |
|
158 #endif |
|
159 # ifdef _STLP_OWN_IOSTREAMS |
|
160 _STLP_DECLSPEC ~domain_error() _STLP_NOTHROW_INHERENTLY; |
|
161 # endif |
|
162 }; |
|
163 |
|
164 #ifdef __SYMBIAN32__ |
|
165 class invalid_argument : public logic_error { |
|
166 #else |
|
167 class _STLP_CLASS_DECLSPEC invalid_argument : public logic_error { |
|
168 #endif |
|
169 public: |
|
170 _STLP_DECLSPEC invalid_argument(const string& __arg) |
|
171 #ifdef __SYMBIAN32__ |
|
172 ; |
|
173 #else |
|
174 : logic_error(__arg) {} |
|
175 #endif |
|
176 # ifdef _STLP_OWN_IOSTREAMS |
|
177 _STLP_DECLSPEC ~invalid_argument() _STLP_NOTHROW_INHERENTLY; |
|
178 # endif |
|
179 }; |
|
180 |
|
181 #ifdef __SYMBIAN32__ |
|
182 class length_error : public logic_error { |
|
183 #else |
|
184 class _STLP_CLASS_DECLSPEC length_error : public logic_error { |
|
185 #endif |
|
186 public: |
|
187 _STLP_DECLSPEC length_error(const string& __arg) |
|
188 #ifdef __SYMBIAN32__ |
|
189 ; |
|
190 #else |
|
191 : logic_error(__arg) {} |
|
192 #endif |
|
193 # ifdef _STLP_OWN_IOSTREAMS |
|
194 _STLP_DECLSPEC ~length_error() _STLP_NOTHROW_INHERENTLY; |
|
195 # endif |
|
196 }; |
|
197 |
|
198 #ifdef __SYMBIAN32__ |
|
199 class out_of_range : public logic_error { |
|
200 #else |
|
201 class _STLP_CLASS_DECLSPEC out_of_range : public logic_error { |
|
202 #endif |
|
203 public: |
|
204 _STLP_DECLSPEC out_of_range(const string& __arg) |
|
205 #ifdef __SYMBIAN32__ |
|
206 ; |
|
207 #else |
|
208 : logic_error(__arg) {} |
|
209 #endif |
|
210 # ifdef _STLP_OWN_IOSTREAMS |
|
211 _STLP_DECLSPEC ~out_of_range() _STLP_NOTHROW_INHERENTLY; |
|
212 # endif |
|
213 }; |
|
214 |
|
215 #ifdef __SYMBIAN32__ |
|
216 class range_error : public runtime_error { |
|
217 #else |
|
218 class _STLP_CLASS_DECLSPEC range_error : public runtime_error { |
|
219 #endif |
|
220 public: |
|
221 _STLP_DECLSPEC range_error(const string& __arg) |
|
222 #ifdef __SYMBIAN32__ |
|
223 ; |
|
224 #else |
|
225 : runtime_error(__arg) {} |
|
226 #endif |
|
227 # ifdef _STLP_OWN_IOSTREAMS |
|
228 _STLP_DECLSPEC ~range_error() _STLP_NOTHROW_INHERENTLY; |
|
229 # endif |
|
230 }; |
|
231 |
|
232 #ifdef __SYMBIAN32__ |
|
233 class overflow_error : public runtime_error { |
|
234 #else |
|
235 class _STLP_CLASS_DECLSPEC overflow_error : public runtime_error { |
|
236 #endif |
|
237 public: |
|
238 _STLP_DECLSPEC overflow_error(const string& __arg) |
|
239 #ifdef __SYMBIAN32__ |
|
240 ; |
|
241 #else |
|
242 : runtime_error(__arg) {} |
|
243 #endif |
|
244 # ifdef _STLP_OWN_IOSTREAMS |
|
245 _STLP_DECLSPEC ~overflow_error() _STLP_NOTHROW_INHERENTLY; |
|
246 # endif |
|
247 }; |
|
248 |
|
249 #ifdef __SYMBIAN32__ |
|
250 class underflow_error : public runtime_error { |
|
251 #else |
|
252 class _STLP_CLASS_DECLSPEC underflow_error : public runtime_error { |
|
253 #endif |
|
254 public: |
|
255 _STLP_DECLSPEC underflow_error(const string& __arg) |
|
256 #ifdef __SYMBIAN32__ |
|
257 ; |
|
258 #else |
|
259 : runtime_error(__arg) {} |
|
260 #endif |
|
261 # ifdef _STLP_OWN_IOSTREAMS |
|
262 _STLP_DECLSPEC ~underflow_error() _STLP_NOTHROW_INHERENTLY; |
|
263 # endif |
|
264 }; |
|
265 |
|
266 _STLP_END_NAMESPACE |
|
267 |
|
268 #endif /* Not o32, and no exceptions */ |
|
269 # endif /* _STLP_STDEXCEPT_SEEN */ |
|
270 |
|
271 |
|
272 #if defined (_STLP_USE_NATIVE_STDEXCEPT) |
|
273 # include _STLP_NATIVE_HEADER(stdexcept) |
|
274 # endif |
|
275 |
|
276 #endif /* _STLP_STDEXCEPT */ |
|
277 |
|
278 # if (_STLP_OUTERMOST_HEADER_ID == 0x63) |
|
279 # if ! defined (_STLP_DONT_POP_0x63) |
|
280 # include <stl/_epilog.h> |
|
281 # undef _STLP_OUTERMOST_HEADER_ID |
|
282 # endif |
|
283 # undef _STLP_DONT_POP_0x63 |
|
284 # endif |
|
285 |
|
286 |
|
287 // Local Variables: |
|
288 // mode:C++ |
|
289 // End: |
|
290 |