+ C++ ABI: pure virtual functions
[lightlibc++.git] / include / lightlibc++ / exception.hpp
blob9475d6e57863cc8a420a07af25a2126ae65ce541
1 /*
2 Permission is granted to use, modify, and / or redistribute at will.
4 This includes removing authorship notices, re-use of code parts in
5 other software (with or without giving credit), and / or creating a
6 commercial product based on it.
8 This permission is not revocable by the author.
10 This software is provided as-is. Use it at your own risk. There is
11 no warranty whatsoever, neither expressed nor implied, and by using
12 this software you accept that the author(s) shall not be held liable
13 for any loss of data, loss of service, or other damages, be they
14 incidental or consequential. Your only option other than accepting
15 this is not to use the software at all.
17 #ifndef _LIGHTLIBCPP_EXCEPTION_HPP
18 #define _LIGHTLIBCPP_EXCEPTION_HPP
22 #include <lightlibc++/compiler.hpp>
26 namespace std
28 /** \addtogroup lightlibcpp_18_7 */
29 /*@{*/
31 /**
32 *\english
33 * \brief Base class for exceptions thrown by the C++ Standard Library
35 * 18.7.1 Class exception
37 * Base class for exceptions thrown by the C++ Standard Library
38 *\endenglish
39 *\german
40 * \brief Basisklasse der Ausnahmen, die von der C++ Standardbibliothek geworfen werden
42 * 18.7.1 Klasse exception
44 * Basisklasse der Ausnahmen, die von der C++ Standardbibliothek geworfen werden
45 *\endgerman
47 class exception
49 public:
50 /**
51 *\english
52 * Constructs an object of class exception.
53 *\endenglish
54 *\german
55 * Konstruiert ein Objekt der Klasse exception.
56 *\endgerman */
57 inline exception() throw()
61 /**
62 *\english
63 * Copies an object of class exception.
64 * \param[in] x reference to the object to copy
65 *\endenglish
66 *\german
67 * Kopiert ein Objekt der Klasse exception.
68 * \param[in] x Referenz auf das zu kopierende Objekt
69 *\endgerman */
70 inline exception(const exception& x) throw()
72 (void)x;
75 /**
76 *\english
77 * Copies an object of class exception.
78 * \param[in] x reference to the object to copy
79 *\endenglish
80 *\german
81 * Kopiert ein Objekt der Klasse exception.
82 * \param[in] x Referenz auf das zu kopierende Objekt
83 *\endgerman */
84 inline exception& operator = (const exception& x) throw()
86 (void)x;
87 return *this;
90 /**
91 *\english
92 * Destructs an object of class exception
93 *\endenglish
94 *\german
95 * Zerstört ein Objekt der Klasse exception
96 *\endgerman */
97 virtual ~exception() throw();
99 /**
100 *\english
101 * User-friendly name of the class
102 * \return null-terminated character sequence
103 *\endenglish
104 *\german
105 * Benutzerfreundlicher Name der Klasse
106 * \return nullterminierte Zeichenkette
107 *\endgerman
109 virtual const char* what() const throw();
112 /*@}*/
116 /** \addtogroup lightlibcpp_18_7_2 */
117 /*@{*/
120 *\english
121 * \brief Class thrown by the runtime, when an exception-specification is
122 * violated
124 * 18.7.2.1 Class bad_exception
126 * Class thrown by the runtime, when an exception-specification is violated
127 *\endenglish
128 *\german
129 * \brief Klasse die von der Laufzeit geworfen wird, wenn eine
130 * Ausnahmenspezifikation verletzt wurde
132 * 18.7.2.1 Klasse bad_exception
134 * Klasse die von der Laufzeit geworfen wird, wenn eine
135 * Ausnahmenspezifikation verletzt wurde
136 *\endgerman
138 class bad_exception : public std::exception
140 public:
142 *\english
143 * Constructs an object of class bad_exception.
144 *\endenglish
145 *\german
146 * Konstruiert ein Objekt der Klasse bad_exception.
147 *\endgerman */
148 inline bad_exception() throw()
153 *\english
154 * Copies an object of class bad_exception.
155 * \param[in] x reference to the object to copy
156 *\endenglish
157 *\german
158 * Kopiert ein Objekt der Klasse bad_exception.
159 * \param[in] x Referenz auf das zu kopierende Objekt
160 *\endgerman */
161 inline bad_exception(const bad_exception& x) throw()
162 : std::exception(x)
167 *\english
168 * Destructs an object of class bad_exception
169 *\endenglish
170 *\german
171 * Zerstört ein Objekt der Klasse bad_exception
172 *\endgerman */
173 virtual ~bad_exception() throw();
175 virtual const char* what() const throw();
179 *\english
180 * 18.7.2.2 Type unexpected_handler
182 * The type of a handler function to be called by unexpected() when a
183 * function attempts to throw an exception not listed in its
184 * exception-specification.
186 * An unexpected_handler shall not return.
188 * The default unexpected_handler calls terminate().
189 *\endenglish
190 *\german
191 * 18.7.2.2 Typ unexpected_handler
193 * Der Typ einer Handlerfunktion, welche von unexpected() aufgerufen wird,
194 * wenn eine Funktion eine Ausnahme, die nicht in ihrer
195 * Ausnahmenspezifikation angegeben ist, wirft.
197 * Ein unexpected_handler darf die Kontrolle nicht an die aufrufende
198 * Funktion zurückgeben.
200 * Der standardmäßig installierte unexpected_handler ruft terminate() auf.
201 *\endgerman
203 typedef void (*unexpected_handler)() _LIGHTLIBCPP_NORETURN;
206 * 18.7.2.3 set_unexpected
208 *\english
209 * The unexpected_handler f becomes the new handler called by unexpected()
210 * \param[in] f a non-null pointer to the new unexpected_handler
211 * \return a pointer to the previous unexpected_handler
212 *\endenglish
213 *\german
214 * Der unexpected_handler f wird der neue Handler, der von unexpected()
215 * aufgerufen wird
216 * \param[in] f ein gültiger Zeiger auf einen unexpected_handler
217 * \return ein Zeiger auf den vorhergehende unexpected_handler
218 *\endgerman
220 unexpected_handler set_unexpected(unexpected_handler f) throw();
223 *\english
224 * lightlibc++ extension
226 * Get the current unexpected_handler
227 * \note This function is needed by the C++ exception handling ABI
228 * \return apointer to the current unexpected_handler
229 *\endenglish
230 *\german
231 * lightlibc++ Erweiterung
233 * Gibt einen Zeiger auf momentan installierten unexpected_handler zurück
234 * \note Diese Funktion wird von der C++ Ausnahmebehandlungs-ABI benötigt
235 * \return ein Zeiger auf den momentan installierten unexpected_handler
236 *\endgerman
238 unexpected_handler __get_unexpected();
241 * 18.6.2.4 unexpected
243 *\english
244 * Called by the implementation when a function exits via an exception not
245 * allowed by its exception-specification. May also be called directly by the
246 * program.
248 * Calls the calls the current unexpected_handler.
249 *\endenglish
250 *\german
251 * Diese Funktion wird vom der Laufzeit aufgerufen, falls eine Funktion eine
252 * Ausnahme, die nicht in ihrer Ausnahmenspezifikation angegeben ist, wirft.
253 * Diese Funktion darf auch direkt aus dem Programm aufgerufen werden.
255 * unexpected() ruft den momentanen unexpected_handler auf.
256 *\endgerman
258 void unexpected() _LIGHTLIBCPP_NORETURN;
260 /*@}*/
264 /** \addtogroup lightlibcpp_18_7_3 */
265 /*@{*/
268 *\english
269 * 18.7.3.1 Type terminate_handler
271 * The type of a handler function to be called by terminate() when
272 * terminating exception processing.
274 * A terminate_handler shall terminate execution of the program without
275 * returning to the caller.
277 * The default terminate_handler calls abort().
278 *\endenglish
279 *\german
280 * 18.7.3.1 Typ terminate_handler
282 * Der Typ einer Handlerfunktion, welche von terminate() aufgerufen wird,
283 * wenn die Ausnahmebehandlung terminiert wird (durch den standardmäßig
284 * installierten unexpected_handler).
286 * Ein terminate_handler muss das Programm beenden ohne die Kontrolle zum
287 * Aufrufer zurückzugeben
289 * Der standardmäßig installierte terminate_handler ruft abort() auf.
290 *\endgerman
292 typedef void (*terminate_handler)() _LIGHTLIBCPP_NORETURN;
295 * 18.7.3.2 set_terminate
297 *\english
298 * The terminate_handler f becomes the new handler called by terminate()
299 * \param[in] f a non-null pointer to the new terminate_handler
300 * \return a pointer to the previous terminate_handler
301 *\endenglish
302 *\german
303 * Der terminate_handler f wird der neue Handler, der von terminate()
304 * aufgerufen wird
305 * \param[in] f ein gültiger Zeiger auf einen terminate_handler
306 * \return ein Zeiger auf den vorhergehende terminate_handler
307 *\endgerman
309 terminate_handler set_terminate(terminate_handler f) throw();
312 *\english
313 * lightlibc++ extension
315 * Get the current terminate_handler
316 * \note This function is needed by the C++ exception handling ABI
317 * \return apointer to the current terminate_handler
318 *\endenglish
319 *\german
320 * lightlibc++ Erweiterung
322 * Gibt einen Zeiger auf momentan installierten terminate_handler zurück
323 * \note Diese Funktion wird von der C++ Ausnahmebehandlungs-ABI benötigt
324 * \return ein Zeiger auf den momentan installierten terminate_handler
325 *\endgerman
327 terminate_handler __get_terminate();
330 * 18.7.3.3 terminate
332 *\english
333 * Called by the default unexpected_handler. May also be called directly by
334 * the program.
336 * Calls the calls the current terminate_handler.
337 *\endenglish
338 *\german
339 * Diese Funktion wird vom standardmäßig installierten unexpected_handler
340 * aufgerufen. Außerdem darf terminate() auch direkt aus dem Programm
341 * aufgerufen werden.
343 * terminate() ruft den momentanen terminate_handler auf.
344 *\endgerman
346 void terminate() _LIGHTLIBCPP_NORETURN;
348 /*@}*/
352 /** \addtogroup lightlibcpp_18_7 */
353 /*@{*/
355 // TODO: bool uncaught_exception() throw(), implemented by the C++ ABI: Exception Handling patch
357 #ifdef _LIGHTLIBCPP_CPP10
358 // TODO C++1x: typedef \unspec exception_ptr;
359 // TODO C++1x: exception_ptr current_exception();
360 // TODO C++1x: void rethrow_exception(exception_ptr p);
361 // TODO C++1x: template<class E> exception_ptr copy_exception(E e);
362 #endif
364 /*@}*/
369 #endif