libstdc++
regex_error.h
Go to the documentation of this file.
00001 // class template regex -*- C++ -*-
00002 
00003 // Copyright (C) 2010-2015 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     };
00065 
00066   /** The expression contained an invalid collating element name. */
00067   constexpr error_type error_collate(_S_error_collate);
00068 
00069   /** The expression contained an invalid character class name. */
00070   constexpr error_type error_ctype(_S_error_ctype);
00071 
00072   /**
00073    * The expression contained an invalid escaped character, or a trailing
00074    * escape.
00075    */
00076   constexpr error_type error_escape(_S_error_escape);
00077 
00078   /** The expression contained an invalid back reference. */
00079   constexpr error_type error_backref(_S_error_backref);
00080 
00081   /** The expression contained mismatched [ and ]. */
00082   constexpr error_type error_brack(_S_error_brack);
00083 
00084   /** The expression contained mismatched ( and ). */
00085   constexpr error_type error_paren(_S_error_paren);
00086 
00087   /** The expression contained mismatched { and } */
00088   constexpr error_type error_brace(_S_error_brace);
00089 
00090   /** The expression contained an invalid range in a {} expression. */
00091   constexpr error_type error_badbrace(_S_error_badbrace);
00092 
00093   /**
00094    * The expression contained an invalid character range,
00095    * such as [b-a] in most encodings.
00096    */
00097   constexpr error_type error_range(_S_error_range);
00098 
00099   /**
00100    * There was insufficient memory to convert the expression into a
00101    * finite state machine.
00102    */
00103   constexpr error_type error_space(_S_error_space);
00104 
00105   /**
00106    * One of <em>*?+{</em> was not preceded by a valid regular expression.
00107    */
00108   constexpr error_type error_badrepeat(_S_error_badrepeat);
00109 
00110   /**
00111    * The complexity of an attempted match against a regular expression
00112    * exceeded a pre-set level.
00113    */
00114   constexpr error_type error_complexity(_S_error_complexity);
00115 
00116   /**
00117    * There was insufficient memory to determine whether the
00118    * regular expression could match the specified character sequence.
00119    */
00120   constexpr error_type error_stack(_S_error_stack);
00121 
00122   //@}
00123 _GLIBCXX_END_NAMESPACE_VERSION
00124 } // namespace regex_constants
00125 
00126 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00127 
00128   // [7.8] Class regex_error
00129   /**
00130    * @brief A regular expression exception class.
00131    * @ingroup exceptions
00132    *
00133    * The regular expression library throws objects of this class on error.
00134    */
00135   class regex_error : public std::runtime_error
00136   {
00137     regex_constants::error_type _M_code;
00138 
00139   public:
00140     /**
00141      * @brief Constructs a regex_error object.
00142      *
00143      * @param __ecode the regex error code.
00144      */
00145     explicit
00146     regex_error(regex_constants::error_type __ecode);
00147 
00148     virtual ~regex_error() throw();
00149 
00150     /**
00151      * @brief Gets the regex error code.
00152      *
00153      * @returns the regex error code.
00154      */
00155     regex_constants::error_type
00156     code() const
00157     { return _M_code; }
00158   };
00159 
00160   //@} // group regex
00161 
00162   void
00163   __throw_regex_error(regex_constants::error_type __ecode);
00164 
00165 _GLIBCXX_END_NAMESPACE_VERSION
00166 } // namespace std