home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Compilers / digital marsC compier / dm / stl / stdexcept < prev    next >
Encoding:
Text File  |  2000-06-08  |  2.3 KB  |  97 lines

  1. /*
  2.  * Copyright (c) 1997
  3.  * Silicon Graphics Computer Systems, Inc.
  4.  *
  5.  * Permission to use, copy, modify, distribute and sell this software
  6.  * and its documentation for any purpose is hereby granted without fee,
  7.  * provided that the above copyright notice appear in all copies and
  8.  * that both that copyright notice and this permission notice appear
  9.  * in supporting documentation.  Silicon Graphics makes no
  10.  * representations about the suitability of this software for any
  11.  * purpose.  It is provided "as is" without express or implied warranty.
  12.  */ 
  13.  
  14. #ifndef __SGI_STDEXCEPT
  15. #define __SGI_STDEXCEPT
  16.  
  17. #include <stl_exception.h>
  18.  
  19. #if defined(__STL_USE_EXCEPTIONS) || \
  20.     !(defined(_MIPS_SIM) && defined(_ABIO32) && _MIPS_SIM == _ABIO32)
  21.  
  22. #include <stl_string_fwd.h>
  23.  
  24. __STL_BEGIN_NAMESPACE
  25.  
  26. class __Named_exception : public __STL_EXCEPTION_BASE {
  27. public:
  28.   __Named_exception(const string& __str) {
  29.     strncpy(_M_name, __get_c_string(__str), _S_bufsize);
  30.     _M_name[_S_bufsize - 1] = '\0';
  31.   }
  32.   virtual const char* what() const __STL_NOTHROW { return _M_name; }
  33.  
  34. private:
  35.   enum { _S_bufsize = 256 };
  36.   char _M_name[_S_bufsize];
  37. };
  38.  
  39. class logic_error : public __Named_exception {
  40. public:
  41.   logic_error(const string& __s) : __Named_exception(__s) {}
  42. };
  43.  
  44. class runtime_error : public __Named_exception {
  45. public:
  46.   runtime_error(const string& __s) : __Named_exception(__s) {}
  47. };
  48.  
  49. class domain_error : public logic_error {
  50. public:
  51.   domain_error(const string& __arg) : logic_error(__arg) {}
  52. };
  53.  
  54. class invalid_argument : public logic_error {
  55. public:
  56.   invalid_argument(const string& __arg) : logic_error(__arg) {}
  57. };
  58.  
  59. class length_error : public logic_error {
  60. public:
  61.   length_error(const string& __arg) : logic_error(__arg) {}
  62. };
  63.  
  64. class out_of_range : public logic_error {
  65. public:
  66.   out_of_range(const string& __arg) : logic_error(__arg) {}
  67. };
  68.  
  69. class range_error : public runtime_error {
  70. public:
  71.   range_error(const string& __arg) : runtime_error(__arg) {}
  72. };
  73.  
  74. class overflow_error : public runtime_error {
  75. public:
  76.   overflow_error(const string& __arg) : runtime_error(__arg) {}
  77. };
  78.  
  79. class underflow_error : public runtime_error {
  80. public:
  81.   underflow_error(const string& __arg) : runtime_error(__arg) {}
  82. };
  83.  
  84. __STL_END_NAMESPACE
  85.  
  86. #ifndef __SGI_STL_STRING
  87. #include <string>
  88. #endif
  89.  
  90. #endif /* Not o32, and no exceptions */
  91.  
  92. #endif /* __SGI_STDEXCEPT */
  93.  
  94. // Local Variables:
  95. // mode:C++
  96. // End:
  97.