File indexing completed on 2025-01-18 10:02:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 #ifndef NCURSES_ETIP_H_incl
0038 #define NCURSES_ETIP_H_incl 1
0039
0040
0041 #ifndef HAVE_BUILTIN_H
0042 #define HAVE_BUILTIN_H 0
0043 #endif
0044
0045 #ifndef HAVE_GXX_BUILTIN_H
0046 #define HAVE_GXX_BUILTIN_H 0
0047 #endif
0048
0049 #ifndef HAVE_GPP_BUILTIN_H
0050 #define HAVE_GPP_BUILTIN_H 0
0051 #endif
0052
0053 #ifndef HAVE_IOSTREAM
0054 #define HAVE_IOSTREAM 1
0055 #endif
0056
0057 #ifndef HAVE_TYPEINFO
0058 #define HAVE_TYPEINFO 1
0059 #endif
0060
0061 #ifndef HAVE_VALUES_H
0062 #define HAVE_VALUES_H 0
0063 #endif
0064
0065 #ifndef ETIP_NEEDS_MATH_H
0066 #define ETIP_NEEDS_MATH_H 0
0067 #endif
0068
0069 #ifndef ETIP_NEEDS_MATH_EXCEPTION
0070 #define ETIP_NEEDS_MATH_EXCEPTION 0
0071 #endif
0072
0073 #ifndef CPP_HAS_OVERRIDE
0074 #define CPP_HAS_OVERRIDE 0
0075 #endif
0076
0077 #ifndef CPP_HAS_PARAM_INIT
0078 #define CPP_HAS_PARAM_INIT 0
0079 #endif
0080
0081 #ifndef CPP_HAS_STATIC_CAST
0082 #define CPP_HAS_STATIC_CAST 1
0083 #endif
0084
0085 #ifndef IOSTREAM_NAMESPACE
0086 #define IOSTREAM_NAMESPACE 1
0087 #endif
0088
0089 #ifdef __GNUG__
0090 # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
0091 # if HAVE_TYPEINFO
0092 # include <typeinfo>
0093 # endif
0094 # endif
0095 #endif
0096
0097 #if defined(__GNUG__)
0098 # if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H
0099 # if ETIP_NEEDS_MATH_H
0100 # if ETIP_NEEDS_MATH_EXCEPTION
0101 # undef exception
0102 # define exception math_exception
0103 # endif
0104 # include <math.h>
0105 # endif
0106 # undef exception
0107 # define exception builtin_exception
0108 # if HAVE_GPP_BUILTIN_H
0109 # include <gpp/builtin.h>
0110 # elif HAVE_GXX_BUILTIN_H
0111 # include <g++/builtin.h>
0112 # else
0113 # include <builtin.h>
0114 # endif
0115 # undef exception
0116 # endif
0117 #elif defined (__SUNPRO_CC)
0118 # include <generic.h>
0119 #endif
0120
0121 #include <ncursesw/curses.h>
0122
0123 extern "C" {
0124 #if HAVE_VALUES_H
0125 # include <values.h>
0126 #endif
0127
0128 #include <assert.h>
0129 #include <ncursesw/eti.h>
0130 #include <errno.h>
0131 }
0132
0133
0134 #if CPP_HAS_OVERRIDE
0135 #define NCURSES_OVERRIDE override
0136 #else
0137 #define NCURSES_OVERRIDE
0138 #endif
0139
0140 #if CPP_HAS_PARAM_INIT
0141 #define NCURSES_PARAM_INIT(value) = value
0142 #else
0143 #define NCURSES_PARAM_INIT(value)
0144 #endif
0145
0146 #if CPP_HAS_STATIC_CAST
0147 #define STATIC_CAST(s) static_cast<s>
0148 #else
0149 #define STATIC_CAST(s) (s)
0150 #endif
0151
0152 #ifndef NCURSES_CXX_IMPEXP
0153 #define NCURSES_CXX_IMPEXP
0154 #endif
0155
0156
0157 class NCURSES_CXX_IMPEXP NCursesPanel;
0158 class NCURSES_CXX_IMPEXP NCursesMenu;
0159 class NCURSES_CXX_IMPEXP NCursesForm;
0160
0161 class NCURSES_CXX_IMPEXP NCursesException
0162 {
0163 public:
0164 const char *message;
0165 int errorno;
0166
0167 NCursesException (const char* msg, int err)
0168 : message(msg), errorno (err)
0169 {};
0170
0171 explicit NCursesException (const char* msg)
0172 : message(msg), errorno (E_SYSTEM_ERROR)
0173 {};
0174
0175 NCursesException& operator=(const NCursesException& rhs)
0176 {
0177 message = rhs.message;
0178 errorno = rhs.errorno;
0179 return *this;
0180 }
0181
0182 NCursesException(const NCursesException& rhs)
0183 : message(rhs.message), errorno(rhs.errorno)
0184 {
0185 }
0186
0187 virtual const char *classname() const {
0188 return "NCursesWindow";
0189 }
0190
0191 virtual ~NCursesException()
0192 {
0193 }
0194 };
0195
0196 class NCURSES_CXX_IMPEXP NCursesPanelException : public NCursesException
0197 {
0198 public:
0199 const NCursesPanel* p;
0200
0201 NCursesPanelException (const char *msg, int err) :
0202 NCursesException (msg, err),
0203 p (0)
0204 {};
0205
0206 NCursesPanelException (const NCursesPanel* panel,
0207 const char *msg,
0208 int err) :
0209 NCursesException (msg, err),
0210 p (panel)
0211 {};
0212
0213 explicit NCursesPanelException (int err) :
0214 NCursesException ("panel library error", err),
0215 p (0)
0216 {};
0217
0218 NCursesPanelException (const NCursesPanel* panel,
0219 int err) :
0220 NCursesException ("panel library error", err),
0221 p (panel)
0222 {};
0223
0224 NCursesPanelException& operator=(const NCursesPanelException& rhs)
0225 {
0226 if (this != &rhs) {
0227 NCursesException::operator=(rhs);
0228 p = rhs.p;
0229 }
0230 return *this;
0231 }
0232
0233 NCursesPanelException(const NCursesPanelException& rhs)
0234 : NCursesException(rhs), p(rhs.p)
0235 {
0236 }
0237
0238 virtual const char *classname() const NCURSES_OVERRIDE {
0239 return "NCursesPanel";
0240 }
0241
0242 virtual ~NCursesPanelException()
0243 {
0244 }
0245 };
0246
0247 class NCURSES_CXX_IMPEXP NCursesMenuException : public NCursesException
0248 {
0249 public:
0250 const NCursesMenu* m;
0251
0252 NCursesMenuException (const char *msg, int err) :
0253 NCursesException (msg, err),
0254 m (0)
0255 {};
0256
0257 NCursesMenuException (const NCursesMenu* menu,
0258 const char *msg,
0259 int err) :
0260 NCursesException (msg, err),
0261 m (menu)
0262 {};
0263
0264 explicit NCursesMenuException (int err) :
0265 NCursesException ("menu library error", err),
0266 m (0)
0267 {};
0268
0269 NCursesMenuException (const NCursesMenu* menu,
0270 int err) :
0271 NCursesException ("menu library error", err),
0272 m (menu)
0273 {};
0274
0275 NCursesMenuException& operator=(const NCursesMenuException& rhs)
0276 {
0277 if (this != &rhs) {
0278 NCursesException::operator=(rhs);
0279 m = rhs.m;
0280 }
0281 return *this;
0282 }
0283
0284 NCursesMenuException(const NCursesMenuException& rhs)
0285 : NCursesException(rhs), m(rhs.m)
0286 {
0287 }
0288
0289 virtual const char *classname() const NCURSES_OVERRIDE {
0290 return "NCursesMenu";
0291 }
0292
0293 virtual ~NCursesMenuException()
0294 {
0295 }
0296 };
0297
0298 class NCURSES_CXX_IMPEXP NCursesFormException : public NCursesException
0299 {
0300 public:
0301 const NCursesForm* f;
0302
0303 NCursesFormException (const char *msg, int err) :
0304 NCursesException (msg, err),
0305 f (0)
0306 {};
0307
0308 NCursesFormException (const NCursesForm* form,
0309 const char *msg,
0310 int err) :
0311 NCursesException (msg, err),
0312 f (form)
0313 {};
0314
0315 explicit NCursesFormException (int err) :
0316 NCursesException ("form library error", err),
0317 f (0)
0318 {};
0319
0320 NCursesFormException (const NCursesForm* form,
0321 int err) :
0322 NCursesException ("form library error", err),
0323 f (form)
0324 {};
0325
0326 NCursesFormException& operator=(const NCursesFormException& rhs)
0327 {
0328 if (this != &rhs) {
0329 NCursesException::operator=(rhs);
0330 f = rhs.f;
0331 }
0332 return *this;
0333 }
0334
0335 NCursesFormException(const NCursesFormException& rhs)
0336 : NCursesException(rhs), f(rhs.f)
0337 {
0338 }
0339
0340 virtual const char *classname() const NCURSES_OVERRIDE {
0341 return "NCursesForm";
0342 }
0343
0344 virtual ~NCursesFormException()
0345 {
0346 }
0347 };
0348
0349 #if !((defined(__GNUG__) && defined(__EXCEPTIONS) && (__GNUG__ < 7)) || defined(__SUNPRO_CC))
0350 # if HAVE_IOSTREAM
0351 # include <iostream>
0352 # if IOSTREAM_NAMESPACE
0353 using std::cerr;
0354 using std::endl;
0355 # endif
0356 # else
0357 # include <iostream.h>
0358 # endif
0359 #endif
0360
0361 inline void THROW(const NCursesException *e) {
0362 #if defined(__GNUG__) && defined(__EXCEPTIONS)
0363 # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
0364 (*lib_error_handler)(e ? e->classname() : "", e ? e->message : "");
0365 # elif (__GNUG__ >= 7)
0366
0367 ::endwin();
0368 std::cerr << "Found a problem - goodbye" << std::endl;
0369 exit(EXIT_FAILURE);
0370 # else
0371 # define CPP_HAS_TRY_CATCH 1
0372 # endif
0373 #elif defined(__SUNPRO_CC)
0374 # if !defined(__SUNPRO_CC_COMPAT) || (__SUNPRO_CC_COMPAT < 5)
0375 genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
0376 # else
0377 # define CPP_HAS_TRY_CATCH 1
0378 # endif
0379 #else
0380 if (e)
0381 cerr << e->message << endl;
0382 exit(0);
0383 #endif
0384
0385 #ifndef CPP_HAS_TRY_CATCH
0386 #define CPP_HAS_TRY_CATCH 0
0387 #define NCURSES_CPP_TRY
0388 #define NCURSES_CPP_CATCH(e) if (false)
0389 #define THROWS(s)
0390 #define THROW2(s,t)
0391 #elif CPP_HAS_TRY_CATCH
0392 throw *e;
0393 #define NCURSES_CPP_TRY try
0394 #define NCURSES_CPP_CATCH(e) catch(e)
0395 #if defined(__cpp_noexcept_function_type) && (__cpp_noexcept_function_type >= 201510)
0396
0397 #define THROWS(s)
0398 #define THROW2(s,t)
0399 #else
0400 #define THROWS(s) throw(s)
0401 #define THROW2(s,t) throw(s,t)
0402 #endif
0403 #endif
0404 }
0405
0406 #endif