1 ///////////////////////////////////////////////////////////////////////////////
2 /// \file regex_error.hpp
3 /// Contains the definition of the regex_error exception class.
5 // Copyright 2008 Eric Niebler. Distributed under the Boost
6 // Software License, Version 1.0. (See accompanying file
7 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 #ifndef BOOST_XPRESSIVE_REGEX_ERROR_HPP_EAN_10_04_2005
10 #define BOOST_XPRESSIVE_REGEX_ERROR_HPP_EAN_10_04_2005
12 // MS compatible compilers support #pragma once
13 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
19 #include <boost/throw_exception.hpp>
20 #include <boost/exception/exception.hpp>
21 #include <boost/xpressive/regex_constants.hpp>
24 ///////////////////////////////////////////////////////////////////////////////
25 // This is a hack to get Doxygen to show the inheritance relation between
26 // regex_error and std::runtime_error.
27 #ifdef BOOST_XPRESSIVE_DOXYGEN_INVOKED
32 struct runtime_error
{};
37 namespace boost
{ namespace xpressive
40 ////////////////////////////////////////////////////////////////////////////////
43 /// \brief The class regex_error defines the type of objects thrown as
44 /// exceptions to report errors during the conversion from a string representing
45 /// a regular expression to a finite state machine.
50 /// Constructs an object of class regex_error.
51 /// \param code The error_type this regex_error represents.
52 /// \post code() == code
53 explicit regex_error(regex_constants::error_type code
, char const *str
= "")
54 : std::runtime_error(str
)
60 /// Accessor for the error_type value
61 /// \return the error_type code passed to the constructor
63 regex_constants::error_type
code() const
68 /// Destructor for class regex_error
70 virtual ~regex_error() throw()
75 regex_constants::error_type code_
;
80 // To work around a GCC warning
81 inline bool false_() { return false; }
84 #define BOOST_XPR_ENSURE_(pred, code, msg) \
89 BOOST_THROW_EXCEPTION(boost::xpressive::regex_error(code, msg)) \
90 , boost::xpressive::detail::false_() \
95 }} // namespace boost::xpressive