Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: /// \file regex_error.hpp Chris@16: /// Contains the definition of the regex_error exception class. Chris@16: // Chris@16: // Copyright 2008 Eric Niebler. Distributed under the Boost Chris@16: // Software License, Version 1.0. (See accompanying file Chris@16: // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_XPRESSIVE_REGEX_ERROR_HPP_EAN_10_04_2005 Chris@16: #define BOOST_XPRESSIVE_REGEX_ERROR_HPP_EAN_10_04_2005 Chris@16: Chris@16: // MS compatible compilers support #pragma once Chris@101: #if defined(_MSC_VER) Chris@16: # pragma once Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: //{{AFX_DOC_COMMENT Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: // This is a hack to get Doxygen to show the inheritance relation between Chris@16: // regex_error and std::runtime_error. Chris@16: #ifdef BOOST_XPRESSIVE_DOXYGEN_INVOKED Chris@16: /// INTERNAL ONLY Chris@16: namespace std Chris@16: { Chris@16: /// INTERNAL ONLY Chris@16: struct runtime_error {}; Chris@16: } Chris@16: #endif Chris@16: //}}AFX_DOC_COMMENT Chris@16: Chris@16: namespace boost { namespace xpressive Chris@16: { Chris@16: Chris@16: //////////////////////////////////////////////////////////////////////////////// Chris@16: // regex_error Chris@16: // Chris@16: /// \brief The class regex_error defines the type of objects thrown as Chris@16: /// exceptions to report errors during the conversion from a string representing Chris@16: /// a regular expression to a finite state machine. Chris@16: struct regex_error Chris@16: : std::runtime_error Chris@16: , boost::exception Chris@16: { Chris@16: /// Constructs an object of class regex_error. Chris@16: /// \param code The error_type this regex_error represents. Chris@16: /// \param str The message string of this regex_error. Chris@16: /// \post code() == code Chris@16: explicit regex_error(regex_constants::error_type code, char const *str = "") Chris@16: : std::runtime_error(str) Chris@16: , boost::exception() Chris@16: , code_(code) Chris@16: { Chris@16: } Chris@16: Chris@16: /// Accessor for the error_type value Chris@16: /// \return the error_type code passed to the constructor Chris@16: /// \throw nothrow Chris@16: regex_constants::error_type code() const Chris@16: { Chris@16: return this->code_; Chris@16: } Chris@16: Chris@16: /// Destructor for class regex_error Chris@16: /// \throw nothrow Chris@16: virtual ~regex_error() throw() Chris@16: {} Chris@16: Chris@16: private: Chris@16: Chris@16: regex_constants::error_type code_; Chris@16: }; Chris@16: Chris@16: namespace detail Chris@16: { Chris@16: inline bool ensure_( Chris@16: bool cond Chris@16: , regex_constants::error_type code Chris@16: , char const *msg Chris@16: , char const *fun Chris@16: , char const *file Chris@16: , unsigned long line Chris@16: ) Chris@16: { Chris@16: if(!cond) Chris@16: { Chris@16: #ifndef BOOST_EXCEPTION_DISABLE Chris@16: boost::throw_exception( Chris@16: boost::xpressive::regex_error(code, msg) Chris@16: << boost::throw_function(fun) Chris@16: << boost::throw_file(file) Chris@16: << boost::throw_line((int)line) Chris@16: ); Chris@16: #else Chris@16: boost::throw_exception(boost::xpressive::regex_error(code, msg)); Chris@16: #endif Chris@16: } Chris@16: return true; Chris@16: } Chris@16: } Chris@16: Chris@16: #define BOOST_XPR_ENSURE_(pred, code, msg) \ Chris@16: boost::xpressive::detail::ensure_(!!(pred), code, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__) \ Chris@16: /**/ Chris@16: Chris@16: }} // namespace boost::xpressive Chris@16: Chris@16: #endif