home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stl453up.zip / stl453fx / stlport / stdexcept < prev    next >
Text File  |  2002-04-29  |  4KB  |  170 lines

  1. /*
  2.  * Copyright (c) 1996,1997
  3.  * Silicon Graphics Computer Systems, Inc.
  4.  *
  5.  * Copyright (c) 1999 
  6.  * Boris Fomitchev
  7.  *
  8.  * This material is provided "as is", with absolutely no warranty expressed
  9.  * or implied. Any use is at your own risk.
  10.  *
  11.  * Permission to use or copy this software for any purpose is hereby granted 
  12.  * without fee, provided the above notices are retained on all copies.
  13.  * Permission to modify the code and to distribute modified code is granted,
  14.  * provided the above notices are retained, and a notice that the code was
  15.  * modified is included with the above copyright notice.
  16.  *
  17.  */
  18.  
  19. #ifndef _STLP_STDEXCEPT
  20.  
  21. # if !defined (_STLP_OUTERMOST_HEADER_ID)
  22. #  define _STLP_OUTERMOST_HEADER_ID 0x63
  23. #  include <stl/_prolog.h>
  24. # elif (_STLP_OUTERMOST_HEADER_ID == 0x63) && ! defined (_STLP_DONT_POP_0x63)
  25. #  define _STLP_DONT_POP_0x63
  26. # endif
  27.  
  28. # if !defined(_STLP_STDEXCEPT_SEEN) && \
  29.    (!defined (_STLP_USE_NATIVE_STDEXCEPT) || defined (_STLP_USE_OWN_NAMESPACE))
  30.  
  31. #  define _STLP_STDEXCEPT_SEEN 1
  32.  
  33. #  include <exception>
  34.  
  35. #if defined(_STLP_USE_EXCEPTIONS) || \
  36.     !(defined(_MIPS_SIM) && defined(_ABIO32) && _MIPS_SIM == _ABIO32)
  37.  
  38. # include <cstring>
  39.  
  40. #ifndef _STLP_INTERNAL_ALLOC_H
  41. # include <stl/_alloc.h>
  42. #endif
  43.  
  44. #ifndef _STLP_STRING_FWD_H
  45. # include <stl/_string_fwd.h>
  46. #endif
  47.  
  48. # define _STLP_OWN_STDEXCEPT 1
  49.  
  50. _STLP_BEGIN_NAMESPACE
  51.  
  52. class _STLP_CLASS_DECLSPEC __Named_exception : public _STLP_EXCEPTION_BASE {
  53. public:
  54.   __Named_exception(const string& __str) 
  55. # ifdef _STLP_OWN_IOSTREAMS
  56.     ;
  57.   const char* what() const _STLP_NOTHROW_INHERENTLY;
  58.   ~__Named_exception() _STLP_NOTHROW_INHERENTLY;
  59. # else
  60.   {
  61.     strncpy(_M_name, __get_c_string(__str), _S_bufsize);
  62.     _M_name[_S_bufsize - 1] = '\0';
  63.   }
  64.   const char* what() const _STLP_NOTHROW_INHERENTLY { return _M_name; }
  65. # endif
  66.  
  67. private:
  68.   enum { _S_bufsize = 256 };
  69.   char _M_name[_S_bufsize];
  70. };
  71.  
  72. class _STLP_CLASS_DECLSPEC logic_error : public __Named_exception {
  73. public:
  74.   logic_error(const string& __s) : __Named_exception(__s) {}
  75. # ifdef _STLP_OWN_IOSTREAMS
  76.   ~logic_error() _STLP_NOTHROW_INHERENTLY;
  77. # endif
  78. };
  79.  
  80. class _STLP_CLASS_DECLSPEC runtime_error : public __Named_exception {
  81. public:
  82.   runtime_error(const string& __s) : __Named_exception(__s) {}
  83. # ifdef _STLP_OWN_IOSTREAMS
  84.   ~runtime_error() _STLP_NOTHROW_INHERENTLY;
  85. # endif
  86. };
  87.  
  88. class _STLP_CLASS_DECLSPEC domain_error : public logic_error {
  89. public:
  90.   domain_error(const string& __arg) : logic_error(__arg) {}
  91. # ifdef _STLP_OWN_IOSTREAMS
  92.   ~domain_error() _STLP_NOTHROW_INHERENTLY;
  93. # endif
  94. };
  95.  
  96. class _STLP_CLASS_DECLSPEC invalid_argument : public logic_error {
  97. public:
  98.   invalid_argument(const string& __arg) : logic_error(__arg) {}
  99. # ifdef _STLP_OWN_IOSTREAMS
  100.   ~invalid_argument() _STLP_NOTHROW_INHERENTLY;
  101. # endif
  102. };
  103.  
  104. class _STLP_CLASS_DECLSPEC length_error : public logic_error {
  105. public:
  106.   length_error(const string& __arg) : logic_error(__arg) {}
  107. # ifdef _STLP_OWN_IOSTREAMS
  108.   ~length_error() _STLP_NOTHROW_INHERENTLY;
  109. # endif
  110. };
  111.  
  112. class _STLP_CLASS_DECLSPEC out_of_range : public logic_error {
  113. public:
  114.   out_of_range(const string& __arg) : logic_error(__arg) {}
  115. # ifdef _STLP_OWN_IOSTREAMS
  116.   ~out_of_range() _STLP_NOTHROW_INHERENTLY;
  117. # endif
  118. };
  119.  
  120. class _STLP_CLASS_DECLSPEC range_error : public runtime_error {
  121. public:
  122.   range_error(const string& __arg) : runtime_error(__arg) {}
  123. # ifdef _STLP_OWN_IOSTREAMS
  124.   ~range_error() _STLP_NOTHROW_INHERENTLY;
  125. # endif
  126. };
  127.  
  128. class _STLP_CLASS_DECLSPEC overflow_error : public runtime_error {
  129. public:
  130.   overflow_error(const string& __arg) : runtime_error(__arg) {}
  131. # ifdef _STLP_OWN_IOSTREAMS
  132.   ~overflow_error() _STLP_NOTHROW_INHERENTLY;
  133. # endif
  134. };
  135.  
  136. class _STLP_CLASS_DECLSPEC underflow_error : public runtime_error {
  137. public:
  138.   underflow_error(const string& __arg) : runtime_error(__arg) {}
  139. # ifdef _STLP_OWN_IOSTREAMS
  140.   ~underflow_error() _STLP_NOTHROW_INHERENTLY;
  141. # endif
  142. };
  143.  
  144. _STLP_END_NAMESPACE
  145.  
  146. #endif /* Not o32, and no exceptions */
  147. # endif /* _STLP_STDEXCEPT_SEEN */
  148.  
  149.  
  150. #if defined (_STLP_USE_NATIVE_STDEXCEPT)
  151. #  include _STLP_NATIVE_HEADER(stdexcept)
  152. # endif
  153.  
  154. #  define _STLP_STDEXCEPT 1
  155.  
  156. # if (_STLP_OUTERMOST_HEADER_ID == 0x63)
  157. #  if ! defined (_STLP_DONT_POP_0x63)
  158. #   include <stl/_epilog.h>
  159. #   undef  _STLP_OUTERMOST_HEADER_ID
  160. #   endif
  161. #   undef  _STLP_DONT_POP_0x63
  162. # endif
  163.  
  164. #endif /* _STLP_STDEXCEPT */
  165.  
  166. // Local Variables:
  167. // mode:C++
  168. // End:
  169.  
  170.