1 // * This makes emacs happy -*-Mode: C++;-*-
2 /****************************************************************************
3 * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. *
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: *
13 * The above copyright notice and this permission notice shall be included *
14 * in all copies or substantial portions of the Software. *
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. *
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 *
28 ****************************************************************************/
30 /****************************************************************************
31 * Author: Juergen Pfeifer, 1997 *
32 ****************************************************************************/
34 // $Id: etip.h.in,v 1.36 2007/04/07 18:56:32 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
44 #ifndef HAVE_GXX_BUILTIN_H
45 #define HAVE_GXX_BUILTIN_H 0
48 #ifndef HAVE_GPP_BUILTIN_H
49 #define HAVE_GPP_BUILTIN_H 0
53 #define HAVE_IOSTREAM 0
57 #define HAVE_TYPEINFO 0
61 #define HAVE_VALUES_H 0
64 #ifndef ETIP_NEEDS_MATH_H
65 #define ETIP_NEEDS_MATH_H 0
68 #ifndef ETIP_NEEDS_MATH_EXCEPTION
69 #define ETIP_NEEDS_MATH_EXCEPTION 0
72 #ifndef CPP_HAS_PARAM_INIT
73 #define CPP_HAS_PARAM_INIT 0
76 #ifndef CPP_HAS_STATIC_CAST
77 #define CPP_HAS_STATIC_CAST 0 // workaround for g++ 2.95.3
81 # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
89 # if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H
90 # if ETIP_NEEDS_MATH_H
91 # if ETIP_NEEDS_MATH_EXCEPTION
93 # define exception math_exception
98 # define exception builtin_exception
99 # if HAVE_GPP_BUILTIN_H
100 # include <gpp/builtin.h>
101 # elif HAVE_GXX_BUILTIN_H
102 # include <g++/builtin.h>
104 # include <builtin.h>
108 #elif defined (__SUNPRO_CC)
109 # include <generic.h>
112 #include <ncurses_dll.h>
125 #if CPP_HAS_PARAM_INIT
126 #define NCURSES_PARAM_INIT(value) = value
128 #define NCURSES_PARAM_INIT(value) /*nothing*/
131 #if CPP_HAS_STATIC_CAST
132 #define STATIC_CAST(s) static_cast<s>
134 #define STATIC_CAST(s) (s)
137 // Forward Declarations
138 class NCURSES_IMPEXP NCursesPanel;
139 class NCURSES_IMPEXP NCursesMenu;
140 class NCURSES_IMPEXP NCursesForm;
142 class NCURSES_IMPEXP NCursesException
148 NCursesException (const char* msg, int err)
149 : message(msg), errorno (err)
152 NCursesException (const char* msg)
153 : message(msg), errorno (E_SYSTEM_ERROR)
156 NCursesException& operator=(const NCursesException& rhs)
158 errorno = rhs.errorno;
162 NCursesException(const NCursesException& rhs)
163 : message(rhs.message), errorno(rhs.errorno)
167 virtual const char *classname() const {
168 return "NCursesWindow";
171 virtual ~NCursesException()
176 class NCURSES_IMPEXP NCursesPanelException : public NCursesException
179 const NCursesPanel* p;
181 NCursesPanelException (const char *msg, int err) :
182 NCursesException (msg, err),
186 NCursesPanelException (const NCursesPanel* panel,
189 NCursesException (msg, err),
193 NCursesPanelException (int err) :
194 NCursesException ("panel library error", err),
198 NCursesPanelException (const NCursesPanel* panel,
200 NCursesException ("panel library error", err),
204 NCursesPanelException& operator=(const NCursesPanelException& rhs)
207 NCursesException::operator=(rhs);
213 NCursesPanelException(const NCursesPanelException& rhs)
214 : NCursesException(rhs), p(rhs.p)
218 virtual const char *classname() const {
219 return "NCursesPanel";
222 virtual ~NCursesPanelException()
227 class NCURSES_IMPEXP NCursesMenuException : public NCursesException
230 const NCursesMenu* m;
232 NCursesMenuException (const char *msg, int err) :
233 NCursesException (msg, err),
237 NCursesMenuException (const NCursesMenu* menu,
240 NCursesException (msg, err),
244 NCursesMenuException (int err) :
245 NCursesException ("menu library error", err),
249 NCursesMenuException (const NCursesMenu* menu,
251 NCursesException ("menu library error", err),
255 NCursesMenuException& operator=(const NCursesMenuException& rhs)
258 NCursesException::operator=(rhs);
264 NCursesMenuException(const NCursesMenuException& rhs)
265 : NCursesException(rhs), m(rhs.m)
269 virtual const char *classname() const {
270 return "NCursesMenu";
273 virtual ~NCursesMenuException()
278 class NCURSES_IMPEXP NCursesFormException : public NCursesException
281 const NCursesForm* f;
283 NCursesFormException (const char *msg, int err) :
284 NCursesException (msg, err),
288 NCursesFormException (const NCursesForm* form,
291 NCursesException (msg, err),
295 NCursesFormException (int err) :
296 NCursesException ("form library error", err),
300 NCursesFormException (const NCursesForm* form,
302 NCursesException ("form library error", err),
306 NCursesFormException& operator=(const NCursesFormException& rhs)
309 NCursesException::operator=(rhs);
315 NCursesFormException(const NCursesFormException& rhs)
316 : NCursesException(rhs), f(rhs.f)
320 virtual const char *classname() const {
321 return "NCursesForm";
324 virtual ~NCursesFormException()
329 #if !((defined(__GNUG__) && defined(__EXCEPTIONS)) || defined(__SUNPRO_CC))
335 # include <iostream.h>
337 extern "C" void exit(int);
340 inline void THROW(const NCursesException *e) {
341 #if defined(__GNUG__) && defined(__EXCEPTIONS)
342 # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
343 (*lib_error_handler)(e ? e->classname() : "", e ? e->message : "");
345 #define CPP_HAS_TRY_CATCH 1
347 #elif defined(__SUNPRO_CC)
348 # if !defined(__SUNPRO_CC_COMPAT) || (__SUNPRO_CC_COMPAT < 5)
349 genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
351 #define CPP_HAS_TRY_CATCH 1
355 cerr << e->message << endl;
359 #ifndef CPP_HAS_TRY_CATCH
360 #define CPP_HAS_TRY_CATCH 0
361 #define NCURSES_CPP_TRY /* nothing */
362 #define NCURSES_CPP_CATCH(e) if (false)
363 #define THROWS(s) /* nothing */
364 #elif CPP_HAS_TRY_CATCH
366 #define NCURSES_CPP_TRY try
367 #define NCURSES_CPP_CATCH(e) catch(e)
368 #define THROWS(s) throw(s)
372 #endif /* NCURSES_ETIP_H_incl */