1 // * This makes emacs happy -*-Mode: C++;-*-
2 /****************************************************************************
3 * Copyright (c) 1998-2007,2008 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.37 2008/08/30 19:27: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 1
57 #define HAVE_TYPEINFO 1
61 #define HAVE_VALUES_H 0
64 #ifndef ETIP_NEEDS_MATH_H
65 #define ETIP_NEEDS_MATH_H 1
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 1
80 #ifndef IOSTREAM_NAMESPACE
81 #define IOSTREAM_NAMESPACE 1
85 # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
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
97 # define exception math_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>
108 # include <builtin.h>
112 #elif defined (__SUNPRO_CC)
113 # include <generic.h>
116 #include <ncurses_dll.h>
129 #if CPP_HAS_PARAM_INIT
130 #define NCURSES_PARAM_INIT(value) = value
132 #define NCURSES_PARAM_INIT(value) /*nothing*/
135 #if CPP_HAS_STATIC_CAST
136 #define STATIC_CAST(s) static_cast<s>
138 #define STATIC_CAST(s) (s)
141 // Forward Declarations
142 class NCURSES_IMPEXP NCursesPanel
;
143 class NCURSES_IMPEXP NCursesMenu
;
144 class NCURSES_IMPEXP NCursesForm
;
146 class NCURSES_IMPEXP NCursesException
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
;
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
183 const NCursesPanel
* p
;
185 NCursesPanelException (const char *msg
, int err
) :
186 NCursesException (msg
, err
),
190 NCursesPanelException (const NCursesPanel
* panel
,
193 NCursesException (msg
, err
),
197 NCursesPanelException (int err
) :
198 NCursesException ("panel library error", err
),
202 NCursesPanelException (const NCursesPanel
* panel
,
204 NCursesException ("panel library error", err
),
208 NCursesPanelException
& operator=(const NCursesPanelException
& rhs
)
211 NCursesException::operator=(rhs
);
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
234 const NCursesMenu
* m
;
236 NCursesMenuException (const char *msg
, int err
) :
237 NCursesException (msg
, err
),
241 NCursesMenuException (const NCursesMenu
* menu
,
244 NCursesException (msg
, err
),
248 NCursesMenuException (int err
) :
249 NCursesException ("menu library error", err
),
253 NCursesMenuException (const NCursesMenu
* menu
,
255 NCursesException ("menu library error", err
),
259 NCursesMenuException
& operator=(const NCursesMenuException
& rhs
)
262 NCursesException::operator=(rhs
);
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
285 const NCursesForm
* f
;
287 NCursesFormException (const char *msg
, int err
) :
288 NCursesException (msg
, err
),
292 NCursesFormException (const NCursesForm
* form
,
295 NCursesException (msg
, err
),
299 NCursesFormException (int err
) :
300 NCursesException ("form library error", err
),
304 NCursesFormException (const NCursesForm
* form
,
306 NCursesException ("form library error", err
),
310 NCursesFormException
& operator=(const NCursesFormException
& rhs
)
313 NCursesException::operator=(rhs
);
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))
336 # if IOSTREAM_NAMESPACE
341 # include <iostream.h>
343 extern "C" void exit(int);
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
: "");
351 #define CPP_HAS_TRY_CATCH 1
353 #elif defined(__SUNPRO_CC)
354 # if !defined(__SUNPRO_CC_COMPAT) || (__SUNPRO_CC_COMPAT < 5)
355 genericerror(1, ((e
!= 0) ? (char *)(e
->message
) : ""));
357 #define CPP_HAS_TRY_CATCH 1
361 cerr
<< e
->message
<< endl
;
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 #elif CPP_HAS_TRY_CATCH
372 #define NCURSES_CPP_TRY try
373 #define NCURSES_CPP_CATCH(e) catch(e)
374 #define THROWS(s) throw(s)
378 #endif /* NCURSES_ETIP_H_incl */