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.34 2007/01/27 18:49:00 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_TYPEINFO 0
57 #define HAVE_VALUES_H 0
60 #ifndef ETIP_NEEDS_MATH_H
61 #define ETIP_NEEDS_MATH_H 0
64 #ifndef ETIP_NEEDS_MATH_EXCEPTION
65 #define ETIP_NEEDS_MATH_EXCEPTION 0
68 #ifndef CPP_HAS_PARAM_INIT
69 #define CPP_HAS_PARAM_INIT 0
72 #ifndef CPP_HAS_STATIC_CAST
73 #define CPP_HAS_STATIC_CAST 0 // workaround for g++ 2.95.3
77 # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
85 # if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H
86 # if ETIP_NEEDS_MATH_H
87 # if ETIP_NEEDS_MATH_EXCEPTION
89 # define exception math_exception
94 # define exception builtin_exception
95 # if HAVE_GPP_BUILTIN_H
96 # include <gpp/builtin.h>
97 # elif HAVE_GXX_BUILTIN_H
98 # include <g++/builtin.h>
100 # include <builtin.h>
104 #elif defined (__SUNPRO_CC)
105 # include <generic.h>
108 #include <ncurses_dll.h>
121 #if CPP_HAS_PARAM_INIT
122 #define NCURSES_PARAM_INIT(value) = value
124 #define NCURSES_PARAM_INIT(value) /*nothing*/
127 #if CPP_HAS_STATIC_CAST
128 #define STATIC_CAST(s) static_cast<s>
130 #define STATIC_CAST(s) (s)
133 // Forward Declarations
134 class NCURSES_IMPEXP NCursesPanel;
135 class NCURSES_IMPEXP NCursesMenu;
136 class NCURSES_IMPEXP NCursesForm;
138 class NCURSES_IMPEXP NCursesException
144 NCursesException (const char* msg, int err)
145 : message(msg), errorno (err)
148 NCursesException (const char* msg)
149 : message(msg), errorno (E_SYSTEM_ERROR)
152 NCursesException& operator=(const NCursesException& rhs)
154 errorno = rhs.errorno;
158 NCursesException(const NCursesException& rhs)
159 : message(rhs.message), errorno(rhs.errorno)
163 virtual const char *classname() const {
164 return "NCursesWindow";
167 virtual ~NCursesException()
172 class NCURSES_IMPEXP NCursesPanelException : public NCursesException
175 const NCursesPanel* p;
177 NCursesPanelException (const char *msg, int err) :
178 NCursesException (msg, err),
182 NCursesPanelException (const NCursesPanel* panel,
185 NCursesException (msg, err),
189 NCursesPanelException (int err) :
190 NCursesException ("panel library error", err),
194 NCursesPanelException (const NCursesPanel* panel,
196 NCursesException ("panel library error", err),
200 NCursesPanelException& operator=(const NCursesPanelException& rhs)
203 NCursesException::operator=(rhs);
209 NCursesPanelException(const NCursesPanelException& rhs)
210 : NCursesException(rhs), p(rhs.p)
214 virtual const char *classname() const {
215 return "NCursesPanel";
218 virtual ~NCursesPanelException()
223 class NCURSES_IMPEXP NCursesMenuException : public NCursesException
226 const NCursesMenu* m;
228 NCursesMenuException (const char *msg, int err) :
229 NCursesException (msg, err),
233 NCursesMenuException (const NCursesMenu* menu,
236 NCursesException (msg, err),
240 NCursesMenuException (int err) :
241 NCursesException ("menu library error", err),
245 NCursesMenuException (const NCursesMenu* menu,
247 NCursesException ("menu library error", err),
251 NCursesMenuException& operator=(const NCursesMenuException& rhs)
254 NCursesException::operator=(rhs);
260 NCursesMenuException(const NCursesMenuException& rhs)
261 : NCursesException(rhs), m(rhs.m)
265 virtual const char *classname() const {
266 return "NCursesMenu";
269 virtual ~NCursesMenuException()
274 class NCURSES_IMPEXP NCursesFormException : public NCursesException
277 const NCursesForm* f;
279 NCursesFormException (const char *msg, int err) :
280 NCursesException (msg, err),
284 NCursesFormException (const NCursesForm* form,
287 NCursesException (msg, err),
291 NCursesFormException (int err) :
292 NCursesException ("form library error", err),
296 NCursesFormException (const NCursesForm* form,
298 NCursesException ("form library error", err),
302 NCursesFormException& operator=(const NCursesFormException& rhs)
305 NCursesException::operator=(rhs);
311 NCursesFormException(const NCursesFormException& rhs)
312 : NCursesException(rhs), f(rhs.f)
316 virtual const char *classname() const {
317 return "NCursesForm";
320 virtual ~NCursesFormException()
325 #if !((defined(__GNUG__) && defined(__EXCEPTIONS)) || defined(__SUNPRO_CC))
326 # include <iostream.h>
327 extern "C" void exit(int);
330 inline void THROW(const NCursesException *e) {
331 #if defined(__GNUG__) && defined(__EXCEPTIONS)
332 # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
333 (*lib_error_handler)(e?e->classname():"",e?e->message:"");
337 #elif defined(__SUNPRO_CC)
338 # if !defined(__SUNPRO_CC_COMPAT) || (__SUNPRO_CC_COMPAT < 5)
339 genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
345 cerr << e->message << endl;
352 #endif /* NCURSES_ETIP_H_incl */