1 // * This makes emacs happy -*-Mode: C++;-*-
2 /****************************************************************************
3 * Copyright (c) 1998-2003,2005 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.32 2005/08/06 19:55:57 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
52 #ifndef HAVE_STRSTREAM_H
53 #define HAVE_STRSTREAM_H 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
80 #ifndef USE_STRSTREAM_VSCAN
81 #define USE_STRSTREAM_VSCAN 0
84 #ifndef USE_STRSTREAM_VSCAN_CAST
85 #define USE_STRSTREAM_VSCAN_CAST 0
89 # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
97 # if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H
98 # if ETIP_NEEDS_MATH_H
99 # if ETIP_NEEDS_MATH_EXCEPTION
101 # define exception math_exception
106 # define exception builtin_exception
107 # if HAVE_GPP_BUILTIN_H
108 # include <gpp/builtin.h>
109 # elif HAVE_GXX_BUILTIN_H
110 # include <g++/builtin.h>
112 # include <builtin.h>
116 #elif defined (__SUNPRO_CC)
117 # include <generic.h>
120 #include <ncurses_dll.h>
133 #if CPP_HAS_PARAM_INIT
134 #define NCURSES_PARAM_INIT(value) = value
136 #define NCURSES_PARAM_INIT(value) /*nothing*/
139 #if CPP_HAS_STATIC_CAST
140 #define STATIC_CAST(s) static_cast<s>
142 #define STATIC_CAST(s) (s)
145 // Forward Declarations
146 class NCURSES_IMPEXP NCursesPanel;
147 class NCURSES_IMPEXP NCursesMenu;
148 class NCURSES_IMPEXP NCursesForm;
150 class NCURSES_IMPEXP NCursesException
156 NCursesException (const char* msg, int err)
157 : message(msg), errorno (err)
160 NCursesException (const char* msg)
161 : message(msg), errorno (E_SYSTEM_ERROR)
164 NCursesException& operator=(const NCursesException& rhs)
166 errorno = rhs.errorno;
170 NCursesException(const NCursesException& rhs)
171 : message(rhs.message), errorno(rhs.errorno)
175 virtual const char *classname() const {
176 return "NCursesWindow";
179 virtual ~NCursesException()
184 class NCURSES_IMPEXP NCursesPanelException : public NCursesException
187 const NCursesPanel* p;
189 NCursesPanelException (const char *msg, int err) :
190 NCursesException (msg, err),
194 NCursesPanelException (const NCursesPanel* panel,
197 NCursesException (msg, err),
201 NCursesPanelException (int err) :
202 NCursesException ("panel library error", err),
206 NCursesPanelException (const NCursesPanel* panel,
208 NCursesException ("panel library error", err),
212 NCursesPanelException& operator=(const NCursesPanelException& rhs)
215 NCursesException::operator=(rhs);
221 NCursesPanelException(const NCursesPanelException& rhs)
222 : NCursesException(rhs), p(rhs.p)
226 virtual const char *classname() const {
227 return "NCursesPanel";
230 virtual ~NCursesPanelException()
235 class NCURSES_IMPEXP NCursesMenuException : public NCursesException
238 const NCursesMenu* m;
240 NCursesMenuException (const char *msg, int err) :
241 NCursesException (msg, err),
245 NCursesMenuException (const NCursesMenu* menu,
248 NCursesException (msg, err),
252 NCursesMenuException (int err) :
253 NCursesException ("menu library error", err),
257 NCursesMenuException (const NCursesMenu* menu,
259 NCursesException ("menu library error", err),
263 NCursesMenuException& operator=(const NCursesMenuException& rhs)
266 NCursesException::operator=(rhs);
272 NCursesMenuException(const NCursesMenuException& rhs)
273 : NCursesException(rhs), m(rhs.m)
277 virtual const char *classname() const {
278 return "NCursesMenu";
281 virtual ~NCursesMenuException()
286 class NCURSES_IMPEXP NCursesFormException : public NCursesException
289 const NCursesForm* f;
291 NCursesFormException (const char *msg, int err) :
292 NCursesException (msg, err),
296 NCursesFormException (const NCursesForm* form,
299 NCursesException (msg, err),
303 NCursesFormException (int err) :
304 NCursesException ("form library error", err),
308 NCursesFormException (const NCursesForm* form,
310 NCursesException ("form library error", err),
314 NCursesFormException& operator=(const NCursesFormException& rhs)
317 NCursesException::operator=(rhs);
323 NCursesFormException(const NCursesFormException& rhs)
324 : NCursesException(rhs), f(rhs.f)
328 virtual const char *classname() const {
329 return "NCursesForm";
332 virtual ~NCursesFormException()
337 #if !((defined(__GNUG__) && defined(__EXCEPTIONS)) || defined(__SUNPRO_CC))
338 # include <iostream.h>
339 extern "C" void exit(int);
342 inline void THROW(const NCursesException *e) {
343 #if defined(__GNUG__) && defined(__EXCEPTIONS)
344 # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
345 (*lib_error_handler)(e?e->classname():"",e?e->message:"");
349 #elif defined(__SUNPRO_CC)
350 # if !defined(__SUNPRO_CC_COMPAT) || (__SUNPRO_CC_COMPAT < 5)
351 genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
357 cerr << e->message << endl;
364 #endif /* NCURSES_ETIP_H_incl */