1 // * This makes emacs happy -*-Mode: C++;-*-
2 /****************************************************************************
3 * Copyright 2018-2020,2021 Thomas E. Dickey *
4 * Copyright 1998-2012,2017 Free Software Foundation, Inc. *
6 * Permission is hereby granted, free of charge, to any person obtaining a *
7 * copy of this software and associated documentation files (the *
8 * "Software"), to deal in the Software without restriction, including *
9 * without limitation the rights to use, copy, modify, merge, publish, *
10 * distribute, distribute with modifications, sublicense, and/or sell *
11 * copies of the Software, and to permit persons to whom the Software is *
12 * furnished to do so, subject to the following conditions: *
14 * The above copyright notice and this permission notice shall be included *
15 * in all copies or substantial portions of the Software. *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25 * Except as contained in this notice, the name(s) of the above copyright *
26 * holders shall not be used in advertising or otherwise to promote the *
27 * sale, use or other dealings in this Software without prior written *
29 ****************************************************************************/
31 /****************************************************************************
32 * Author: Juergen Pfeifer, 1997 *
33 ****************************************************************************/
35 // $Id: etip.h.in,v 1.46 2021/04/17 17:59:57 tom Exp $
37 #ifndef NCURSES_ETIP_H_incl
38 #define NCURSES_ETIP_H_incl 1
40 // These are substituted at configure/build time
41 #ifndef HAVE_BUILTIN_H
42 #define HAVE_BUILTIN_H 0
45 #ifndef HAVE_GXX_BUILTIN_H
46 #define HAVE_GXX_BUILTIN_H 0
49 #ifndef HAVE_GPP_BUILTIN_H
50 #define HAVE_GPP_BUILTIN_H 0
54 #define HAVE_IOSTREAM 0
58 #define HAVE_TYPEINFO 0
62 #define HAVE_VALUES_H 0
65 #ifndef ETIP_NEEDS_MATH_H
66 #define ETIP_NEEDS_MATH_H 0
69 #ifndef ETIP_NEEDS_MATH_EXCEPTION
70 #define ETIP_NEEDS_MATH_EXCEPTION 0
73 #ifndef CPP_HAS_PARAM_INIT
74 #define CPP_HAS_PARAM_INIT 0
77 #ifndef CPP_HAS_STATIC_CAST
78 #define CPP_HAS_STATIC_CAST 0 // workaround for g++ 2.95.3
81 #ifndef IOSTREAM_NAMESPACE
82 #define IOSTREAM_NAMESPACE 0
86 # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
94 # if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H
95 # if ETIP_NEEDS_MATH_H
96 # if ETIP_NEEDS_MATH_EXCEPTION
98 # define exception math_exception
103 # define exception builtin_exception
104 # if HAVE_GPP_BUILTIN_H
105 # include <gpp/builtin.h>
106 # elif HAVE_GXX_BUILTIN_H
107 # include <g++/builtin.h>
109 # include <builtin.h>
113 #elif defined (__SUNPRO_CC)
114 # include <generic.h>
130 #if CPP_HAS_PARAM_INIT
131 #define NCURSES_PARAM_INIT(value) = value
133 #define NCURSES_PARAM_INIT(value) /*nothing*/
136 #if CPP_HAS_STATIC_CAST
137 #define STATIC_CAST(s) static_cast<s>
139 #define STATIC_CAST(s) (s)
142 // Forward Declarations
143 class NCURSES_CXX_IMPEXP NCursesPanel;
144 class NCURSES_CXX_IMPEXP NCursesMenu;
145 class NCURSES_CXX_IMPEXP NCursesForm;
147 class NCURSES_CXX_IMPEXP NCursesException
153 NCursesException (const char* msg, int err)
154 : message(msg), errorno (err)
157 explicit NCursesException (const char* msg)
158 : message(msg), errorno (E_SYSTEM_ERROR)
161 NCursesException& operator=(const NCursesException& rhs)
163 message = rhs.message;
164 errorno = rhs.errorno;
168 NCursesException(const NCursesException& rhs)
169 : message(rhs.message), errorno(rhs.errorno)
173 virtual const char *classname() const {
174 return "NCursesWindow";
177 virtual ~NCursesException()
182 class NCURSES_CXX_IMPEXP NCursesPanelException : public NCursesException
185 const NCursesPanel* p;
187 NCursesPanelException (const char *msg, int err) :
188 NCursesException (msg, err),
192 NCursesPanelException (const NCursesPanel* panel,
195 NCursesException (msg, err),
199 explicit NCursesPanelException (int err) :
200 NCursesException ("panel library error", err),
204 NCursesPanelException (const NCursesPanel* panel,
206 NCursesException ("panel library error", err),
210 NCursesPanelException& operator=(const NCursesPanelException& rhs)
213 NCursesException::operator=(rhs);
219 NCursesPanelException(const NCursesPanelException& rhs)
220 : NCursesException(rhs), p(rhs.p)
224 virtual const char *classname() const {
225 return "NCursesPanel";
228 virtual ~NCursesPanelException()
233 class NCURSES_CXX_IMPEXP NCursesMenuException : public NCursesException
236 const NCursesMenu* m;
238 NCursesMenuException (const char *msg, int err) :
239 NCursesException (msg, err),
243 NCursesMenuException (const NCursesMenu* menu,
246 NCursesException (msg, err),
250 explicit NCursesMenuException (int err) :
251 NCursesException ("menu library error", err),
255 NCursesMenuException (const NCursesMenu* menu,
257 NCursesException ("menu library error", err),
261 NCursesMenuException& operator=(const NCursesMenuException& rhs)
264 NCursesException::operator=(rhs);
270 NCursesMenuException(const NCursesMenuException& rhs)
271 : NCursesException(rhs), m(rhs.m)
275 virtual const char *classname() const {
276 return "NCursesMenu";
279 virtual ~NCursesMenuException()
284 class NCURSES_CXX_IMPEXP NCursesFormException : public NCursesException
287 const NCursesForm* f;
289 NCursesFormException (const char *msg, int err) :
290 NCursesException (msg, err),
294 NCursesFormException (const NCursesForm* form,
297 NCursesException (msg, err),
301 explicit NCursesFormException (int err) :
302 NCursesException ("form library error", err),
306 NCursesFormException (const NCursesForm* form,
308 NCursesException ("form library error", err),
312 NCursesFormException& operator=(const NCursesFormException& rhs)
315 NCursesException::operator=(rhs);
321 NCursesFormException(const NCursesFormException& rhs)
322 : NCursesException(rhs), f(rhs.f)
326 virtual const char *classname() const {
327 return "NCursesForm";
330 virtual ~NCursesFormException()
335 #if !((defined(__GNUG__) && defined(__EXCEPTIONS) && (__GNUG__ < 7)) || defined(__SUNPRO_CC))
338 # if IOSTREAM_NAMESPACE
343 # include <iostream.h>
347 inline void THROW(const NCursesException *e) {
348 #if defined(__GNUG__) && defined(__EXCEPTIONS)
349 # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
350 (*lib_error_handler)(e ? e->classname() : "", e ? e->message : "");
351 # elif (__GNUG__ >= 7)
352 // g++ 7.0 warns about deprecation, but lacks the predefined symbols
354 std::cerr << "Found a problem - goodbye" << std::endl;
357 # define CPP_HAS_TRY_CATCH 1
359 #elif defined(__SUNPRO_CC)
360 # if !defined(__SUNPRO_CC_COMPAT) || (__SUNPRO_CC_COMPAT < 5)
361 genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
363 # define CPP_HAS_TRY_CATCH 1
367 cerr << e->message << endl;
371 #ifndef CPP_HAS_TRY_CATCH
372 #define CPP_HAS_TRY_CATCH 0
373 #define NCURSES_CPP_TRY /* nothing */
374 #define NCURSES_CPP_CATCH(e) if (false)
375 #define THROWS(s) /* nothing */
376 #define THROW2(s,t) /* nothing */
377 #elif CPP_HAS_TRY_CATCH
379 #define NCURSES_CPP_TRY try
380 #define NCURSES_CPP_CATCH(e) catch(e)
381 #if defined(__cpp_noexcept_function_type) && (__cpp_noexcept_function_type >= 201510)
382 // C++17 deprecates the usage of throw().
383 #define THROWS(s) /* nothing */
384 #define THROW2(s,t) /* nothing */
386 #define THROWS(s) throw(s)
387 #define THROW2(s,t) throw(s,t)
392 #endif /* NCURSES_ETIP_H_incl */