libstdc++
|
00001 // class template regex -*- C++ -*- 00002 00003 // Copyright (C) 2010-2013 Free Software Foundation, Inc. 00004 // 00005 // This file is part of the GNU ISO C++ Library. This library is free 00006 // software; you can redistribute it and/or modify it under the 00007 // terms of the GNU General Public License as published by the 00008 // Free Software Foundation; either version 3, or (at your option) 00009 // any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 00016 // Under Section 7 of GPL version 3, you are granted additional 00017 // permissions described in the GCC Runtime Library Exception, version 00018 // 3.1, as published by the Free Software Foundation. 00019 00020 // You should have received a copy of the GNU General Public License and 00021 // a copy of the GCC Runtime Library Exception along with this program; 00022 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00023 // <http://www.gnu.org/licenses/>. 00024 00025 /** 00026 * @file bits/regex_error.h 00027 * @brief Error and exception objects for the std regex library. 00028 * 00029 * This is an internal header file, included by other library headers. 00030 * Do not attempt to use it directly. @headername{regex} 00031 */ 00032 00033 namespace std _GLIBCXX_VISIBILITY(default) 00034 { 00035 /** 00036 * @addtogroup regex 00037 * @{ 00038 */ 00039 00040 namespace regex_constants 00041 { 00042 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00043 00044 /** 00045 * @name 5.3 Error Types 00046 */ 00047 //@{ 00048 00049 enum error_type 00050 { 00051 _S_error_collate, 00052 _S_error_ctype, 00053 _S_error_escape, 00054 _S_error_backref, 00055 _S_error_brack, 00056 _S_error_paren, 00057 _S_error_brace, 00058 _S_error_badbrace, 00059 _S_error_range, 00060 _S_error_space, 00061 _S_error_badrepeat, 00062 _S_error_complexity, 00063 _S_error_stack, 00064 _S_error_last 00065 }; 00066 00067 /** The expression contained an invalid collating element name. */ 00068 constexpr error_type error_collate(_S_error_collate); 00069 00070 /** The expression contained an invalid character class name. */ 00071 constexpr error_type error_ctype(_S_error_ctype); 00072 00073 /** 00074 * The expression contained an invalid escaped character, or a trailing 00075 * escape. 00076 */ 00077 constexpr error_type error_escape(_S_error_escape); 00078 00079 /** The expression contained an invalid back reference. */ 00080 constexpr error_type error_backref(_S_error_backref); 00081 00082 /** The expression contained mismatched [ and ]. */ 00083 constexpr error_type error_brack(_S_error_brack); 00084 00085 /** The expression contained mismatched ( and ). */ 00086 constexpr error_type error_paren(_S_error_paren); 00087 00088 /** The expression contained mismatched { and } */ 00089 constexpr error_type error_brace(_S_error_brace); 00090 00091 /** The expression contained an invalid range in a {} expression. */ 00092 constexpr error_type error_badbrace(_S_error_badbrace); 00093 00094 /** 00095 * The expression contained an invalid character range, 00096 * such as [b-a] in most encodings. 00097 */ 00098 constexpr error_type error_range(_S_error_range); 00099 00100 /** 00101 * There was insufficient memory to convert the expression into a 00102 * finite state machine. 00103 */ 00104 constexpr error_type error_space(_S_error_space); 00105 00106 /** 00107 * One of <em>*?+{</em> was not preceded by a valid regular expression. 00108 */ 00109 constexpr error_type error_badrepeat(_S_error_badrepeat); 00110 00111 /** 00112 * The complexity of an attempted match against a regular expression 00113 * exceeded a pre-set level. 00114 */ 00115 constexpr error_type error_complexity(_S_error_complexity); 00116 00117 /** 00118 * There was insufficient memory to determine whether the 00119 * regular expression could match the specified character sequence. 00120 */ 00121 constexpr error_type error_stack(_S_error_stack); 00122 00123 //@} 00124 _GLIBCXX_END_NAMESPACE_VERSION 00125 } // namespace regex_constants 00126 00127 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00128 00129 // [7.8] Class regex_error 00130 /** 00131 * @brief A regular expression exception class. 00132 * @ingroup exceptions 00133 * 00134 * The regular expression library throws objects of this class on error. 00135 */ 00136 class regex_error : public std::runtime_error 00137 { 00138 regex_constants::error_type _M_code; 00139 00140 public: 00141 /** 00142 * @brief Constructs a regex_error object. 00143 * 00144 * @param __ecode the regex error code. 00145 */ 00146 explicit 00147 regex_error(regex_constants::error_type __ecode); 00148 00149 virtual ~regex_error() throw(); 00150 00151 /** 00152 * @brief Gets the regex error code. 00153 * 00154 * @returns the regex error code. 00155 */ 00156 regex_constants::error_type 00157 code() const 00158 { return _M_code; } 00159 }; 00160 00161 //@} // group regex 00162 00163 void 00164 __throw_regex_error(regex_constants::error_type __ecode); 00165 00166 _GLIBCXX_END_NAMESPACE_VERSION 00167 } // namespace std