_range_errors.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (c) 1999
  3. * Silicon Graphics
  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. #if defined(_STLP_THROW_RANGE_ERRORS)
  15. # if defined (_STLP_WHOLE_NATIVE_STD) && defined (_STLP_DONT_REDEFINE_STD)
  16. // In this mode we are going to throw native exception so that catch of
  17. // exception like std::runtime_error for instance will also catch exception
  18. // thrown by STLport containers like stlport::vector or stlport::string.
  19. # include <stdexcept>
  20. # include <string>
  21. # define _STLP_THROW_MSG(ex,msg) throw std::ex(msg)
  22. # else
  23. # if !defined (_STLP_SGX_CONFIG) && defined (__BUILDING_STLPORT)
  24. # include <stdexcept>
  25. # include <string>
  26. # else
  27. # ifndef _STLP_INTERNAL_STDEXCEPT
  28. # include <stl/_stdexcept.h>
  29. # endif
  30. # ifndef _STLP_INTERNAL_STRING_H
  31. # include <stl/_string.h>
  32. # endif
  33. # endif
  34. # define _STLP_THROW_MSG(ex,msg) throw ex(msg)
  35. # endif
  36. #else
  37. # if !defined (_STLP_SGX_CONFIG) && defined (__BUILDING_STLPORT)
  38. # include <cstdlib>
  39. # include <cstdio>
  40. # else
  41. # ifndef _STLP_INTERNAL_CSTDLIB
  42. # include <stl/_cstdlib.h>
  43. # endif
  44. # ifndef _STLP_INTERNAL_CSTDIO
  45. # include <stl/_cstdio.h>
  46. # endif
  47. # endif
  48. # define _STLP_THROW_MSG(ex,msg) /*puts(msg),*/(void)(msg), _STLP_ABORT()
  49. #endif
  50. // For mode without library and throwing range errors, include the
  51. // stdexcept header and throw the appropriate exceptions directly.
  52. #if defined (_STLP_EXTERN_RANGE_ERRORS)
  53. # define _STLP_THROW_FUNCT_SPEC void _STLP_DECLSPEC
  54. #else
  55. # define _STLP_THROW_FUNCT_SPEC inline void
  56. #endif
  57. _STLP_BEGIN_NAMESPACE
  58. _STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_runtime_error(const char* __msg)
  59. { _STLP_THROW_MSG(runtime_error, __msg); }
  60. _STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_range_error(const char* __msg)
  61. { _STLP_THROW_MSG(range_error, __msg); }
  62. _STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_out_of_range(const char* __msg)
  63. { _STLP_THROW_MSG(out_of_range, __msg); }
  64. _STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_length_error(const char* __msg)
  65. { _STLP_THROW_MSG(length_error, __msg); }
  66. _STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_invalid_argument(const char* __msg)
  67. { _STLP_THROW_MSG(invalid_argument, __msg); }
  68. _STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_overflow_error(const char* __msg)
  69. { _STLP_THROW_MSG(overflow_error, __msg); }
  70. _STLP_END_NAMESPACE
  71. #undef _STLP_THROW_FUNCT_SPEC
  72. #undef _STLP_THROW_MSG