]> ncurses.scripts.mit.edu Git - ncurses.git/blob - c++/etip.h.in
ncurses 5.0
[ncurses.git] / c++ / etip.h.in
1 // * This makes emacs happy -*-Mode: C++;-*-
2 /****************************************************************************
3  * Copyright (c) 1998,1999 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@gmx.net> 1997                 *
32  ****************************************************************************/
33
34 // $Id: etip.h.in,v 1.13 1999/09/12 02:01:59 tom 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_GXX_BUILTIN_H
45 #define HAVE_GXX_BUILTIN_H 0
46 #endif
47
48 #ifndef HAVE_GPP_BUILTIN_H
49 #define HAVE_GPP_BUILTIN_H 0
50 #endif
51
52 #ifndef HAVE_TYPEINFO
53 #define HAVE_TYPEINFO 0
54 #endif
55
56 #ifndef HAVE_VALUES_H
57 #define HAVE_VALUES_H 0
58 #endif
59
60 #ifndef ETIP_NEEDS_MATH_H
61 #define ETIP_NEEDS_MATH_H 0
62 #endif
63
64 #ifndef ETIP_NEEDS_MATH_EXCEPTION
65 #define ETIP_NEEDS_MATH_EXCEPTION 0
66 #endif
67
68 #ifndef CPP_HAS_PARAM_INIT
69 #define CPP_HAS_PARAM_INIT 0
70 #endif
71
72 #ifdef __GNUG__
73 #  if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
74 #    if HAVE_TYPEINFO
75 #      include <typeinfo>
76 #    endif
77 #  endif
78 #endif
79
80 #if defined(__GNUG__)
81 #  if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H
82 #    if ETIP_NEEDS_MATH_H
83 #      if ETIP_NEEDS_MATH_EXCEPTION
84 #        undef exception
85 #        define exception math_exception
86 #      endif
87 #      include <math.h>
88 #    endif
89 #    undef exception
90 #    define exception builtin_exception
91 #    if HAVE_GPP_BUILTIN_H
92 #     include <gpp/builtin.h>
93 #    elif HAVE_GXX_BUILTIN_H
94 #     include <g++/builtin.h>
95 #    else
96 #     include <builtin.h>
97 #    endif
98 #    undef exception
99 #  endif
100 #elif defined (__SUNPRO_CC)
101 #  include <generic.h>
102 #  include <string.h>
103 #else
104 #  include <string.h>
105 #endif
106
107 extern "C" {
108 #if HAVE_VALUES_H
109 #  include <values.h>
110 #endif
111
112 #include <assert.h>
113 #include <eti.h>
114 #include <errno.h>
115 }
116
117 // Language features
118 #if CPP_HAS_PARAM_INIT
119 #define NCURSES_PARAM_INIT(value) = value
120 #else
121 #define NCURSES_PARAM_INIT(value) /*nothing*/
122 #endif
123
124 // Forward Declarations
125 class NCursesPanel;
126 class NCursesMenu;
127 class NCursesForm;
128
129 class NCursesException
130 {
131 public:
132   const char *message;
133   int errorno;
134
135   NCursesException (const char* msg, int err)
136     : message(msg), errorno (err)
137     {};
138
139   NCursesException (const char* msg)
140     : message(msg), errorno (E_SYSTEM_ERROR)
141     {};
142
143   virtual const char *classname() const {
144     return "NCursesWindow";
145   }
146 };
147
148 class NCursesPanelException : public NCursesException
149 {
150 public:
151   const NCursesPanel* p;
152
153   NCursesPanelException (const char *msg, int err) : 
154     NCursesException (msg, err),
155     p ((NCursesPanel*)0)
156     {};
157
158   NCursesPanelException (const NCursesPanel* panel,
159                          const char *msg,
160                          int err) : 
161     NCursesException (msg, err),
162     p (panel)
163     {};
164
165   NCursesPanelException (int err) : 
166     NCursesException ("panel library error", err),
167     p ((NCursesPanel*)0)
168     {};
169
170   NCursesPanelException (const NCursesPanel* panel,
171                          int err) : 
172     NCursesException ("panel library error", err),
173     p (panel)
174     {};
175
176   virtual const char *classname() const {
177     return "NCursesPanel";
178   }
179
180 };
181
182 class NCursesMenuException : public NCursesException
183 {
184 public:
185   const NCursesMenu* m;
186
187   NCursesMenuException (const char *msg, int err) : 
188     NCursesException (msg, err),
189     m ((NCursesMenu *)0)
190     {};
191
192   NCursesMenuException (const NCursesMenu* menu,
193                         const char *msg,
194                         int err) : 
195     NCursesException (msg, err),
196     m (menu)
197     {};
198
199   NCursesMenuException (int err) : 
200     NCursesException ("menu library error", err),
201     m ((NCursesMenu *)0)
202     {};
203
204   NCursesMenuException (const NCursesMenu* menu,
205                         int err) : 
206     NCursesException ("menu library error", err),
207     m (menu)
208     {};
209
210   virtual const char *classname() const {
211     return "NCursesMenu";
212   }
213
214 };
215
216 class NCursesFormException : public NCursesException
217 {
218 public:
219   const NCursesForm* f;
220
221   NCursesFormException (const char *msg, int err) : 
222     NCursesException (msg, err),
223     f ((NCursesForm*)0)
224     {};
225
226   NCursesFormException (const NCursesForm* form,
227                         const char *msg,
228                         int err) : 
229     NCursesException (msg, err),
230     f (form)
231     {};
232
233   NCursesFormException (int err) : 
234     NCursesException ("form library error", err),
235     f ((NCursesForm*)0)
236     {};
237
238   NCursesFormException (const NCursesForm* form,
239                         int err) : 
240     NCursesException ("form library error", err),
241     f (form)
242     {};
243
244   virtual const char *classname() const {
245     return "NCursesForm";
246   }
247
248 };
249
250 #if !(defined(__GNUG__)||defined(__SUNPRO_CC))
251 #  include <iostream.h>
252    extern "C" void exit(int);
253 #endif
254
255 inline void THROW(const NCursesException *e) {
256 #if defined(__GNUG__)
257 #  if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
258       (*lib_error_handler)(e?e->classname():"",e?e->message:"");
259 #else
260       throw *e;
261 #endif
262 #elif defined(__SUNPRO_CC)
263   genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
264 #else
265   if (e)
266     cerr << e->message << endl;
267   exit(0);
268 #endif     
269 }
270
271 #define THROWS(s)
272
273 #endif // _ETIP_H