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