1 // stdexcept standard header
2 #pragma once
3 #ifndef _STDEXCEPT_
4 #define _STDEXCEPT_
5 #ifndef RC_INVOKED
6 #include <exception>
7 #include <xstring>
8
9 #ifdef _MSC_VER
10  #pragma pack(push,_CRT_PACKING)
11  #pragma warning(push,3)
12 #endif  /* _MSC_VER */
13 _STD_BEGIN
14
15 #ifndef _Mbstinit
16  #define _Mbstinit(x)    _Mbstatet x = {0}
17 #endif /* _Mbstinit */
18
19         // CLASS logic_error
20 class logic_error
21     : public _XSTD exception
22     {    // base of all logic-error exceptions
23 public:
24     explicit __CLR_OR_THIS_CALL logic_error(const string& _Message)
25         : _Str(_Message)
26         {    // construct from message string
27         }
28
29     virtual __CLR_OR_THIS_CALL ~logic_error() _THROW0()
30         {    // destroy the object
31         }
32
33     virtual const char *__CLR_OR_THIS_CALL what() const _THROW0()
34         {    // return pointer to message string
35         return (_Str.c_str());
36         }
37
38  #if !_HAS_EXCEPTIONS
39 protected:
40     virtual void __CLR_OR_THIS_CALL _Doraise() const
41         {    // perform class-specific exception handling
42         _RAISE(*this);
43         }
44  #endif /* _HAS_EXCEPTIONS */
45
46 private:
47     string _Str;    // the stored message string
48     };
49
50         // CLASS domain_error
51 class domain_error
52     : public logic_error
53     {    // base of all domain-error exceptions
54 public:
55     explicit __CLR_OR_THIS_CALL domain_error(const string& _Message)
56         : logic_error(_Message)
57         {    // construct from message string
58         }
59
60     virtual __CLR_OR_THIS_CALL ~domain_error() _THROW0()
61         {    // destroy the object
62         }
63
64  #if !_HAS_EXCEPTIONS
65 protected:
66     virtual void __CLR_OR_THIS_CALL _Doraise() const
67         {    // perform class-specific exception handling
68         _RAISE(*this);
69         }
70  #endif /* _HAS_EXCEPTIONS */
71
72     };
73
74         // CLASS invalid_argument
75 class invalid_argument
76     : public logic_error
77     {    // base of all invalid-argument exceptions
78 public:
79     explicit __CLR_OR_THIS_CALL invalid_argument(const string& _Message)
80         : logic_error(_Message)
81         {    // construct from message string
82         }
83
84     virtual __CLR_OR_THIS_CALL ~invalid_argument() _THROW0()
85         {    // destroy the object
86         }
87
88  #if !_HAS_EXCEPTIONS
89 protected:
90     virtual void __CLR_OR_THIS_CALL _Doraise() const
91         {    // perform class-specific exception handling
92         _RAISE(*this);
93         }
94  #endif /* _HAS_EXCEPTIONS */
95
96     };
97
98         // CLASS length_error
99 class length_error
100     : public logic_error
101     {    // base of all length-error exceptions
102 public:
103     explicit __CLR_OR_THIS_CALL length_error(const string& _Message)
104         : logic_error(_Message)
105         {    // construct from message string
106         }
107
108     virtual __CLR_OR_THIS_CALL ~length_error() _THROW0()
109         {    // destroy the object
110         }
111
112  #if !_HAS_EXCEPTIONS
113 protected:
114     virtual void __CLR_OR_THIS_CALL _Doraise() const
115         {    // perform class-specific exception handling
116         _RAISE(*this);
117         }
118  #endif /* _HAS_EXCEPTIONS */
119
120     };
121
122         // CLASS out_of_range
123 class out_of_range
124     : public logic_error
125     {    // base of all out-of-range exceptions
126 public:
127     explicit __CLR_OR_THIS_CALL out_of_range(const string& _Message)
128         : logic_error(_Message)
129         {    // construct from message string
130         }
131
132     virtual __CLR_OR_THIS_CALL ~out_of_range() _THROW0()
133         {    // destroy the object
134         }
135
136  #if !_HAS_EXCEPTIONS
137 protected:
138     virtual void __CLR_OR_THIS_CALL _Doraise() const
139         {    // perform class-specific exception handling
140         _RAISE(*this);
141         }
142  #endif /* _HAS_EXCEPTIONS */
143
144     };
145
Lines 146 ... 155 are skipped.
156     virtual __CLR_OR_THIS_CALL ~runtime_error() _THROW0()
157         {    // destroy the object
158         }
159
160     virtual const char *__CLR_OR_THIS_CALL what() const _THROW0()
161         {    // return pointer to message string
162         return (_Str.c_str());
163         }
164
165  #if !_HAS_EXCEPTIONS
166 protected:
167     virtual void __CLR_OR_THIS_CALL _Doraise() const
168         {    // perform class-specific exception handling
169         _RAISE(*this);
170         }
171  #endif /* _HAS_EXCEPTIONS */
172
173 private:
174     string _Str;    // the stored message string
175     };
176
177         // CLASS overflow_error
178 class overflow_error
179     : public runtime_error
180     {    // base of all overflow-error exceptions
181 public:
182     explicit __CLR_OR_THIS_CALL overflow_error(const string& _Message)
183         : runtime_error(_Message)
184         {    // construct from message string
185         }
186
187     virtual __CLR_OR_THIS_CALL ~overflow_error() _THROW0()
188         {    // destroy the object
189         }
190
191  #if !_HAS_EXCEPTIONS
192 protected:
193     virtual void __CLR_OR_THIS_CALL _Doraise() const
194         {    // perform class-specific exception handling
195         _RAISE(*this);
196         }
197  #endif /* _HAS_EXCEPTIONS */
198
199     };
200
201         // CLASS underflow_error
202 class underflow_error
203     : public runtime_error
204     {    // base of all underflow-error exceptions
205 public:
206     explicit __CLR_OR_THIS_CALL underflow_error(const string& _Message)
207         : runtime_error(_Message)
208         {    // construct from message string
209         }
210
211     virtual __CLR_OR_THIS_CALL ~underflow_error() _THROW0()
212         {    // destroy the object
213         }
214
215  #if !_HAS_EXCEPTIONS
216 protected:
217     virtual void __CLR_OR_THIS_CALL _Doraise() const
218         {    // perform class-specific exception handling
219         _RAISE(*this);
220         }
221  #endif /* _HAS_EXCEPTIONS */
222
223     };
224
225         // CLASS range_error
226 class range_error
227     : public runtime_error
228     {    // base of all range-error exceptions
229 public:
230     explicit __CLR_OR_THIS_CALL range_error(const string& _Message)
231         : runtime_error(_Message)
232         {    // construct from message string
233         }
234
235     virtual __CLR_OR_THIS_CALL ~range_error() _THROW0()
236         {    // destroy the object
237         }
238
239  #if !_HAS_EXCEPTIONS
240 protected:
241     virtual void __CLR_OR_THIS_CALL _Doraise() const
242         {    // perform class-specific exception handling
243         _RAISE(*this);
244         }
245  #endif /* _HAS_EXCEPTIONS */
246
247     };
248
249 #ifdef _M_CEE_PURE
250
251 inline
252 void __clrcall _String_base::_Xlen()
253       {    // report a length_error
254       _THROW(length_error, "string too long");
255       }
256
257 inline
258 void __clrcall _String_base::_Xran()
259       {    // report an out_of_range error
260       _THROW(out_of_range, "invalid string position");
261       }
262
263 inline
264 void __clrcall _String_base::_Xinvarg()
265       {    // report an out_of_range error
266       _THROW(invalid_argument, "invalid string argument");
267       }
268
269 #endif
270
271 _STD_END
272 #ifdef _MSC_VER
273  #pragma warning(pop)
274  #pragma pack(pop)
275 #endif  /* _MSC_VER */
276
277 #endif /* RC_INVOKED */
278 #endif /* _STDEXCEPT_ */
279
280 /*
281  * Copyright (c) 1992-2007 by P.J. Plauger.  ALL RIGHTS RESERVED.
282  * Consult your license regarding permissions and restrictions.
283  V5.03:0009 */
284