1*38fd1498Szrj // class template regex -*- C++ -*-
2*38fd1498Szrj
3*38fd1498Szrj // Copyright (C) 2010-2018 Free Software Foundation, Inc.
4*38fd1498Szrj //
5*38fd1498Szrj // This file is part of the GNU ISO C++ Library. This library is free
6*38fd1498Szrj // software; you can redistribute it and/or modify it under the
7*38fd1498Szrj // terms of the GNU General Public License as published by the
8*38fd1498Szrj // Free Software Foundation; either version 3, or (at your option)
9*38fd1498Szrj // any later version.
10*38fd1498Szrj
11*38fd1498Szrj // This library is distributed in the hope that it will be useful,
12*38fd1498Szrj // but WITHOUT ANY WARRANTY; without even the implied warranty of
13*38fd1498Szrj // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14*38fd1498Szrj // GNU General Public License for more details.
15*38fd1498Szrj
16*38fd1498Szrj // Under Section 7 of GPL version 3, you are granted additional
17*38fd1498Szrj // permissions described in the GCC Runtime Library Exception, version
18*38fd1498Szrj // 3.1, as published by the Free Software Foundation.
19*38fd1498Szrj
20*38fd1498Szrj // You should have received a copy of the GNU General Public License and
21*38fd1498Szrj // a copy of the GCC Runtime Library Exception along with this program;
22*38fd1498Szrj // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23*38fd1498Szrj // <http://www.gnu.org/licenses/>.
24*38fd1498Szrj
25*38fd1498Szrj /**
26*38fd1498Szrj * @file bits/regex_error.h
27*38fd1498Szrj * @brief Error and exception objects for the std regex library.
28*38fd1498Szrj *
29*38fd1498Szrj * This is an internal header file, included by other library headers.
30*38fd1498Szrj * Do not attempt to use it directly. @headername{regex}
31*38fd1498Szrj */
32*38fd1498Szrj
_GLIBCXX_VISIBILITY(default)33*38fd1498Szrj namespace std _GLIBCXX_VISIBILITY(default)
34*38fd1498Szrj {
35*38fd1498Szrj _GLIBCXX_BEGIN_NAMESPACE_VERSION
36*38fd1498Szrj
37*38fd1498Szrj /**
38*38fd1498Szrj * @addtogroup regex
39*38fd1498Szrj * @{
40*38fd1498Szrj */
41*38fd1498Szrj
42*38fd1498Szrj namespace regex_constants
43*38fd1498Szrj {
44*38fd1498Szrj /**
45*38fd1498Szrj * @name 5.3 Error Types
46*38fd1498Szrj */
47*38fd1498Szrj //@{
48*38fd1498Szrj
49*38fd1498Szrj enum error_type
50*38fd1498Szrj {
51*38fd1498Szrj _S_error_collate,
52*38fd1498Szrj _S_error_ctype,
53*38fd1498Szrj _S_error_escape,
54*38fd1498Szrj _S_error_backref,
55*38fd1498Szrj _S_error_brack,
56*38fd1498Szrj _S_error_paren,
57*38fd1498Szrj _S_error_brace,
58*38fd1498Szrj _S_error_badbrace,
59*38fd1498Szrj _S_error_range,
60*38fd1498Szrj _S_error_space,
61*38fd1498Szrj _S_error_badrepeat,
62*38fd1498Szrj _S_error_complexity,
63*38fd1498Szrj _S_error_stack,
64*38fd1498Szrj };
65*38fd1498Szrj
66*38fd1498Szrj /** The expression contained an invalid collating element name. */
67*38fd1498Szrj constexpr error_type error_collate(_S_error_collate);
68*38fd1498Szrj
69*38fd1498Szrj /** The expression contained an invalid character class name. */
70*38fd1498Szrj constexpr error_type error_ctype(_S_error_ctype);
71*38fd1498Szrj
72*38fd1498Szrj /**
73*38fd1498Szrj * The expression contained an invalid escaped character, or a trailing
74*38fd1498Szrj * escape.
75*38fd1498Szrj */
76*38fd1498Szrj constexpr error_type error_escape(_S_error_escape);
77*38fd1498Szrj
78*38fd1498Szrj /** The expression contained an invalid back reference. */
79*38fd1498Szrj constexpr error_type error_backref(_S_error_backref);
80*38fd1498Szrj
81*38fd1498Szrj /** The expression contained mismatched [ and ]. */
82*38fd1498Szrj constexpr error_type error_brack(_S_error_brack);
83*38fd1498Szrj
84*38fd1498Szrj /** The expression contained mismatched ( and ). */
85*38fd1498Szrj constexpr error_type error_paren(_S_error_paren);
86*38fd1498Szrj
87*38fd1498Szrj /** The expression contained mismatched { and } */
88*38fd1498Szrj constexpr error_type error_brace(_S_error_brace);
89*38fd1498Szrj
90*38fd1498Szrj /** The expression contained an invalid range in a {} expression. */
91*38fd1498Szrj constexpr error_type error_badbrace(_S_error_badbrace);
92*38fd1498Szrj
93*38fd1498Szrj /**
94*38fd1498Szrj * The expression contained an invalid character range,
95*38fd1498Szrj * such as [b-a] in most encodings.
96*38fd1498Szrj */
97*38fd1498Szrj constexpr error_type error_range(_S_error_range);
98*38fd1498Szrj
99*38fd1498Szrj /**
100*38fd1498Szrj * There was insufficient memory to convert the expression into a
101*38fd1498Szrj * finite state machine.
102*38fd1498Szrj */
103*38fd1498Szrj constexpr error_type error_space(_S_error_space);
104*38fd1498Szrj
105*38fd1498Szrj /**
106*38fd1498Szrj * One of <em>*?+{</em> was not preceded by a valid regular expression.
107*38fd1498Szrj */
108*38fd1498Szrj constexpr error_type error_badrepeat(_S_error_badrepeat);
109*38fd1498Szrj
110*38fd1498Szrj /**
111*38fd1498Szrj * The complexity of an attempted match against a regular expression
112*38fd1498Szrj * exceeded a pre-set level.
113*38fd1498Szrj */
114*38fd1498Szrj constexpr error_type error_complexity(_S_error_complexity);
115*38fd1498Szrj
116*38fd1498Szrj /**
117*38fd1498Szrj * There was insufficient memory to determine whether the
118*38fd1498Szrj * regular expression could match the specified character sequence.
119*38fd1498Szrj */
120*38fd1498Szrj constexpr error_type error_stack(_S_error_stack);
121*38fd1498Szrj
122*38fd1498Szrj //@}
123*38fd1498Szrj } // namespace regex_constants
124*38fd1498Szrj
125*38fd1498Szrj // [7.8] Class regex_error
126*38fd1498Szrj /**
127*38fd1498Szrj * @brief A regular expression exception class.
128*38fd1498Szrj * @ingroup exceptions
129*38fd1498Szrj *
130*38fd1498Szrj * The regular expression library throws objects of this class on error.
131*38fd1498Szrj */
132*38fd1498Szrj class regex_error : public std::runtime_error
133*38fd1498Szrj {
134*38fd1498Szrj regex_constants::error_type _M_code;
135*38fd1498Szrj
136*38fd1498Szrj public:
137*38fd1498Szrj /**
138*38fd1498Szrj * @brief Constructs a regex_error object.
139*38fd1498Szrj *
140*38fd1498Szrj * @param __ecode the regex error code.
141*38fd1498Szrj */
142*38fd1498Szrj explicit
143*38fd1498Szrj regex_error(regex_constants::error_type __ecode);
144*38fd1498Szrj
145*38fd1498Szrj virtual ~regex_error() throw();
146*38fd1498Szrj
147*38fd1498Szrj /**
148*38fd1498Szrj * @brief Gets the regex error code.
149*38fd1498Szrj *
150*38fd1498Szrj * @returns the regex error code.
151*38fd1498Szrj */
152*38fd1498Szrj regex_constants::error_type
153*38fd1498Szrj code() const
154*38fd1498Szrj { return _M_code; }
155*38fd1498Szrj
156*38fd1498Szrj private:
157*38fd1498Szrj regex_error(regex_constants::error_type __ecode, const char* __what)
158*38fd1498Szrj : std::runtime_error(__what), _M_code(__ecode)
159*38fd1498Szrj { }
160*38fd1498Szrj
161*38fd1498Szrj friend void __throw_regex_error(regex_constants::error_type, const char*);
162*38fd1498Szrj };
163*38fd1498Szrj
164*38fd1498Szrj //@} // group regex
165*38fd1498Szrj
166*38fd1498Szrj void
167*38fd1498Szrj __throw_regex_error(regex_constants::error_type __ecode);
168*38fd1498Szrj
169*38fd1498Szrj inline void
170*38fd1498Szrj __throw_regex_error(regex_constants::error_type __ecode, const char* __what)
171*38fd1498Szrj { _GLIBCXX_THROW_OR_ABORT(regex_error(__ecode, __what)); }
172*38fd1498Szrj
173*38fd1498Szrj _GLIBCXX_END_NAMESPACE_VERSION
174*38fd1498Szrj } // namespace std
175