pattern_except.hpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. *
  3. * Copyright (c) 1998-2002
  4. * John Maddock
  5. *
  6. * Use, modification and distribution are subject to the
  7. * Boost Software License, Version 1.0. (See accompanying file
  8. * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. *
  10. */
  11. /*
  12. * LOCATION: see http://www.boost.org for most recent version.
  13. * FILE pattern_except.hpp
  14. * VERSION see <boost/version.hpp>
  15. * DESCRIPTION: Declares pattern-matching exception classes.
  16. */
  17. #ifndef BOOST_RE_PAT_EXCEPT_HPP
  18. #define BOOST_RE_PAT_EXCEPT_HPP
  19. #ifndef BOOST_REGEX_CONFIG_HPP
  20. #include <boost/regex/config.hpp>
  21. #endif
  22. #include <stdexcept>
  23. #include <cstddef>
  24. #include <boost/regex/v4/error_type.hpp>
  25. namespace boost{
  26. #ifdef BOOST_MSVC
  27. #pragma warning(push)
  28. #pragma warning(disable: 4103)
  29. #endif
  30. #ifdef BOOST_HAS_ABI_HEADERS
  31. # include BOOST_ABI_PREFIX
  32. #endif
  33. #ifdef BOOST_MSVC
  34. #pragma warning(pop)
  35. #endif
  36. #ifdef BOOST_MSVC
  37. #pragma warning(push)
  38. #pragma warning(disable : 4275)
  39. #endif
  40. class BOOST_REGEX_DECL regex_error : public std::runtime_error
  41. {
  42. public:
  43. explicit regex_error(const std::string& s, regex_constants::error_type err = regex_constants::error_unknown, std::ptrdiff_t pos = 0);
  44. explicit regex_error(regex_constants::error_type err);
  45. ~regex_error() throw();
  46. regex_constants::error_type code()const
  47. { return m_error_code; }
  48. std::ptrdiff_t position()const
  49. { return m_position; }
  50. void raise()const;
  51. private:
  52. regex_constants::error_type m_error_code;
  53. std::ptrdiff_t m_position;
  54. };
  55. typedef regex_error bad_pattern;
  56. typedef regex_error bad_expression;
  57. namespace BOOST_REGEX_DETAIL_NS{
  58. BOOST_REGEX_DECL void BOOST_REGEX_CALL raise_runtime_error(const std::runtime_error& ex);
  59. template <class traits>
  60. void raise_error(const traits& t, regex_constants::error_type code)
  61. {
  62. (void)t; // warning suppression
  63. std::runtime_error e(t.error_string(code));
  64. ::boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(e);
  65. }
  66. }
  67. #ifdef BOOST_MSVC
  68. #pragma warning(pop)
  69. #endif
  70. #ifdef BOOST_MSVC
  71. #pragma warning(push)
  72. #pragma warning(disable: 4103)
  73. #endif
  74. #ifdef BOOST_HAS_ABI_HEADERS
  75. # include BOOST_ABI_SUFFIX
  76. #endif
  77. #ifdef BOOST_MSVC
  78. #pragma warning(pop)
  79. #endif
  80. } // namespace boost
  81. #endif