libncurses: updated to 6.0
[tomato.git] / release / src / router / libncurses / c++ / etip.h.in
blob9f642ee6d0008b4be25cde0970aa42bce74bc055
1 // * This makes emacs happy -*-Mode: C++;-*-
2 /****************************************************************************
3 * Copyright (c) 1998-2011,2012 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 ****************************************************************************/
30 /****************************************************************************
31 * Author: Juergen Pfeifer, 1997 *
32 ****************************************************************************/
34 // $Id: etip.h.in,v 1.39 2012/12/29 21:50:44 tom Exp $
36 #ifndef NCURSES_ETIP_H_incl
37 #define NCURSES_ETIP_H_incl 1
39 // These are substituted at configure/build time
40 #ifndef HAVE_BUILTIN_H
41 #define HAVE_BUILTIN_H 0
42 #endif
44 #ifndef HAVE_GXX_BUILTIN_H
45 #define HAVE_GXX_BUILTIN_H 0
46 #endif
48 #ifndef HAVE_GPP_BUILTIN_H
49 #define HAVE_GPP_BUILTIN_H 0
50 #endif
52 #ifndef HAVE_IOSTREAM
53 #define HAVE_IOSTREAM 0
54 #endif
56 #ifndef HAVE_TYPEINFO
57 #define HAVE_TYPEINFO 0
58 #endif
60 #ifndef HAVE_VALUES_H
61 #define HAVE_VALUES_H 0
62 #endif
64 #ifndef ETIP_NEEDS_MATH_H
65 #define ETIP_NEEDS_MATH_H 0
66 #endif
68 #ifndef ETIP_NEEDS_MATH_EXCEPTION
69 #define ETIP_NEEDS_MATH_EXCEPTION 0
70 #endif
72 #ifndef CPP_HAS_PARAM_INIT
73 #define CPP_HAS_PARAM_INIT 0
74 #endif
76 #ifndef CPP_HAS_STATIC_CAST
77 #define CPP_HAS_STATIC_CAST 0 // workaround for g++ 2.95.3
78 #endif
80 #ifndef IOSTREAM_NAMESPACE
81 #define IOSTREAM_NAMESPACE 0
82 #endif
84 #ifdef __GNUG__
85 # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
86 # if HAVE_TYPEINFO
87 # include <typeinfo>
88 # endif
89 # endif
90 #endif
92 #if defined(__GNUG__)
93 # if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H
94 # if ETIP_NEEDS_MATH_H
95 # if ETIP_NEEDS_MATH_EXCEPTION
96 # undef exception
97 # define exception math_exception
98 # endif
99 # include <math.h>
100 # endif
101 # undef exception
102 # define exception builtin_exception
103 # if HAVE_GPP_BUILTIN_H
104 # include <gpp/builtin.h>
105 # elif HAVE_GXX_BUILTIN_H
106 # include <g++/builtin.h>
107 # else
108 # include <builtin.h>
109 # endif
110 # undef exception
111 # endif
112 #elif defined (__SUNPRO_CC)
113 # include <generic.h>
114 #endif
116 #include <ncurses_dll.h>
118 extern "C" {
119 #if HAVE_VALUES_H
120 # include <values.h>
121 #endif
123 #include <assert.h>
124 #include <eti.h>
125 #include <errno.h>
128 // Language features
129 #if CPP_HAS_PARAM_INIT
130 #define NCURSES_PARAM_INIT(value) = value
131 #else
132 #define NCURSES_PARAM_INIT(value) /*nothing*/
133 #endif
135 #if CPP_HAS_STATIC_CAST
136 #define STATIC_CAST(s) static_cast<s>
137 #else
138 #define STATIC_CAST(s) (s)
139 #endif
141 // Forward Declarations
142 class NCURSES_IMPEXP NCursesPanel;
143 class NCURSES_IMPEXP NCursesMenu;
144 class NCURSES_IMPEXP NCursesForm;
146 class NCURSES_IMPEXP NCursesException
148 public:
149 const char *message;
150 int errorno;
152 NCursesException (const char* msg, int err)
153 : message(msg), errorno (err)
156 NCursesException (const char* msg)
157 : message(msg), errorno (E_SYSTEM_ERROR)
160 NCursesException& operator=(const NCursesException& rhs)
162 errorno = rhs.errorno;
163 return *this;
166 NCursesException(const NCursesException& rhs)
167 : message(rhs.message), errorno(rhs.errorno)
171 virtual const char *classname() const {
172 return "NCursesWindow";
175 virtual ~NCursesException()
180 class NCURSES_IMPEXP NCursesPanelException : public NCursesException
182 public:
183 const NCursesPanel* p;
185 NCursesPanelException (const char *msg, int err) :
186 NCursesException (msg, err),
187 p (0)
190 NCursesPanelException (const NCursesPanel* panel,
191 const char *msg,
192 int err) :
193 NCursesException (msg, err),
194 p (panel)
197 NCursesPanelException (int err) :
198 NCursesException ("panel library error", err),
199 p (0)
202 NCursesPanelException (const NCursesPanel* panel,
203 int err) :
204 NCursesException ("panel library error", err),
205 p (panel)
208 NCursesPanelException& operator=(const NCursesPanelException& rhs)
210 if (this != &rhs) {
211 NCursesException::operator=(rhs);
212 p = rhs.p;
214 return *this;
217 NCursesPanelException(const NCursesPanelException& rhs)
218 : NCursesException(rhs), p(rhs.p)
222 virtual const char *classname() const {
223 return "NCursesPanel";
226 virtual ~NCursesPanelException()
231 class NCURSES_IMPEXP NCursesMenuException : public NCursesException
233 public:
234 const NCursesMenu* m;
236 NCursesMenuException (const char *msg, int err) :
237 NCursesException (msg, err),
238 m (0)
241 NCursesMenuException (const NCursesMenu* menu,
242 const char *msg,
243 int err) :
244 NCursesException (msg, err),
245 m (menu)
248 NCursesMenuException (int err) :
249 NCursesException ("menu library error", err),
250 m (0)
253 NCursesMenuException (const NCursesMenu* menu,
254 int err) :
255 NCursesException ("menu library error", err),
256 m (menu)
259 NCursesMenuException& operator=(const NCursesMenuException& rhs)
261 if (this != &rhs) {
262 NCursesException::operator=(rhs);
263 m = rhs.m;
265 return *this;
268 NCursesMenuException(const NCursesMenuException& rhs)
269 : NCursesException(rhs), m(rhs.m)
273 virtual const char *classname() const {
274 return "NCursesMenu";
277 virtual ~NCursesMenuException()
282 class NCURSES_IMPEXP NCursesFormException : public NCursesException
284 public:
285 const NCursesForm* f;
287 NCursesFormException (const char *msg, int err) :
288 NCursesException (msg, err),
289 f (0)
292 NCursesFormException (const NCursesForm* form,
293 const char *msg,
294 int err) :
295 NCursesException (msg, err),
296 f (form)
299 NCursesFormException (int err) :
300 NCursesException ("form library error", err),
301 f (0)
304 NCursesFormException (const NCursesForm* form,
305 int err) :
306 NCursesException ("form library error", err),
307 f (form)
310 NCursesFormException& operator=(const NCursesFormException& rhs)
312 if (this != &rhs) {
313 NCursesException::operator=(rhs);
314 f = rhs.f;
316 return *this;
319 NCursesFormException(const NCursesFormException& rhs)
320 : NCursesException(rhs), f(rhs.f)
324 virtual const char *classname() const {
325 return "NCursesForm";
328 virtual ~NCursesFormException()
333 #if !((defined(__GNUG__) && defined(__EXCEPTIONS)) || defined(__SUNPRO_CC))
334 # if HAVE_IOSTREAM
335 # include <iostream>
336 # if IOSTREAM_NAMESPACE
337 using std::cerr;
338 using std::endl;
339 # endif
340 # else
341 # include <iostream.h>
342 # endif
343 extern "C" void exit(int);
344 #endif
346 inline void THROW(const NCursesException *e) {
347 #if defined(__GNUG__) && defined(__EXCEPTIONS)
348 # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
349 (*lib_error_handler)(e ? e->classname() : "", e ? e->message : "");
350 #else
351 #define CPP_HAS_TRY_CATCH 1
352 #endif
353 #elif defined(__SUNPRO_CC)
354 # if !defined(__SUNPRO_CC_COMPAT) || (__SUNPRO_CC_COMPAT < 5)
355 genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
356 #else
357 #define CPP_HAS_TRY_CATCH 1
358 #endif
359 #else
360 if (e)
361 cerr << e->message << endl;
362 exit(0);
363 #endif
365 #ifndef CPP_HAS_TRY_CATCH
366 #define CPP_HAS_TRY_CATCH 0
367 #define NCURSES_CPP_TRY /* nothing */
368 #define NCURSES_CPP_CATCH(e) if (false)
369 #define THROWS(s) /* nothing */
370 #define THROW2(s,t) /* nothing */
371 #elif CPP_HAS_TRY_CATCH
372 throw *e;
373 #define NCURSES_CPP_TRY try
374 #define NCURSES_CPP_CATCH(e) catch(e)
375 #define THROWS(s) throw(s)
376 #define THROW2(s,t) throw(s,t)
377 #endif
380 #endif /* NCURSES_ETIP_H_incl */