Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/boost/xpressive/regex_error.hpp @ 29

Last change on this file since 29 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 2.3 KB
Line 
1///////////////////////////////////////////////////////////////////////////////
2/// \file regex_error.hpp
3/// Contains the definition of the regex_error exception class.
4//
5//  Copyright 2004 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)
8
9#ifndef BOOST_XPRESSIVE_REGEX_ERROR_HPP_EAN_10_04_2005
10#define BOOST_XPRESSIVE_REGEX_ERROR_HPP_EAN_10_04_2005
11
12// MS compatible compilers support #pragma once
13#if defined(_MSC_VER) && (_MSC_VER >= 1020)
14# pragma once
15#endif
16
17#include <string>
18#include <stdexcept>
19#include <boost/xpressive/regex_constants.hpp>
20
21//{{AFX_DOC_COMMENT
22///////////////////////////////////////////////////////////////////////////////
23// This is a hack to get Doxygen to show the inheritance relation between
24// regex_error and std::runtime_error.
25#ifdef BOOST_XPRESSIVE_DOXYGEN_INVOKED
26/// INTERNAL ONLY
27namespace std
28{
29    /// INTERNAL ONLY
30    struct runtime_error {};
31}
32#endif
33//}}AFX_DOC_COMMENT
34
35namespace boost { namespace xpressive
36{
37
38////////////////////////////////////////////////////////////////////////////////
39//  regex_error
40//
41/// \brief The class regex_error defines the type of objects thrown as
42/// exceptions to report errors during the conversion from a string representing
43/// a regular expression to a finite state machine.
44struct regex_error
45  : std::runtime_error
46{
47    /// Constructs an object of class regex_error.
48    /// \param code The error_type this regex_error represents.
49    /// \post code() == code
50    explicit regex_error(regex_constants::error_type code, char const *str = "")
51      : std::runtime_error(str)
52      , code_(code)
53    {
54    }
55
56    /// Accessor for the error_type value
57    /// \return the error_type code passed to the constructor
58    /// \throw nothrow
59    regex_constants::error_type code() const
60    {
61        return this->code_;
62    }
63
64private:
65
66    regex_constants::error_type code_;
67};
68
69namespace detail
70{
71
72//////////////////////////////////////////////////////////////////////////
73// ensure
74/// INTERNAL ONLY
75inline bool ensure(bool predicate, regex_constants::error_type code, char const *str = "")
76{
77    return predicate ? true : throw regex_error(code, str);
78}
79
80}}} // namespace boost::xpressive::detail
81
82#endif
Note: See TracBrowser for help on using the repository browser.