Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:53:54

0001 ///////////////////////////////////////////////////////////////////////////////
0002 /// \file regex_error.hpp
0003 /// Contains the definition of the regex_error exception class.
0004 //
0005 //  Copyright 2008 Eric Niebler. Distributed under the Boost
0006 //  Software License, Version 1.0. (See accompanying file
0007 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 #ifndef BOOST_XPRESSIVE_REGEX_ERROR_HPP_EAN_10_04_2005
0010 #define BOOST_XPRESSIVE_REGEX_ERROR_HPP_EAN_10_04_2005
0011 
0012 // MS compatible compilers support #pragma once
0013 #if defined(_MSC_VER)
0014 # pragma once
0015 #endif
0016 
0017 #include <string>
0018 #include <stdexcept>
0019 #include <boost/throw_exception.hpp>
0020 #include <boost/current_function.hpp>
0021 #include <boost/exception/exception.hpp>
0022 #include <boost/exception/info.hpp>
0023 #include <boost/xpressive/regex_constants.hpp>
0024 
0025 //{{AFX_DOC_COMMENT
0026 ///////////////////////////////////////////////////////////////////////////////
0027 // This is a hack to get Doxygen to show the inheritance relation between
0028 // regex_error and std::runtime_error.
0029 #ifdef BOOST_XPRESSIVE_DOXYGEN_INVOKED
0030 /// INTERNAL ONLY
0031 namespace std
0032 {
0033     /// INTERNAL ONLY
0034     struct runtime_error {};
0035 }
0036 #endif
0037 //}}AFX_DOC_COMMENT
0038 
0039 namespace boost { namespace xpressive
0040 {
0041 
0042 ////////////////////////////////////////////////////////////////////////////////
0043 //  regex_error
0044 //
0045 /// \brief The class regex_error defines the type of objects thrown as
0046 /// exceptions to report errors during the conversion from a string representing
0047 /// a regular expression to a finite state machine.
0048 struct regex_error
0049   : std::runtime_error
0050   , boost::exception
0051 {
0052     /// Constructs an object of class regex_error.
0053     /// \param code The error_type this regex_error represents.
0054     /// \param str The message string of this regex_error.
0055     /// \post code() == code
0056     explicit regex_error(regex_constants::error_type code, char const *str = "")
0057       : std::runtime_error(str)
0058       , boost::exception()
0059       , code_(code)
0060     {
0061     }
0062 
0063     /// Accessor for the error_type value
0064     /// \return the error_type code passed to the constructor
0065     /// \throw nothrow
0066     regex_constants::error_type code() const
0067     {
0068         return this->code_;
0069     }
0070 
0071     /// Destructor for class regex_error
0072     /// \throw nothrow
0073     virtual ~regex_error() throw()
0074     {}
0075 
0076 private:
0077 
0078     regex_constants::error_type code_;
0079 };
0080 
0081 namespace detail
0082 {
0083     inline bool ensure_(
0084         bool cond
0085       , regex_constants::error_type code
0086       , char const *msg
0087       , char const *fun
0088       , char const *file
0089       , unsigned long line
0090     )
0091     {
0092         if(!cond)
0093         {
0094             #ifndef BOOST_EXCEPTION_DISABLE
0095             boost::throw_exception(
0096                 boost::xpressive::regex_error(code, msg)
0097                     << boost::throw_function(fun)
0098                     << boost::throw_file(file)
0099                     << boost::throw_line((int)line)
0100             );
0101             #else
0102             boost::throw_exception(boost::xpressive::regex_error(code, msg));
0103             #endif
0104         }
0105         return true;
0106     }
0107 }
0108 
0109 #define BOOST_XPR_ENSURE_(pred, code, msg)                                                          \
0110     boost::xpressive::detail::ensure_(!!(pred), code, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)  \
0111     /**/
0112 
0113 }} // namespace boost::xpressive
0114 
0115 #endif