fix doc example typo
[boost.git] / boost / xpressive / regex_error.hpp
blob91b8a88c8f948a50c4f76ae487fd81f3fc45853a
1 ///////////////////////////////////////////////////////////////////////////////
2 /// \file regex_error.hpp
3 /// Contains the definition of the regex_error exception class.
4 //
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)
14 # pragma once
15 #endif
17 #include <string>
18 #include <stdexcept>
19 #include <boost/throw_exception.hpp>
20 #include <boost/exception/exception.hpp>
21 #include <boost/xpressive/regex_constants.hpp>
23 //{{AFX_DOC_COMMENT
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
28 /// INTERNAL ONLY
29 namespace std
31 /// INTERNAL ONLY
32 struct runtime_error {};
34 #endif
35 //}}AFX_DOC_COMMENT
37 namespace boost { namespace xpressive
40 ////////////////////////////////////////////////////////////////////////////////
41 // regex_error
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.
46 struct regex_error
47 : std::runtime_error
48 , boost::exception
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)
55 , boost::exception()
56 , code_(code)
60 /// Accessor for the error_type value
61 /// \return the error_type code passed to the constructor
62 /// \throw nothrow
63 regex_constants::error_type code() const
65 return this->code_;
68 /// Destructor for class regex_error
69 /// \throw nothrow
70 virtual ~regex_error() throw()
73 private:
75 regex_constants::error_type code_;
78 namespace detail
80 // To work around a GCC warning
81 inline bool false_() { return false; }
84 #define BOOST_XPR_ENSURE_(pred, code, msg) \
85 ( \
86 (pred) \
87 ? true \
88 : ( \
89 BOOST_THROW_EXCEPTION(boost::xpressive::regex_error(code, msg)) \
90 , boost::xpressive::detail::false_() \
91 ) \
92 ) \
93 /**/
95 }} // namespace boost::xpressive
97 #endif