exception.hpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright Andrey Semashev 2007 - 2015.
  3. * Distributed under the Boost Software License, Version 1.0.
  4. * (See accompanying file LICENSE_1_0.txt or copy at
  5. * http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. /*!
  8. * \file support/exception.hpp
  9. * \author Andrey Semashev
  10. * \date 18.07.2009
  11. *
  12. * This header enables Boost.Exception support for Boost.Log.
  13. */
  14. #ifndef BOOST_LOG_SUPPORT_EXCEPTION_HPP_INCLUDED_
  15. #define BOOST_LOG_SUPPORT_EXCEPTION_HPP_INCLUDED_
  16. #include <string>
  17. #include <boost/type_index.hpp>
  18. #include <boost/exception/info.hpp>
  19. #include <boost/log/detail/config.hpp>
  20. #include <boost/log/attributes/attribute_name.hpp>
  21. #include <boost/log/attributes/named_scope.hpp>
  22. #include <boost/log/detail/header.hpp>
  23. #ifdef BOOST_HAS_PRAGMA_ONCE
  24. #pragma once
  25. #endif
  26. namespace boost {
  27. BOOST_LOG_OPEN_NAMESPACE
  28. /*!
  29. * Attribute name exception information
  30. */
  31. typedef error_info< struct attribute_name_info_tag, attribute_name > attribute_name_info;
  32. /*!
  33. * Type info exception information
  34. */
  35. typedef error_info< struct type_info_info_tag, typeindex::type_index > type_info_info;
  36. /*!
  37. * Parse position exception information
  38. */
  39. typedef error_info< struct position_info_tag, unsigned int > position_info;
  40. /*!
  41. * Current scope exception information
  42. */
  43. typedef error_info< struct current_scope_info_tag, attributes::named_scope_list > current_scope_info;
  44. /*!
  45. * The function returns an error information object that contains current stack of scopes.
  46. * This information can then be attached to an exception and extracted at the catch site.
  47. * The extracted scope list won't be affected by any scope changes that may happen during
  48. * the exception propagation.
  49. *
  50. * \note See the \c named_scope attribute documentation on how to maintain scope list.
  51. */
  52. inline current_scope_info current_scope()
  53. {
  54. return current_scope_info(attributes::named_scope::get_scopes());
  55. }
  56. namespace ipc {
  57. class object_name;
  58. /*!
  59. * System resource name
  60. */
  61. typedef error_info< struct object_name_tag, object_name > object_name_info;
  62. } // namespace ipc
  63. BOOST_LOG_CLOSE_NAMESPACE // namespace log
  64. } // namespace boost
  65. #include <boost/log/detail/footer.hpp>
  66. #endif // BOOST_LOG_SUPPORT_EXCEPTION_HPP_INCLUDED_