williamr@4
|
1 |
/*
|
williamr@4
|
2 |
* Copyright (c) 1999
|
williamr@4
|
3 |
* Silicon Graphics
|
williamr@4
|
4 |
*
|
williamr@4
|
5 |
* Permission to use, copy, modify, distribute and sell this software
|
williamr@4
|
6 |
* and its documentation for any purpose is hereby granted without fee,
|
williamr@4
|
7 |
* provided that the above copyright notice appear in all copies and
|
williamr@4
|
8 |
* that both that copyright notice and this permission notice appear
|
williamr@4
|
9 |
* in supporting documentation. Silicon Graphics makes no
|
williamr@4
|
10 |
* representations about the suitability of this software for any
|
williamr@4
|
11 |
* purpose. It is provided "as is" without express or implied warranty.
|
williamr@4
|
12 |
*
|
williamr@4
|
13 |
*/
|
williamr@4
|
14 |
|
williamr@4
|
15 |
#ifndef _STLP_RANGE_ERRORS_H
|
williamr@4
|
16 |
#define _STLP_RANGE_ERRORS_H
|
williamr@4
|
17 |
|
williamr@4
|
18 |
// A few places in the STL throw range errors, using standard exception
|
williamr@4
|
19 |
// classes defined in <stdexcept>. This header file provides functions
|
williamr@4
|
20 |
// to throw those exception objects.
|
williamr@4
|
21 |
|
williamr@4
|
22 |
// _STLP_DONT_THROW_RANGE_ERRORS is a hook so that users can disable
|
williamr@4
|
23 |
// this exception throwing.
|
williamr@4
|
24 |
#if defined (_STLP_CAN_THROW_RANGE_ERRORS) && defined (_STLP_USE_EXCEPTIONS) && \
|
williamr@4
|
25 |
!defined (_STLP_DONT_THROW_RANGE_ERRORS)
|
williamr@4
|
26 |
# define _STLP_THROW_RANGE_ERRORS
|
williamr@4
|
27 |
#endif
|
williamr@4
|
28 |
|
williamr@4
|
29 |
// For the STLport iostreams, only declaration here, definition is in the lib
|
williamr@4
|
30 |
#if !defined (_STLP_USE_NO_IOSTREAMS) && !defined (_STLP_EXTERN_RANGE_ERRORS)
|
williamr@4
|
31 |
# define _STLP_EXTERN_RANGE_ERRORS
|
williamr@4
|
32 |
#endif
|
williamr@4
|
33 |
|
williamr@4
|
34 |
_STLP_BEGIN_NAMESPACE
|
williamr@4
|
35 |
void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_runtime_error(const char* __msg);
|
williamr@4
|
36 |
void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_range_error(const char* __msg);
|
williamr@4
|
37 |
void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_out_of_range(const char* __msg);
|
williamr@4
|
38 |
void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_length_error(const char* __msg);
|
williamr@4
|
39 |
void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_invalid_argument(const char* __msg);
|
williamr@4
|
40 |
void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_overflow_error(const char* __msg);
|
williamr@4
|
41 |
_STLP_END_NAMESPACE
|
williamr@4
|
42 |
|
williamr@4
|
43 |
#if !defined (_STLP_EXTERN_RANGE_ERRORS)
|
williamr@4
|
44 |
|
williamr@4
|
45 |
# if defined(_STLP_THROW_RANGE_ERRORS)
|
williamr@4
|
46 |
# ifndef _STLP_INTERNAL_STDEXCEPT
|
williamr@4
|
47 |
# include <stl/_stdexcept.h>
|
williamr@4
|
48 |
# endif
|
williamr@4
|
49 |
# ifndef _STLP_STRING
|
williamr@4
|
50 |
# include <string>
|
williamr@4
|
51 |
# endif
|
williamr@4
|
52 |
# define _STLP_THROW_MSG(ex,msg) throw ex(string(msg))
|
williamr@4
|
53 |
# else
|
williamr@4
|
54 |
# if defined (_STLP_RTTI_BUG)
|
williamr@4
|
55 |
# define _STLP_THROW_MSG(ex,msg) TerminateProcess(GetCurrentProcess(), 0)
|
williamr@4
|
56 |
# else
|
williamr@4
|
57 |
# ifndef _STLP_INTERNAL_CSTDLIB
|
williamr@4
|
58 |
# include <stl/_cstdlib.h>
|
williamr@4
|
59 |
# endif
|
williamr@4
|
60 |
# ifndef _STLP_INTERNAL_CSTDIO
|
williamr@4
|
61 |
# include <stl/_cstdio.h>
|
williamr@4
|
62 |
# endif
|
williamr@4
|
63 |
# define _STLP_THROW_MSG(ex,msg) puts(msg),_STLP_ABORT()
|
williamr@4
|
64 |
# endif
|
williamr@4
|
65 |
# endif
|
williamr@4
|
66 |
|
williamr@4
|
67 |
// For mode without library and throwing range errors, include the
|
williamr@4
|
68 |
// stdexcept header and throw the appropriate exceptions directly.
|
williamr@4
|
69 |
|
williamr@4
|
70 |
_STLP_BEGIN_NAMESPACE
|
williamr@4
|
71 |
|
williamr@4
|
72 |
inline void _STLP_DECLSPEC _STLP_CALL __stl_throw_runtime_error(const char* __msg)
|
williamr@4
|
73 |
{ _STLP_THROW_MSG(runtime_error, __msg); }
|
williamr@4
|
74 |
|
williamr@4
|
75 |
inline void _STLP_DECLSPEC _STLP_CALL __stl_throw_range_error(const char* __msg)
|
williamr@4
|
76 |
{ _STLP_THROW_MSG(range_error, __msg); }
|
williamr@4
|
77 |
|
williamr@4
|
78 |
inline void _STLP_DECLSPEC _STLP_CALL __stl_throw_out_of_range(const char* __msg)
|
williamr@4
|
79 |
{ _STLP_THROW_MSG(out_of_range, __msg); }
|
williamr@4
|
80 |
|
williamr@4
|
81 |
inline void _STLP_DECLSPEC _STLP_CALL __stl_throw_length_error(const char* __msg)
|
williamr@4
|
82 |
{ _STLP_THROW_MSG(length_error, __msg); }
|
williamr@4
|
83 |
|
williamr@4
|
84 |
inline void _STLP_DECLSPEC _STLP_CALL __stl_throw_invalid_argument(const char* __msg)
|
williamr@4
|
85 |
{ _STLP_THROW_MSG(invalid_argument, __msg); }
|
williamr@4
|
86 |
|
williamr@4
|
87 |
inline void _STLP_DECLSPEC _STLP_CALL __stl_throw_overflow_error(const char* __msg)
|
williamr@4
|
88 |
{ _STLP_THROW_MSG(overflow_error, __msg); }
|
williamr@4
|
89 |
|
williamr@4
|
90 |
_STLP_END_NAMESPACE
|
williamr@4
|
91 |
|
williamr@4
|
92 |
# undef _STLP_THROW_MSG
|
williamr@4
|
93 |
|
williamr@4
|
94 |
#endif /* EXTERN_RANGE_ERRORS */
|
williamr@4
|
95 |
|
williamr@4
|
96 |
#endif /* _STLP_RANGE_ERRORS_H */
|
williamr@4
|
97 |
|
williamr@4
|
98 |
// Local Variables:
|
williamr@4
|
99 |
// mode:C++
|
williamr@4
|
100 |
// End:
|