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_cursor.h 00027 * This is an internal header file, included by other library headers. 00028 * Do not attempt to use it directly. @headername{regex} 00029 */ 00030 00031 namespace std _GLIBCXX_VISIBILITY(default) 00032 { 00033 namespace __detail 00034 { 00035 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00036 00037 /** 00038 * @defgroup regex-detail Base and Implementation Classes 00039 * @ingroup regex 00040 * @{ 00041 */ 00042 00043 /// ABC for pattern matching 00044 struct _PatternCursor 00045 { 00046 virtual ~_PatternCursor() { }; 00047 virtual void _M_next() = 0; 00048 virtual bool _M_at_end() const = 0; 00049 }; 00050 00051 /// Provides a cursor into the specific target string. 00052 template<typename _FwdIterT> 00053 class _SpecializedCursor 00054 : public _PatternCursor 00055 { 00056 public: 00057 _SpecializedCursor(const _FwdIterT& __b, const _FwdIterT __e) 00058 : _M_b(__b), _M_c(__b), _M_e(__e) 00059 { } 00060 00061 typename std::iterator_traits<_FwdIterT>::value_type 00062 _M_current() const 00063 { return *_M_c; } 00064 00065 void 00066 _M_next() 00067 { ++_M_c; } 00068 00069 _FwdIterT 00070 _M_pos() const 00071 { return _M_c; } 00072 00073 const _FwdIterT& 00074 _M_begin() const 00075 { return _M_b; } 00076 00077 const _FwdIterT& 00078 _M_end() const 00079 { return _M_e; } 00080 00081 bool 00082 _M_at_end() const 00083 { return _M_c == _M_e; } 00084 00085 private: 00086 _FwdIterT _M_b; 00087 _FwdIterT _M_c; 00088 _FwdIterT _M_e; 00089 }; 00090 00091 // Helper function to create a cursor specialized for an iterator class. 00092 template<typename _FwdIterT> 00093 inline _SpecializedCursor<_FwdIterT> 00094 __cursor(const _FwdIterT& __b, const _FwdIterT __e) 00095 { return _SpecializedCursor<_FwdIterT>(__b, __e); } 00096 00097 //@} regex-detail 00098 _GLIBCXX_END_NAMESPACE_VERSION 00099 } // namespace __detail 00100 } // namespace