Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / lib / DtSvc / include / codelibs / exception.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /*
24  * File:        exception.h $XConsortium: exception.h /main/3 1995/10/26 16:12:07 rswiston $
25  *
26  * (c) Copyright 1993, 1994 Hewlett-Packard Company
27  * (c) Copyright 1993, 1994 International Business Machines Corp.
28  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
29  * (c) Copyright 1993, 1994 Novell, Inc.
30  */
31 /* C++ exception handler package */
32
33 #ifndef __EXCEPTION_H_
34 #define __EXCEPTION_H_
35
36 #include <stddef.h>
37 #include <setjmp.h>
38
39
40 typedef const char *const Exception;
41
42 class _Exception
43 {
44         char raised, accepted;
45         _Exception *prev;
46 public:
47         const char *val;
48         jmp_buf buf;
49
50         _Exception();
51         ~_Exception();
52         int accept(Exception val);
53         int recover();
54         void raise(Exception val);
55 };
56 extern _Exception *_curr_exception;
57 extern void _raise_exception(Exception val);
58
59 #define TRY _Exception _new_exception; if (setjmp(_new_exception.buf) == 0)
60 #define RECOVER else if (_new_exception.recover())
61 #define HANDLE(val) else if (_new_exception.accept(val))
62 #define RAISE(val) _raise_exception(val)
63 #define EXCEPTION (_curr_exception != NULL ? _curr_exception->val : NULL)
64
65
66 #endif /* __EXCEPTION_H_ */
67 /*
68 @(#)REV: 2.18 90/12/13                                               
69 */