exception 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright 2010-2011 PathScale, Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * 1. Redistributions of source code must retain the above copyright notice,
  8. * this list of conditions and the following disclaimer.
  9. *
  10. * 2. Redistributions in binary form must reproduce the above copyright notice,
  11. * this list of conditions and the following disclaimer in the documentation
  12. * and/or other materials provided with the distribution.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
  15. * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  16. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  17. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  18. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  19. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  20. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  21. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  22. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  23. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  24. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #ifndef _LINUX_EXCEPTION_
  27. #define _LINUX_EXCEPTION_
  28. namespace std
  29. {
  30. class exception
  31. {
  32. public:
  33. exception() throw();
  34. exception(const exception&) throw();
  35. exception& operator=(const exception&) throw();
  36. virtual ~exception();
  37. virtual const char* what() const throw();
  38. };
  39. /**
  40. * Bad allocation exception. Thrown by ::operator new() if it fails.
  41. */
  42. class bad_alloc: public exception
  43. {
  44. public:
  45. bad_alloc() throw();
  46. bad_alloc(const bad_alloc&) throw();
  47. bad_alloc& operator=(const bad_alloc&) throw();
  48. ~bad_alloc();
  49. virtual const char* what() const throw();
  50. };
  51. class bad_exception : public exception
  52. {
  53. public:
  54. bad_exception() throw();
  55. virtual ~bad_exception() throw();
  56. virtual const char* what() const throw();
  57. };
  58. bool uncaught_exception() throw();
  59. typedef void (*unexpected_handler)();
  60. unexpected_handler set_unexpected(unexpected_handler) throw();
  61. void unexpected();
  62. typedef void (*terminate_handler)();
  63. terminate_handler set_terminate(terminate_handler) throw();
  64. void terminate();
  65. } // namespace std
  66. #endif /* _LINUX_EXCEPTION_ */