home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / ncurses / etip.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-11-21  |  8.9 KB  |  373 lines

  1. // * This makes emacs happy -*-Mode: C++;-*-
  2. /****************************************************************************
  3.  * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc.              *
  4.  *                                                                          *
  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:                 *
  12.  *                                                                          *
  13.  * The above copyright notice and this permission notice shall be included  *
  14.  * in all copies or substantial portions of the Software.                   *
  15.  *                                                                          *
  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.                               *
  23.  *                                                                          *
  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       *
  27.  * authorization.                                                           *
  28.  ****************************************************************************/
  29.  
  30. /****************************************************************************
  31.  *   Author: Juergen Pfeifer, 1997                                          *
  32.  ****************************************************************************/
  33.  
  34. // $Id: etip.h.in,v 1.36 2007/04/07 18:56:32 tom Exp $
  35.  
  36. #ifndef NCURSES_ETIP_H_incl
  37. #define NCURSES_ETIP_H_incl 1
  38.  
  39. // These are substituted at configure/build time
  40. #ifndef HAVE_BUILTIN_H
  41. #define HAVE_BUILTIN_H 0
  42. #endif
  43.  
  44. #ifndef HAVE_GXX_BUILTIN_H
  45. #define HAVE_GXX_BUILTIN_H 0
  46. #endif
  47.  
  48. #ifndef HAVE_GPP_BUILTIN_H
  49. #define HAVE_GPP_BUILTIN_H 0
  50. #endif
  51.  
  52. #ifndef HAVE_IOSTREAM
  53. #define HAVE_IOSTREAM 1
  54. #endif
  55.  
  56. #ifndef HAVE_TYPEINFO
  57. #define HAVE_TYPEINFO 1
  58. #endif
  59.  
  60. #ifndef HAVE_VALUES_H
  61. #define HAVE_VALUES_H 0
  62. #endif
  63.  
  64. #ifndef ETIP_NEEDS_MATH_H
  65. #define ETIP_NEEDS_MATH_H 1
  66. #endif
  67.  
  68. #ifndef ETIP_NEEDS_MATH_EXCEPTION
  69. #define ETIP_NEEDS_MATH_EXCEPTION 0
  70. #endif
  71.  
  72. #ifndef CPP_HAS_PARAM_INIT
  73. #define CPP_HAS_PARAM_INIT 0
  74. #endif
  75.  
  76. #ifndef CPP_HAS_STATIC_CAST
  77. #define CPP_HAS_STATIC_CAST 1
  78. #endif
  79.  
  80. #ifdef __GNUG__
  81. #  if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
  82. #    if HAVE_TYPEINFO
  83. #      include <typeinfo>
  84. #    endif
  85. #  endif
  86. #endif
  87.  
  88. #if defined(__GNUG__)
  89. #  if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H
  90. #    if ETIP_NEEDS_MATH_H
  91. #      if ETIP_NEEDS_MATH_EXCEPTION
  92. #        undef exception
  93. #        define exception math_exception
  94. #      endif
  95. #      include <math.h>
  96. #    endif
  97. #    undef exception
  98. #    define exception builtin_exception
  99. #    if HAVE_GPP_BUILTIN_H
  100. #     include <gpp/builtin.h>
  101. #    elif HAVE_GXX_BUILTIN_H
  102. #     include <g++/builtin.h>
  103. #    else
  104. #     include <builtin.h>
  105. #    endif
  106. #    undef exception
  107. #  endif
  108. #elif defined (__SUNPRO_CC)
  109. #  include <generic.h>
  110. #endif
  111.  
  112. #include <ncurses_dll.h>
  113.  
  114. extern "C" {
  115. #if HAVE_VALUES_H
  116. #  include <values.h>
  117. #endif
  118.  
  119. #include <assert.h>
  120. #include <eti.h>
  121. #include <errno.h>
  122. }
  123.  
  124. // Language features
  125. #if CPP_HAS_PARAM_INIT
  126. #define NCURSES_PARAM_INIT(value) = value
  127. #else
  128. #define NCURSES_PARAM_INIT(value) /*nothing*/
  129. #endif
  130.  
  131. #if CPP_HAS_STATIC_CAST
  132. #define STATIC_CAST(s) static_cast<s>
  133. #else
  134. #define STATIC_CAST(s) (s)
  135. #endif
  136.  
  137. // Forward Declarations
  138. class NCURSES_IMPEXP NCursesPanel;
  139. class NCURSES_IMPEXP NCursesMenu;
  140. class NCURSES_IMPEXP NCursesForm;
  141.  
  142. class NCURSES_IMPEXP NCursesException
  143. {
  144. public:
  145.   const char *message;
  146.   int errorno;
  147.  
  148.   NCursesException (const char* msg, int err)
  149.     : message(msg), errorno (err)
  150.     {};
  151.  
  152.   NCursesException (const char* msg)
  153.     : message(msg), errorno (E_SYSTEM_ERROR)
  154.     {};
  155.  
  156.   NCursesException& operator=(const NCursesException& rhs)
  157.   {
  158.     errorno = rhs.errorno;
  159.     return *this;
  160.   }
  161.  
  162.   NCursesException(const NCursesException& rhs)
  163.     : message(rhs.message), errorno(rhs.errorno)
  164.   {
  165.   }
  166.  
  167.   virtual const char *classname() const {
  168.     return "NCursesWindow";
  169.   }
  170.  
  171.   virtual ~NCursesException()
  172.   {
  173.   }
  174. };
  175.  
  176. class NCURSES_IMPEXP NCursesPanelException : public NCursesException
  177. {
  178. public:
  179.   const NCursesPanel* p;
  180.  
  181.   NCursesPanelException (const char *msg, int err) :
  182.     NCursesException (msg, err),
  183.     p (NULL)
  184.     {};
  185.  
  186.   NCursesPanelException (const NCursesPanel* panel,
  187.              const char *msg,
  188.              int err) :
  189.     NCursesException (msg, err),
  190.     p (panel)
  191.     {};
  192.  
  193.   NCursesPanelException (int err) :
  194.     NCursesException ("panel library error", err),
  195.     p (NULL)
  196.     {};
  197.  
  198.   NCursesPanelException (const NCursesPanel* panel,
  199.              int err) :
  200.     NCursesException ("panel library error", err),
  201.     p (panel)
  202.     {};
  203.  
  204.   NCursesPanelException& operator=(const NCursesPanelException& rhs)
  205.   {
  206.     if (this != &rhs) {
  207.       NCursesException::operator=(rhs);
  208.       p = rhs.p;
  209.     }
  210.     return *this;
  211.   }
  212.  
  213.   NCursesPanelException(const NCursesPanelException& rhs)
  214.     : NCursesException(rhs), p(rhs.p)
  215.   {
  216.   }
  217.  
  218.   virtual const char *classname() const {
  219.     return "NCursesPanel";
  220.   }
  221.  
  222.   virtual ~NCursesPanelException()
  223.   {
  224.   }
  225. };
  226.  
  227. class NCURSES_IMPEXP NCursesMenuException : public NCursesException
  228. {
  229. public:
  230.   const NCursesMenu* m;
  231.  
  232.   NCursesMenuException (const char *msg, int err) :
  233.     NCursesException (msg, err),
  234.     m (NULL)
  235.     {};
  236.  
  237.   NCursesMenuException (const NCursesMenu* menu,
  238.             const char *msg,
  239.             int err) :
  240.     NCursesException (msg, err),
  241.     m (menu)
  242.     {};
  243.  
  244.   NCursesMenuException (int err) :
  245.     NCursesException ("menu library error", err),
  246.     m (NULL)
  247.     {};
  248.  
  249.   NCursesMenuException (const NCursesMenu* menu,
  250.             int err) :
  251.     NCursesException ("menu library error", err),
  252.     m (menu)
  253.     {};
  254.  
  255.   NCursesMenuException& operator=(const NCursesMenuException& rhs)
  256.   {
  257.     if (this != &rhs) {
  258.       NCursesException::operator=(rhs);
  259.       m = rhs.m;
  260.     }
  261.     return *this;
  262.   }
  263.  
  264.   NCursesMenuException(const NCursesMenuException& rhs)
  265.     : NCursesException(rhs), m(rhs.m)
  266.   {
  267.   }
  268.  
  269.   virtual const char *classname() const {
  270.     return "NCursesMenu";
  271.   }
  272.  
  273.   virtual ~NCursesMenuException()
  274.   {
  275.   }
  276. };
  277.  
  278. class NCURSES_IMPEXP NCursesFormException : public NCursesException
  279. {
  280. public:
  281.   const NCursesForm* f;
  282.  
  283.   NCursesFormException (const char *msg, int err) :
  284.     NCursesException (msg, err),
  285.     f (NULL)
  286.     {};
  287.  
  288.   NCursesFormException (const NCursesForm* form,
  289.             const char *msg,
  290.             int err) :
  291.     NCursesException (msg, err),
  292.     f (form)
  293.     {};
  294.  
  295.   NCursesFormException (int err) :
  296.     NCursesException ("form library error", err),
  297.     f (NULL)
  298.     {};
  299.  
  300.   NCursesFormException (const NCursesForm* form,
  301.             int err) :
  302.     NCursesException ("form library error", err),
  303.     f (form)
  304.     {};
  305.  
  306.   NCursesFormException& operator=(const NCursesFormException& rhs)
  307.   {
  308.     if (this != &rhs) {
  309.       NCursesException::operator=(rhs);
  310.       f = rhs.f;
  311.     }
  312.     return *this;
  313.   }
  314.  
  315.   NCursesFormException(const NCursesFormException& rhs)
  316.     : NCursesException(rhs), f(rhs.f)
  317.   {
  318.   }
  319.  
  320.   virtual const char *classname() const {
  321.     return "NCursesForm";
  322.   }
  323.  
  324.   virtual ~NCursesFormException()
  325.   {
  326.   }
  327. };
  328.  
  329. #if !((defined(__GNUG__) && defined(__EXCEPTIONS)) || defined(__SUNPRO_CC))
  330. #  if HAVE_IOSTREAM
  331. #     include <iostream>
  332. using std::cerr;
  333. using std::endl;
  334. #  else
  335. #     include <iostream.h>
  336. #  endif
  337.    extern "C" void exit(int);
  338. #endif
  339.  
  340. inline void THROW(const NCursesException *e) {
  341. #if defined(__GNUG__) && defined(__EXCEPTIONS)
  342. #  if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
  343.       (*lib_error_handler)(e ? e->classname() : "", e ? e->message : "");
  344. #else
  345. #define CPP_HAS_TRY_CATCH 1
  346. #endif
  347. #elif defined(__SUNPRO_CC)
  348. #  if !defined(__SUNPRO_CC_COMPAT) || (__SUNPRO_CC_COMPAT < 5)
  349.   genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
  350. #else
  351. #define CPP_HAS_TRY_CATCH 1
  352. #endif
  353. #else
  354.   if (e)
  355.     cerr << e->message << endl;
  356.   exit(0);
  357. #endif
  358.  
  359. #ifndef CPP_HAS_TRY_CATCH
  360. #define CPP_HAS_TRY_CATCH 0
  361. #define NCURSES_CPP_TRY        /* nothing */
  362. #define NCURSES_CPP_CATCH(e)    if (false)
  363. #define THROWS(s)        /* nothing */
  364. #elif CPP_HAS_TRY_CATCH
  365.   throw *e;
  366. #define NCURSES_CPP_TRY        try
  367. #define NCURSES_CPP_CATCH(e)    catch(e)
  368. #define THROWS(s)        throw(s)
  369. #endif
  370. }
  371.  
  372. #endif /* NCURSES_ETIP_H_incl */
  373.