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