home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / progs / CB / DATA.Z / EXCEPT.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-18  |  2.5 KB  |  131 lines

  1. /*  except.h
  2.  
  3.     Definitions for exception handling
  4.  
  5. */
  6.  
  7. /* $Copyright: 1992$ */
  8. /* $Revision:   8.1  $ */
  9.  
  10. #ifndef __cplusplus
  11. #error Must use C++ for except.h
  12. #endif
  13.  
  14. #ifndef __EXCEPT_H
  15. #define __EXCEPT_H
  16.  
  17. #if !defined(___DEFS_H)
  18. #include <_defs.h>
  19. #endif
  20.  
  21. #if !defined(___STDLIB_H)
  22. #include <stdlib.h>
  23. #endif
  24.  
  25.  
  26. #if !defined(RC_INVOKED)
  27.  
  28. #pragma pack(push, 1)
  29.  
  30. #if defined(__BCOPT__)
  31. #if !defined(_RTL_ALLOW_po) && !defined(__FLAT__)
  32. #pragma option -po-     // disable Object data calling convention
  33. #endif
  34. #endif
  35.  
  36. #if !defined(__TINY__)
  37. #pragma option -RT
  38. #endif
  39.  
  40. #pragma option -Vo-     // set standard C++ options
  41.  
  42. #if defined(__STDC__)
  43. #pragma warn -nak
  44. #endif
  45.  
  46. #endif  /* !RC_INVOKED */
  47.  
  48.  
  49. typedef void (_RTLENTRY *terminate_function)();
  50. typedef void (_RTLENTRY *unexpected_function)();
  51.  
  52. terminate_function  _RTLENTRY set_terminate(terminate_function);
  53. unexpected_function _RTLENTRY set_unexpected(unexpected_function);
  54.  
  55. void  _RTLENTRY terminate();
  56. void  _RTLENTRY unexpected();
  57.  
  58. extern  char _FAR * _RTLENTRY __ThrowFileName();
  59. extern  unsigned    _RTLENTRY __ThrowLineNumber();
  60. extern  char _FAR * _RTLENTRY __ThrowExceptionName();
  61.  
  62. #define  __throwFileName      __ThrowFileName()
  63. #define  __throwLineNumber    __ThrowLineNumber()
  64. #define  __throwExceptionName __ThrowExceptionName()
  65.  
  66. class _EXPCLASS string;
  67.  
  68. class _EXPCLASS xmsg
  69. {
  70. public:
  71.     _RTLENTRY xmsg(const string _FAR &msg);
  72.     _RTLENTRY xmsg(const xmsg _FAR &msg);
  73.     _RTLENTRY ~xmsg();
  74.  
  75.     const string _FAR & _RTLENTRY why() const;
  76.     void                _RTLENTRY raise() throw(xmsg);
  77.     xmsg&               _RTLENTRY operator=(const xmsg _FAR &src);
  78.  
  79. private:
  80.     string _FAR *str;
  81. };
  82.  
  83. inline const string _FAR & _RTLENTRY xmsg::why() const
  84. {
  85.     return *str;
  86. };
  87.  
  88. class _EXPCLASS xalloc : public xmsg
  89. {
  90. public:
  91.     _RTLENTRY xalloc(const string _FAR &msg, size_t size);
  92.  
  93.     size_t _RTLENTRY requested() const;
  94.     void   _RTLENTRY raise() throw(xalloc);
  95.  
  96. private:
  97.     size_t siz;
  98. };
  99.  
  100. inline size_t _RTLENTRY xalloc::requested() const
  101. {
  102.     return siz;
  103. }
  104.  
  105.  
  106. #if !defined(RC_INVOKED)
  107.  
  108. #if defined(__STDC__)
  109. #pragma warn .nak
  110. #endif
  111.  
  112. #pragma option -Vo.     // restore user C++ options
  113.  
  114. #if !defined(__TINY__)
  115. #pragma option -RT.
  116. #endif
  117.  
  118. #if defined(__BCOPT__)
  119. #if !defined(_RTL_ALLOW_po) && !defined(__FLAT__)
  120. #pragma option -po.     // restore Object data calling convention
  121. #endif
  122. #endif
  123.  
  124. /* restore default packing */
  125. #pragma pack(pop)
  126.  
  127. #endif  /* !RC_INVOKED */
  128.  
  129.  
  130. #endif  // __EXCEPT_H
  131.