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