1 // * This makes emacs happy -*-Mode: C++;-*-
2 /****************************************************************************
3 * Copyright 2018,2020 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.45 2020/05/24 01:40:20 anonymous.maarten 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 NCursesException (const char* msg)
158 : message(msg), errorno (E_SYSTEM_ERROR)
161 NCursesException& operator=(const NCursesException& rhs)
163 errorno = rhs.errorno;
167 NCursesException(const NCursesException& rhs)
168 : message(rhs.message), errorno(rhs.errorno)
172 virtual const char *classname() const {
173 return "NCursesWindow";
176 virtual ~NCursesException()
181 class NCURSES_CXX_IMPEXP NCursesPanelException : public NCursesException
184 const NCursesPanel* p;
186 NCursesPanelException (const char *msg, int err) :
187 NCursesException (msg, err),
191 NCursesPanelException (const NCursesPanel* panel,
194 NCursesException (msg, err),
198 NCursesPanelException (int err) :
199 NCursesException ("panel library error", err),
203 NCursesPanelException (const NCursesPanel* panel,
205 NCursesException ("panel library error", err),
209 NCursesPanelException& operator=(const NCursesPanelException& rhs)
212 NCursesException::operator=(rhs);
218 NCursesPanelException(const NCursesPanelException& rhs)
219 : NCursesException(rhs), p(rhs.p)
223 virtual const char *classname() const {
224 return "NCursesPanel";
227 virtual ~NCursesPanelException()
232 class NCURSES_CXX_IMPEXP NCursesMenuException : public NCursesException
235 const NCursesMenu* m;
237 NCursesMenuException (const char *msg, int err) :
238 NCursesException (msg, err),
242 NCursesMenuException (const NCursesMenu* menu,
245 NCursesException (msg, err),
249 NCursesMenuException (int err) :
250 NCursesException ("menu library error", err),
254 NCursesMenuException (const NCursesMenu* menu,
256 NCursesException ("menu library error", err),
260 NCursesMenuException& operator=(const NCursesMenuException& rhs)
263 NCursesException::operator=(rhs);
269 NCursesMenuException(const NCursesMenuException& rhs)
270 : NCursesException(rhs), m(rhs.m)
274 virtual const char *classname() const {
275 return "NCursesMenu";
278 virtual ~NCursesMenuException()
283 class NCURSES_CXX_IMPEXP NCursesFormException : public NCursesException
286 const NCursesForm* f;
288 NCursesFormException (const char *msg, int err) :
289 NCursesException (msg, err),
293 NCursesFormException (const NCursesForm* form,
296 NCursesException (msg, err),
300 NCursesFormException (int err) :
301 NCursesException ("form library error", err),
305 NCursesFormException (const NCursesForm* form,
307 NCursesException ("form library error", err),
311 NCursesFormException& operator=(const NCursesFormException& rhs)
314 NCursesException::operator=(rhs);
320 NCursesFormException(const NCursesFormException& rhs)
321 : NCursesException(rhs), f(rhs.f)
325 virtual const char *classname() const {
326 return "NCursesForm";
329 virtual ~NCursesFormException()
334 #if !((defined(__GNUG__) && defined(__EXCEPTIONS) && (__GNUG__ < 7)) || defined(__SUNPRO_CC))
337 # if IOSTREAM_NAMESPACE
342 # include <iostream.h>
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 : "");
350 # elif (__GNUG__ >= 7)
351 // g++ 7.0 warns about deprecation, but lacks the predefined symbols
353 std::cerr << "Found a problem - goodbye" << std::endl;
356 # define CPP_HAS_TRY_CATCH 1
358 #elif defined(__SUNPRO_CC)
359 # if !defined(__SUNPRO_CC_COMPAT) || (__SUNPRO_CC_COMPAT < 5)
360 genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
362 # define CPP_HAS_TRY_CATCH 1
366 cerr << e->message << endl;
370 #ifndef CPP_HAS_TRY_CATCH
371 #define CPP_HAS_TRY_CATCH 0
372 #define NCURSES_CPP_TRY /* nothing */
373 #define NCURSES_CPP_CATCH(e) if (false)
374 #define THROWS(s) /* nothing */
375 #define THROW2(s,t) /* nothing */
376 #elif CPP_HAS_TRY_CATCH
378 #define NCURSES_CPP_TRY try
379 #define NCURSES_CPP_CATCH(e) catch(e)
380 #if defined(__cpp_noexcept_function_type) && (__cpp_noexcept_function_type >= 201510)
381 // C++17 deprecates the usage of throw().
382 #define THROWS(s) /* nothing */
383 #define THROW2(s,t) /* nothing */
385 #define THROWS(s) throw(s)
386 #define THROW2(s,t) throw(s,t)
391 #endif /* NCURSES_ETIP_H_incl */