]> ncurses.scripts.mit.edu Git - ncurses.git/blob - c++/etip.h.in
ncurses 4.2
[ncurses.git] / c++ / etip.h.in
1 // * This makes emacs happy -*-Mode: C++;-*-
2 /****************************************************************************
3  * Copyright (c) 1998 Free Software Foundation, Inc.                        *
4  *                                                                          *
5  * Permission is hereby granted, free of charge, to any person obtaining a  *
6  * copy of this software and associated documentation files (the            *
7  * "Software"), to deal in the Software without restriction, including      *
8  * without limitation the rights to use, copy, modify, merge, publish,      *
9  * distribute, distribute with modifications, sublicense, and/or sell       *
10  * copies of the Software, and to permit persons to whom the Software is    *
11  * furnished to do so, subject to the following conditions:                 *
12  *                                                                          *
13  * The above copyright notice and this permission notice shall be included  *
14  * in all copies or substantial portions of the Software.                   *
15  *                                                                          *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23  *                                                                          *
24  * Except as contained in this notice, the name(s) of the above copyright   *
25  * holders shall not be used in advertising or otherwise to promote the     *
26  * sale, use or other dealings in this Software without prior written       *
27  * authorization.                                                           *
28  ****************************************************************************/
29
30 /****************************************************************************
31  *   Author: Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> 1997             *
32  ****************************************************************************/
33
34 // $Id: etip.h.in,v 1.4 1998/02/17 09:01:38 juergen Exp $
35
36 #ifndef _ETIP_H
37 #define _ETIP_H
38
39 // These are substituted at configure/build time
40 #ifndef HAVE_BUILTIN_H
41 #define HAVE_BUILTIN_H 0
42 #endif
43
44 #ifndef HAVE_TYPEINFO
45 #define HAVE_TYPEINFO 0
46 #endif
47
48 #ifndef HAVE_VALUES_H
49 #define HAVE_VALUES_H 0
50 #endif
51
52 #ifdef __GNUG__
53 #  if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
54 #    if HAVE_TYPEINFO
55 #      include <typeinfo>
56 #    endif
57 #  endif
58 #endif
59
60 #if defined(__GNUG__)
61 #  if HAVE_BUILTIN_H
62 #    define exception builtin_exception
63 #    include <builtin.h>
64 #    undef exception
65 #  endif
66 #elif defined (__SUNPRO_CC)
67 #  include <generic.h>
68 #  include <string.h>
69 #else
70 #  include <string.h>
71 #endif
72
73 extern "C" {
74 #if HAVE_VALUES_H
75 #  include <values.h>
76 #endif
77
78 #include <assert.h>
79 #include <eti.h>
80 #include <errno.h>
81 }
82
83 // Forward Declarations
84 class NCursesPanel;
85 class NCursesMenu;
86 class NCursesForm;
87
88 class NCursesException
89 {
90 public:
91   int errorno;
92   const char *message;
93
94   NCursesException (const char* msg, int err)
95     : message(msg), errorno (err)
96     {};
97
98   NCursesException (const char* msg)
99     : message(msg), errorno (E_SYSTEM_ERROR)
100     {};
101
102   virtual const char *classname() const {
103     return "NCursesWindow";
104   }
105 };
106
107 class NCursesPanelException : public NCursesException
108 {
109 public:
110   const NCursesPanel* p;
111
112   NCursesPanelException (const char *msg, int err) : 
113     NCursesException (msg, err),
114     p ((NCursesPanel*)0)
115     {};
116
117   NCursesPanelException (const NCursesPanel* panel,
118                          const char *msg,
119                          int err) : 
120     NCursesException (msg, err),
121     p (panel)
122     {};
123
124   NCursesPanelException (int err) : 
125     NCursesException ("panel library error", err),
126     p ((NCursesPanel*)0)
127     {};
128
129   NCursesPanelException (const NCursesPanel* panel,
130                          int err) : 
131     NCursesException ("panel library error", err),
132     p (panel)
133     {};
134
135   virtual const char *classname() const {
136     return "NCursesPanel";
137   }
138
139 };
140
141 class NCursesMenuException : public NCursesException
142 {
143 public:
144   const NCursesMenu* m;
145
146   NCursesMenuException (const char *msg, int err) : 
147     NCursesException (msg, err),
148     m ((NCursesMenu *)0)
149     {};
150
151   NCursesMenuException (const NCursesMenu* menu,
152                         const char *msg,
153                         int err) : 
154     NCursesException (msg, err),
155     m (menu)
156     {};
157
158   NCursesMenuException (int err) : 
159     NCursesException ("menu library error", err),
160     m ((NCursesMenu *)0)
161     {};
162
163   NCursesMenuException (const NCursesMenu* menu,
164                         int err) : 
165     NCursesException ("menu library error", err),
166     m (menu)
167     {};
168
169   virtual const char *classname() const {
170     return "NCursesMenu";
171   }
172
173 };
174
175 class NCursesFormException : public NCursesException
176 {
177 public:
178   const NCursesForm* f;
179
180   NCursesFormException (const char *msg, int err) : 
181     NCursesException (msg, err),
182     f ((NCursesForm*)0)
183     {};
184
185   NCursesFormException (const NCursesForm* form,
186                         const char *msg,
187                         int err) : 
188     NCursesException (msg, err),
189     f (form)
190     {};
191
192   NCursesFormException (int err) : 
193     NCursesException ("form library error", err),
194     f ((NCursesForm*)0)
195     {};
196
197   NCursesFormException (const NCursesForm* form,
198                         int err) : 
199     NCursesException ("form library error", err),
200     f (form)
201     {};
202
203   virtual const char *classname() const {
204     return "NCursesForm";
205   }
206
207 };
208
209 #if !(defined(__GNUG__)||defined(__SUNPRO_CC))
210 #  include <iostream.h>
211    extern "C" void exit(int);
212 #endif
213
214 inline void THROW(const NCursesException *e) {
215 #if defined(__GNUG__)
216 #  if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
217       (*lib_error_handler)(e?e->classname():"",e?e->message:"");
218 #else
219       throw *e;
220 #endif
221 #elif defined(__SUNPRO_CC)
222   genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
223 #else
224   if (e)
225     cerr << e->message << endl;
226   exit(0);
227 #endif     
228 }
229
230 #define THROWS(s)
231
232 #endif // _ETIP_H