Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

242 lines
4.7 KiB

  1. // stdexcept standard header
  2. #pragma once
  3. #ifndef _STDEXCEPT_
  4. #define _STDEXCEPT_
  5. #include <exception>
  6. #include <xstring>
  7. #pragma pack(push,8)
  8. #pragma warning(push,3)
  9. _STD_BEGIN
  10. // CLASS logic_error
  11. class logic_error
  12. : public exception
  13. { // base of all logic-error exceptions
  14. public:
  15. explicit logic_error(const string& _Message)
  16. : _Str(_Message)
  17. { // construct from message string
  18. }
  19. virtual ~logic_error()
  20. { // destroy the object
  21. }
  22. virtual const char *what() const _THROW0()
  23. { // return pointer to message string
  24. return (_Str.c_str());
  25. }
  26. #if !_HAS_EXCEPTIONS
  27. protected:
  28. virtual void _Doraise() const
  29. { // perform class-specific exception handling
  30. _RAISE(*this);
  31. }
  32. #endif /* _HAS_EXCEPTIONS */
  33. private:
  34. string _Str; // the stored message string
  35. };
  36. // CLASS domain_error
  37. class domain_error
  38. : public logic_error
  39. { // base of all domain-error exceptions
  40. public:
  41. explicit domain_error(const string& _Message)
  42. : logic_error(_Message)
  43. { // construct from message string
  44. }
  45. virtual ~domain_error()
  46. { // destroy the object
  47. }
  48. #if !_HAS_EXCEPTIONS
  49. protected:
  50. virtual void _Doraise() const
  51. { // perform class-specific exception handling
  52. _RAISE(*this);
  53. }
  54. #endif /* _HAS_EXCEPTIONS */
  55. };
  56. // CLASS invalid_argument
  57. class invalid_argument
  58. : public logic_error
  59. { // base of all invalid-argument exceptions
  60. public:
  61. explicit invalid_argument(const string& _Message)
  62. : logic_error(_Message)
  63. { // construct from message string
  64. }
  65. virtual ~invalid_argument()
  66. { // destroy the object
  67. }
  68. #if !_HAS_EXCEPTIONS
  69. protected:
  70. virtual void _Doraise() const
  71. { // perform class-specific exception handling
  72. _RAISE(*this);
  73. }
  74. #endif /* _HAS_EXCEPTIONS */
  75. };
  76. // CLASS length_error
  77. class length_error
  78. : public logic_error
  79. { // base of all length-error exceptions
  80. public:
  81. explicit length_error(const string& _Message)
  82. : logic_error(_Message)
  83. { // construct from message string
  84. }
  85. virtual ~length_error()
  86. { // destroy the object
  87. }
  88. #if !_HAS_EXCEPTIONS
  89. protected:
  90. virtual void _Doraise() const
  91. { // perform class-specific exception handling
  92. _RAISE(*this);
  93. }
  94. #endif /* _HAS_EXCEPTIONS */
  95. };
  96. // CLASS out_of_range
  97. class out_of_range
  98. : public logic_error
  99. { // base of all out-of-range exceptions
  100. public:
  101. explicit out_of_range(const string& _Message)
  102. : logic_error(_Message)
  103. { // construct from message string
  104. }
  105. virtual ~out_of_range()
  106. { // destroy the object
  107. }
  108. #if !_HAS_EXCEPTIONS
  109. protected:
  110. virtual void _Doraise() const
  111. { // perform class-specific exception handling
  112. _RAISE(*this);
  113. }
  114. #endif /* _HAS_EXCEPTIONS */
  115. };
  116. // CLASS runtime_error
  117. class runtime_error
  118. : public exception
  119. { // base of all runtime-error exceptions
  120. public:
  121. explicit runtime_error(const string& _Message)
  122. : _Str(_Message)
  123. { // construct from message string
  124. }
  125. virtual ~runtime_error()
  126. { // destroy the object
  127. }
  128. virtual const char *what() const _THROW0()
  129. { // return pointer to message string
  130. return (_Str.c_str());
  131. }
  132. #if !_HAS_EXCEPTIONS
  133. protected:
  134. virtual void _Doraise() const
  135. { // perform class-specific exception handling
  136. _RAISE(*this);
  137. }
  138. #endif /* _HAS_EXCEPTIONS */
  139. private:
  140. string _Str; // the stored message string
  141. };
  142. // CLASS overflow_error
  143. class overflow_error
  144. : public runtime_error
  145. { // base of all overflow-error exceptions
  146. public:
  147. explicit overflow_error(const string& _Message)
  148. : runtime_error(_Message)
  149. { // construct from message string
  150. }
  151. virtual ~overflow_error()
  152. { // destroy the object
  153. }
  154. #if !_HAS_EXCEPTIONS
  155. protected:
  156. virtual void _Doraise() const
  157. { // perform class-specific exception handling
  158. _RAISE(*this);
  159. }
  160. #endif /* _HAS_EXCEPTIONS */
  161. };
  162. // CLASS underflow_error
  163. class underflow_error
  164. : public runtime_error
  165. { // base of all underflow-error exceptions
  166. public:
  167. explicit underflow_error(const string& _Message)
  168. : runtime_error(_Message)
  169. { // construct from message string
  170. }
  171. virtual ~underflow_error()
  172. { // destroy the object
  173. }
  174. #if !_HAS_EXCEPTIONS
  175. protected:
  176. virtual void _Doraise() const
  177. { // perform class-specific exception handling
  178. _RAISE(*this);
  179. }
  180. #endif /* _HAS_EXCEPTIONS */
  181. };
  182. // CLASS range_error
  183. class range_error
  184. : public runtime_error
  185. { // base of all range-error exceptions
  186. public:
  187. explicit range_error(const string& _Message)
  188. : runtime_error(_Message)
  189. { // construct from message string
  190. }
  191. virtual ~range_error()
  192. { // destroy the object
  193. }
  194. #if !_HAS_EXCEPTIONS
  195. protected:
  196. virtual void _Doraise() const
  197. { // perform class-specific exception handling
  198. _RAISE(*this);
  199. }
  200. #endif /* _HAS_EXCEPTIONS */
  201. };
  202. _STD_END
  203. #pragma warning(pop)
  204. #pragma pack(pop)
  205. #endif /* _STDEXCEPT_ */
  206. /*
  207. * Copyright (c) 1992-2001 by P.J. Plauger. ALL RIGHTS RESERVED.
  208. * Consult your license regarding permissions and restrictions.
  209. V3.10:0009 */