blob: 7ec0d45a11b1b1319c92cdcec4430a8b0cfbd1a2 [file] [log] [blame]
Jeff Thompson86b6d642013-10-17 15:01:56 -07001/*
2 *
3 * Copyright (c) 1998-2002
4 * John Maddock
5 *
6 * Use, modification and distribution are subject to the
7 * Boost Software License, Version 1.0. (See accompanying file
8 * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 *
10 */
11
12 /*
13 * LOCATION: see http://www.boost.org for most recent version.
14 * FILE pattern_except.hpp
15 * VERSION see <ndnboost/version.hpp>
16 * DESCRIPTION: Declares pattern-matching exception classes.
17 */
18
19#ifndef NDNBOOST_RE_PAT_EXCEPT_HPP
20#define NDNBOOST_RE_PAT_EXCEPT_HPP
21
22#ifndef NDNBOOST_REGEX_CONFIG_HPP
23#include <ndnboost/regex/config.hpp>
24#endif
25
26#include <stdexcept>
27#include <cstddef>
28#include <ndnboost/regex/v4/error_type.hpp>
29
30namespace ndnboost{
31
32#ifdef NDNBOOST_MSVC
33#pragma warning(push)
34#pragma warning(disable: 4103)
35#endif
36#ifdef NDNBOOST_HAS_ABI_HEADERS
37# include NDNBOOST_ABI_PREFIX
38#endif
39#ifdef NDNBOOST_MSVC
40#pragma warning(pop)
41#endif
42
43#ifdef NDNBOOST_MSVC
44#pragma warning(push)
45#pragma warning(disable : 4275)
46#endif
47class NDNBOOST_REGEX_DECL regex_error : public std::runtime_error
48{
49public:
50 explicit regex_error(const std::string& s, regex_constants::error_type err = regex_constants::error_unknown, std::ptrdiff_t pos = 0);
51 explicit regex_error(regex_constants::error_type err);
52 ~regex_error() throw();
53 regex_constants::error_type code()const
54 { return m_error_code; }
55 std::ptrdiff_t position()const
56 { return m_position; }
57 void raise()const;
58private:
59 regex_constants::error_type m_error_code;
60 std::ptrdiff_t m_position;
61};
62
63typedef regex_error bad_pattern;
64typedef regex_error bad_expression;
65
66namespace re_detail{
67
68NDNBOOST_REGEX_DECL void NDNBOOST_REGEX_CALL raise_runtime_error(const std::runtime_error& ex);
69
70template <class traits>
71void raise_error(const traits& t, regex_constants::error_type code)
72{
73 (void)t; // warning suppression
74 std::runtime_error e(t.error_string(code));
75 ::ndnboost::re_detail::raise_runtime_error(e);
76}
77
78}
79
80#ifdef NDNBOOST_MSVC
81#pragma warning(pop)
82#endif
83
84#ifdef NDNBOOST_MSVC
85#pragma warning(push)
86#pragma warning(disable: 4103)
87#endif
88#ifdef NDNBOOST_HAS_ABI_HEADERS
89# include NDNBOOST_ABI_SUFFIX
90#endif
91#ifdef NDNBOOST_MSVC
92#pragma warning(pop)
93#endif
94
95} // namespace ndnboost
96
97#endif
98
99
100