Commit e07b233d by Benjamin Kosnik Committed by Benjamin Kosnik

c++config: Remove __regex nested namespace.

2012-06-27  Benjamin Kosnik  <bkoz@redhat.com>

	* include/bits/c++config: Remove __regex nested namespace.
	* include/bits/regex_compiler.h: Change __regex to
	__detail. Adjust doxygen markup, add regex-details group.
	* include/bits/regex_constants.h: Same.
	* include/bits/regex_cursor.h: Same.
	* include/bits/regex_error.h: Same.
	* include/bits/regex_grep_matcher.h: Same.
	* include/bits/regex_grep_matcher.tcc: Same.
	* include/bits/regex_nfa.h: Same.
	* include/bits/regex_nfa.tcc: Same.
	* include/bits/regex.h: Same. Remove static from global constants.

	* testsuite/ext/profile/mutex_extensions_neg.cc: Adjust line numbers.

	* include/bits/locale_classes.tcc: Add use_facet, has_facet to
	locales group.

From-SVN: r189039
parent 7fefe030
2012-06-27 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/c++config: Remove __regex nested namespace.
* include/bits/regex_compiler.h: Change __regex to
__detail. Adjust doxygen markup, add regex-details group.
* include/bits/regex_constants.h: Same.
* include/bits/regex_cursor.h: Same.
* include/bits/regex_error.h: Same.
* include/bits/regex_grep_matcher.h: Same.
* include/bits/regex_grep_matcher.tcc: Same.
* include/bits/regex_nfa.h: Same.
* include/bits/regex_nfa.tcc: Same.
* include/bits/regex.h: Same. Remove static from global constants.
* testsuite/ext/profile/mutex_extensions_neg.cc: Adjust line numbers.
* include/bits/locale_classes.tcc: Add use_facet, has_facet to
locales group.
2012-06-25 Edward Smith-Rowland <3dw4rd@verizon.net> 2012-06-25 Edward Smith-Rowland <3dw4rd@verizon.net>
* include/tr2/bool_set (count, size, num_blocks, empty, max_size): * include/tr2/bool_set (count, size, num_blocks, empty, max_size):
......
// Predefined symbols and macros -*- C++ -*- // Predefined symbols and macros -*- C++ -*-
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
// 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. // 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -210,7 +210,6 @@ namespace std ...@@ -210,7 +210,6 @@ namespace std
namespace this_thread { inline namespace __7 { } } namespace this_thread { inline namespace __7 { } }
namespace __detail { inline namespace __7 { } } namespace __detail { inline namespace __7 { } }
namespace __regex { inline namespace __7 { } }
} }
namespace __gnu_cxx namespace __gnu_cxx
......
// Locale support -*- C++ -*- // Locale support -*- C++ -*-
// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. // Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
// Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -89,6 +90,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -89,6 +90,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/** /**
* @brief Test for the presence of a facet. * @brief Test for the presence of a facet.
* @ingroup locales
* *
* has_facet tests the locale argument for the presence of the facet type * has_facet tests the locale argument for the presence of the facet type
* provided as the template parameter. Facets derived from the facet * provided as the template parameter. Facets derived from the facet
...@@ -114,6 +116,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -114,6 +116,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/** /**
* @brief Return a facet. * @brief Return a facet.
* @ingroup locales
* *
* use_facet looks for and returns a reference to a facet of type Facet * use_facet looks for and returns a reference to a facet of type Facet
* where Facet is the template parameter. If has_facet(locale) is true, * where Facet is the template parameter. If has_facet(locale) is true,
......
// class template regex -*- C++ -*- // class template regex -*- C++ -*-
// Copyright (C) 2010, 2011 Free Software Foundation, Inc. // Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -32,15 +32,13 @@ namespace std _GLIBCXX_VISIBILITY(default) ...@@ -32,15 +32,13 @@ namespace std _GLIBCXX_VISIBILITY(default)
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
/** /**
* @defgroup regex Regular Expressions * @addtogroup regex
* A facility for performing regular expression pattern matching. * @{
*/ */
//@{
// [7.7] Class regex_traits
/** /**
* @brief Describes aspects of a regular expression. * @brief Class regex_traits. Describes aspects of a regular expression.
* *
* A regular expression traits class that satisfies the requirements of * A regular expression traits class that satisfies the requirements of
* section [28.7]. * section [28.7].
...@@ -62,8 +60,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -62,8 +60,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/** /**
* @brief Constructs a default traits object. * @brief Constructs a default traits object.
*/ */
regex_traits() regex_traits() { }
{ }
/** /**
* @brief Gives the length of a C-style string starting at @p __p. * @brief Gives the length of a C-style string starting at @p __p.
...@@ -102,9 +99,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -102,9 +99,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
char_type char_type
translate_nocase(char_type __c) const translate_nocase(char_type __c) const
{ {
using std::ctype; typedef std::ctype<char_type> __ctype_type;
using std::use_facet; const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale));
return use_facet<ctype<char_type> >(_M_locale).tolower(__c); return __fctyp.tolower(__c);
} }
/** /**
...@@ -131,12 +128,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -131,12 +128,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
string_type string_type
transform(_Fwd_iter __first, _Fwd_iter __last) const transform(_Fwd_iter __first, _Fwd_iter __last) const
{ {
using std::collate; typedef std::collate<char_type> __collate_type;
using std::use_facet; const __collate_type& __fclt(use_facet<__collate_type>(_M_locale));
const collate<_Ch_type>& __c(use_facet<
collate<_Ch_type> >(_M_locale));
string_type __s(__first, __last); string_type __s(__first, __last);
return __c.transform(__s.data(), __s.data() + __s.size()); return __fclt.transform(__s.data(), __s.data() + __s.size());
} }
/** /**
...@@ -284,16 +279,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -284,16 +279,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
regex_traits<_Ch_type>:: regex_traits<_Ch_type>::
isctype(_Ch_type __c, char_class_type __f) const isctype(_Ch_type __c, char_class_type __f) const
{ {
using std::ctype; typedef std::ctype<char_type> __ctype_type;
using std::use_facet; const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale));
const ctype<_Ch_type>& __ctype(use_facet<
ctype<_Ch_type> >(_M_locale));
if (__ctype.is(__f, __c)) if (__fctyp.is(__f, __c))
return true; return true;
// special case of underscore in [[:w:]] // special case of underscore in [[:w:]]
if (__c == __ctype.widen('_')) if (__c == __fctyp.widen('_'))
{ {
const char __wb[] = "w"; const char __wb[] = "w";
char_class_type __wt = this->lookup_classname(__wb, char_class_type __wt = this->lookup_classname(__wb,
...@@ -303,7 +296,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -303,7 +296,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
// special case of [[:space:]] in [[:blank:]] // special case of [[:space:]] in [[:blank:]]
if (__ctype.is(std::ctype_base::space, __c)) if (__fctyp.is(std::ctype_base::space, __c))
{ {
const char __bb[] = "blank"; const char __bb[] = "blank";
char_class_type __bt = this->lookup_classname(__bb, char_class_type __bt = this->lookup_classname(__bb,
...@@ -320,7 +313,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -320,7 +313,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
regex_traits<_Ch_type>:: regex_traits<_Ch_type>::
value(_Ch_type __ch, int __radix) const value(_Ch_type __ch, int __radix) const
{ {
std::basic_istringstream<_Ch_type> __is(string_type(1, __ch)); std::basic_istringstream<char_type> __is(string_type(1, __ch));
int __v; int __v;
if (__radix == 8) if (__radix == 8)
__is >> std::oct; __is >> std::oct;
...@@ -354,26 +347,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -354,26 +347,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* std [28.8.1](1) * std [28.8.1](1)
*/ */
//@{ //@{
static constexpr regex_constants::syntax_option_type icase static constexpr flag_type icase = regex_constants::icase;
= regex_constants::icase; static constexpr flag_type nosubs = regex_constants::nosubs;
static constexpr regex_constants::syntax_option_type nosubs static constexpr flag_type optimize = regex_constants::optimize;
= regex_constants::nosubs; static constexpr flag_type collate = regex_constants::collate;
static constexpr regex_constants::syntax_option_type optimize static constexpr flag_type ECMAScript = regex_constants::ECMAScript;
= regex_constants::optimize; static constexpr flag_type basic = regex_constants::basic;
static constexpr regex_constants::syntax_option_type collate static constexpr flag_type extended = regex_constants::extended;
= regex_constants::collate; static constexpr flag_type awk = regex_constants::awk;
static constexpr regex_constants::syntax_option_type ECMAScript static constexpr flag_type grep = regex_constants::grep;
= regex_constants::ECMAScript; static constexpr flag_type egrep = regex_constants::egrep;
static constexpr regex_constants::syntax_option_type basic
= regex_constants::basic;
static constexpr regex_constants::syntax_option_type extended
= regex_constants::extended;
static constexpr regex_constants::syntax_option_type awk
= regex_constants::awk;
static constexpr regex_constants::syntax_option_type grep
= regex_constants::grep;
static constexpr regex_constants::syntax_option_type egrep
= regex_constants::egrep;
//@} //@}
// [7.8.2] construct/copy/destroy // [7.8.2] construct/copy/destroy
...@@ -382,8 +365,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -382,8 +365,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* character sequence. * character sequence.
*/ */
basic_regex() basic_regex()
: _M_flags(regex_constants::ECMAScript), : _M_flags(ECMAScript),
_M_automaton(__regex::__compile<const _Ch_type*, _Rx_traits>(0, 0, _M_automaton(__detail::__compile<const _Ch_type*, _Rx_traits>(0, 0,
_M_traits, _M_flags)) _M_traits, _M_flags))
{ } { }
...@@ -399,10 +382,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -399,10 +382,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @throws regex_error if @p __p is not a valid regular expression. * @throws regex_error if @p __p is not a valid regular expression.
*/ */
explicit explicit
basic_regex(const _Ch_type* __p, basic_regex(const _Ch_type* __p, flag_type __f = ECMAScript)
flag_type __f = regex_constants::ECMAScript)
: _M_flags(__f), : _M_flags(__f),
_M_automaton(__regex::__compile(__p, __p + _Rx_traits::length(__p), _M_automaton(__detail::__compile(__p, __p + _Rx_traits::length(__p),
_M_traits, _M_flags)) _M_traits, _M_flags))
{ } { }
...@@ -420,7 +402,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -420,7 +402,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/ */
basic_regex(const _Ch_type* __p, std::size_t __len, flag_type __f) basic_regex(const _Ch_type* __p, std::size_t __len, flag_type __f)
: _M_flags(__f), : _M_flags(__f),
_M_automaton(__regex::__compile(__p, __p + __len, _M_traits, _M_flags)) _M_automaton(__detail::__compile(__p, __p + __len, _M_traits, _M_flags))
{ } { }
/** /**
...@@ -456,9 +438,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -456,9 +438,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
explicit explicit
basic_regex(const std::basic_string<_Ch_type, _Ch_traits, basic_regex(const std::basic_string<_Ch_type, _Ch_traits,
_Ch_alloc>& __s, _Ch_alloc>& __s,
flag_type __f = regex_constants::ECMAScript) flag_type __f = ECMAScript)
: _M_flags(__f), : _M_flags(__f),
_M_automaton(__regex::__compile(__s.begin(), __s.end(), _M_automaton(__detail::__compile(__s.begin(), __s.end(),
_M_traits, _M_flags)) _M_traits, _M_flags))
{ } { }
...@@ -477,9 +459,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -477,9 +459,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/ */
template<typename _InputIterator> template<typename _InputIterator>
basic_regex(_InputIterator __first, _InputIterator __last, basic_regex(_InputIterator __first, _InputIterator __last,
flag_type __f = regex_constants::ECMAScript) flag_type __f = ECMAScript)
: _M_flags(__f), : _M_flags(__f),
_M_automaton(__regex::__compile(__first, __last, _M_traits, _M_flags)) _M_automaton(__detail::__compile(__first, __last, _M_traits, _M_flags))
{ } { }
/** /**
...@@ -491,9 +473,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -491,9 +473,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @throws regex_error if @p __l is not a valid regular expression. * @throws regex_error if @p __l is not a valid regular expression.
*/ */
basic_regex(initializer_list<_Ch_type> __l, basic_regex(initializer_list<_Ch_type> __l,
flag_type __f = regex_constants::ECMAScript) flag_type __f = ECMAScript)
: _M_flags(__f), : _M_flags(__f),
_M_automaton(__regex::__compile(__l.begin(), __l.end(), _M_automaton(__detail::__compile(__l.begin(), __l.end(),
_M_traits, _M_flags)) _M_traits, _M_flags))
{ } { }
...@@ -534,9 +516,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -534,9 +516,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* *
* @param __s A pointer to a string containing a regular expression. * @param __s A pointer to a string containing a regular expression.
*/ */
template<typename _Ch_typeraits, typename _Allocator> template<typename _Ch_typeraits, typename _Alloc>
basic_regex& basic_regex&
operator=(const basic_string<_Ch_type, _Ch_typeraits, _Allocator>& __s) operator=(const basic_string<_Ch_type, _Ch_typeraits, _Alloc>& __s)
{ return this->assign(__s, flags()); } { return this->assign(__s, flags()); }
// [7.8.3] assign // [7.8.3] assign
...@@ -580,8 +562,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -580,8 +562,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* regex_error is thrown, *this remains unchanged. * regex_error is thrown, *this remains unchanged.
*/ */
basic_regex& basic_regex&
assign(const _Ch_type* __p, assign(const _Ch_type* __p, flag_type __flags = ECMAScript)
flag_type __flags = regex_constants::ECMAScript)
{ return this->assign(string_type(__p), __flags); } { return this->assign(string_type(__p), __flags); }
/** /**
...@@ -612,10 +593,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -612,10 +593,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* expression pattern interpreted according to @p __flags. If * expression pattern interpreted according to @p __flags. If
* regex_error is thrown, *this remains unchanged. * regex_error is thrown, *this remains unchanged.
*/ */
template<typename _Ch_typeraits, typename _Allocator> template<typename _Ch_typeraits, typename _Alloc>
basic_regex& basic_regex&
assign(const basic_string<_Ch_type, _Ch_typeraits, _Allocator>& __s, assign(const basic_string<_Ch_type, _Ch_typeraits, _Alloc>& __s,
flag_type __flags = regex_constants::ECMAScript) flag_type __flags = ECMAScript)
{ {
basic_regex __tmp(__s, __flags); basic_regex __tmp(__s, __flags);
this->swap(__tmp); this->swap(__tmp);
...@@ -638,7 +619,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -638,7 +619,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _InputIterator> template<typename _InputIterator>
basic_regex& basic_regex&
assign(_InputIterator __first, _InputIterator __last, assign(_InputIterator __first, _InputIterator __last,
flag_type __flags = regex_constants::ECMAScript) flag_type __flags = ECMAScript)
{ return this->assign(string_type(__first, __last), __flags); } { return this->assign(string_type(__first, __last), __flags); }
/** /**
...@@ -653,8 +634,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -653,8 +634,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* unchanged. * unchanged.
*/ */
basic_regex& basic_regex&
assign(initializer_list<_Ch_type> __l, assign(initializer_list<_Ch_type> __l, flag_type __flags = ECMAScript)
flag_type __flags = regex_constants::ECMAScript)
{ return this->assign(__l.begin(), __l.end(), __flags); } { return this->assign(__l.begin(), __l.end(), __flags); }
// [7.8.4] const operations // [7.8.4] const operations
...@@ -712,18 +692,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -712,18 +692,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ _M_automaton->_M_dot(__ostr); } { _M_automaton->_M_dot(__ostr); }
#endif #endif
const __regex::_AutomatonPtr& const __detail::_AutomatonPtr&
_M_get_automaton() const _M_get_automaton() const
{ return _M_automaton; } { return _M_automaton; }
protected: protected:
flag_type _M_flags; flag_type _M_flags;
_Rx_traits _M_traits; _Rx_traits _M_traits;
__regex::_AutomatonPtr _M_automaton; __detail::_AutomatonPtr _M_automaton;
}; };
/** @brief Standard regular expressions. */ /** @brief Standard regular expressions. */
typedef basic_regex<char> regex; typedef basic_regex<char> regex;
#ifdef _GLIBCXX_USE_WCHAR_T #ifdef _GLIBCXX_USE_WCHAR_T
/** @brief Standard wide-character regular expressions. */ /** @brief Standard wide-character regular expressions. */
typedef basic_regex<wchar_t> wregex; typedef basic_regex<wchar_t> wregex;
...@@ -759,14 +740,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -759,14 +740,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _BiIter> template<typename _BiIter>
class sub_match : public std::pair<_BiIter, _BiIter> class sub_match : public std::pair<_BiIter, _BiIter>
{ {
typedef iterator_traits<_BiIter> __iter_traits;
public: public:
typedef typename iterator_traits<_BiIter>::value_type value_type; typedef typename __iter_traits::value_type value_type;
typedef typename iterator_traits<_BiIter>::difference_type typedef typename __iter_traits::difference_type difference_type;
difference_type;
typedef _BiIter iterator; typedef _BiIter iterator;
typedef std::basic_string<value_type> string_type; typedef std::basic_string<value_type> string_type;
public:
bool matched; bool matched;
constexpr sub_match() : matched() { } constexpr sub_match() : matched() { }
...@@ -851,11 +832,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -851,11 +832,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/** @brief Standard regex submatch over a C-style null-terminated string. */ /** @brief Standard regex submatch over a C-style null-terminated string. */
typedef sub_match<const char*> csub_match; typedef sub_match<const char*> csub_match;
/** @brief Standard regex submatch over a standard string. */ /** @brief Standard regex submatch over a standard string. */
typedef sub_match<string::const_iterator> ssub_match; typedef sub_match<string::const_iterator> ssub_match;
#ifdef _GLIBCXX_USE_WCHAR_T #ifdef _GLIBCXX_USE_WCHAR_T
/** @brief Regex submatch over a C-style null-terminated wide string. */ /** @brief Regex submatch over a C-style null-terminated wide string. */
typedef sub_match<const wchar_t*> wcsub_match; typedef sub_match<const wchar_t*> wcsub_match;
/** @brief Regex submatch over a standard wide string. */ /** @brief Regex submatch over a standard wide string. */
typedef sub_match<wstring::const_iterator> wssub_match; typedef sub_match<wstring::const_iterator> wssub_match;
#endif #endif
...@@ -870,8 +854,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -870,8 +854,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/ */
template<typename _BiIter> template<typename _BiIter>
inline bool inline bool
operator==(const sub_match<_BiIter>& __lhs, operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
const sub_match<_BiIter>& __rhs)
{ return __lhs.compare(__rhs) == 0; } { return __lhs.compare(__rhs) == 0; }
/** /**
...@@ -882,8 +865,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -882,8 +865,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/ */
template<typename _BiIter> template<typename _BiIter>
inline bool inline bool
operator!=(const sub_match<_BiIter>& __lhs, operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
const sub_match<_BiIter>& __rhs)
{ return __lhs.compare(__rhs) != 0; } { return __lhs.compare(__rhs) != 0; }
/** /**
...@@ -894,8 +876,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -894,8 +876,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/ */
template<typename _BiIter> template<typename _BiIter>
inline bool inline bool
operator<(const sub_match<_BiIter>& __lhs, operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
const sub_match<_BiIter>& __rhs)
{ return __lhs.compare(__rhs) < 0; } { return __lhs.compare(__rhs) < 0; }
/** /**
...@@ -906,8 +887,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -906,8 +887,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/ */
template<typename _BiIter> template<typename _BiIter>
inline bool inline bool
operator<=(const sub_match<_BiIter>& __lhs, operator<=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
const sub_match<_BiIter>& __rhs)
{ return __lhs.compare(__rhs) <= 0; } { return __lhs.compare(__rhs) <= 0; }
/** /**
...@@ -918,8 +898,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -918,8 +898,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/ */
template<typename _BiIter> template<typename _BiIter>
inline bool inline bool
operator>=(const sub_match<_BiIter>& __lhs, operator>=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
const sub_match<_BiIter>& __rhs)
{ return __lhs.compare(__rhs) >= 0; } { return __lhs.compare(__rhs) >= 0; }
/** /**
...@@ -930,10 +909,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -930,10 +909,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/ */
template<typename _BiIter> template<typename _BiIter>
inline bool inline bool
operator>(const sub_match<_BiIter>& __lhs, operator>(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
const sub_match<_BiIter>& __rhs)
{ return __lhs.compare(__rhs) > 0; } { return __lhs.compare(__rhs) > 0; }
// Alias for sub_match'd string.
template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
using __sub_match_string = basic_string<
typename iterator_traits<_Bi_iter>::value_type,
_Ch_traits, _Ch_alloc>;
/** /**
* @brief Tests the equivalence of a string and a regular expression * @brief Tests the equivalence of a string and a regular expression
* submatch. * submatch.
...@@ -943,9 +927,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -943,9 +927,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/ */
template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
inline bool inline bool
operator==(const basic_string< operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
typename iterator_traits<_Bi_iter>::value_type,
_Ch_traits, _Ch_alloc>& __lhs,
const sub_match<_Bi_iter>& __rhs) const sub_match<_Bi_iter>& __rhs)
{ return __rhs.compare(__lhs.c_str()) == 0; } { return __rhs.compare(__lhs.c_str()) == 0; }
...@@ -958,9 +940,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -958,9 +940,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/ */
template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
inline bool inline bool
operator!=(const basic_string< operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
typename iterator_traits<_Bi_iter>::value_type, const sub_match<_Bi_iter>& __rhs)
_Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
{ return !(__lhs == __rhs); } { return !(__lhs == __rhs); }
/** /**
...@@ -971,9 +952,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -971,9 +952,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/ */
template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
inline bool inline bool
operator<(const basic_string< operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
typename iterator_traits<_Bi_iter>::value_type, const sub_match<_Bi_iter>& __rhs)
_Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
{ return __rhs.compare(__lhs.c_str()) > 0; } { return __rhs.compare(__lhs.c_str()) > 0; }
/** /**
...@@ -984,9 +964,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -984,9 +964,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/ */
template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
inline bool inline bool
operator>(const basic_string< operator>(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
typename iterator_traits<_Bi_iter>::value_type, const sub_match<_Bi_iter>& __rhs)
_Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
{ return __rhs < __lhs; } { return __rhs < __lhs; }
/** /**
...@@ -997,9 +976,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -997,9 +976,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/ */
template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
inline bool inline bool
operator>=(const basic_string< operator>=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
typename iterator_traits<_Bi_iter>::value_type, const sub_match<_Bi_iter>& __rhs)
_Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
{ return !(__lhs < __rhs); } { return !(__lhs < __rhs); }
/** /**
...@@ -1010,9 +988,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1010,9 +988,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/ */
template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
inline bool inline bool
operator<=(const basic_string< operator<=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
typename iterator_traits<_Bi_iter>::value_type, const sub_match<_Bi_iter>& __rhs)
_Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
{ return !(__rhs < __lhs); } { return !(__rhs < __lhs); }
/** /**
...@@ -1025,9 +1002,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1025,9 +1002,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
inline bool inline bool
operator==(const sub_match<_Bi_iter>& __lhs, operator==(const sub_match<_Bi_iter>& __lhs,
const basic_string< const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
typename iterator_traits<_Bi_iter>::value_type,
_Ch_traits, _Ch_alloc>& __rhs)
{ return __lhs.compare(__rhs.c_str()) == 0; } { return __lhs.compare(__rhs.c_str()) == 0; }
/** /**
...@@ -1040,9 +1015,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1040,9 +1015,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
inline bool inline bool
operator!=(const sub_match<_Bi_iter>& __lhs, operator!=(const sub_match<_Bi_iter>& __lhs,
const basic_string< const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
typename iterator_traits<_Bi_iter>::value_type,
_Ch_traits, _Ch_alloc>& __rhs)
{ return !(__lhs == __rhs); } { return !(__lhs == __rhs); }
/** /**
...@@ -1054,9 +1027,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1054,9 +1027,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc> template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
inline bool inline bool
operator<(const sub_match<_Bi_iter>& __lhs, operator<(const sub_match<_Bi_iter>& __lhs,
const basic_string< const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
typename iterator_traits<_Bi_iter>::value_type,
_Ch_traits, _Ch_alloc>& __rhs)
{ return __lhs.compare(__rhs.c_str()) < 0; } { return __lhs.compare(__rhs.c_str()) < 0; }
/** /**
...@@ -1068,9 +1039,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1068,9 +1039,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc> template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
inline bool inline bool
operator>(const sub_match<_Bi_iter>& __lhs, operator>(const sub_match<_Bi_iter>& __lhs,
const basic_string< const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
typename iterator_traits<_Bi_iter>::value_type,
_Ch_traits, _Ch_alloc>& __rhs)
{ return __rhs < __lhs; } { return __rhs < __lhs; }
/** /**
...@@ -1082,9 +1051,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1082,9 +1051,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc> template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
inline bool inline bool
operator>=(const sub_match<_Bi_iter>& __lhs, operator>=(const sub_match<_Bi_iter>& __lhs,
const basic_string< const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
typename iterator_traits<_Bi_iter>::value_type,
_Ch_traits, _Ch_alloc>& __rhs)
{ return !(__lhs < __rhs); } { return !(__lhs < __rhs); }
/** /**
...@@ -1096,9 +1063,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1096,9 +1063,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc> template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
inline bool inline bool
operator<=(const sub_match<_Bi_iter>& __lhs, operator<=(const sub_match<_Bi_iter>& __lhs,
const basic_string< const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
typename iterator_traits<_Bi_iter>::value_type,
_Ch_traits, _Ch_alloc>& __rhs)
{ return !(__rhs < __lhs); } { return !(__rhs < __lhs); }
/** /**
...@@ -1261,8 +1226,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1261,8 +1226,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs, operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
const sub_match<_Bi_iter>& __rhs) const sub_match<_Bi_iter>& __rhs)
{ {
return __rhs.compare(typename sub_match<_Bi_iter>::string_type(1, __lhs)) typedef typename sub_match<_Bi_iter>::string_type string_type;
== 0; return __rhs.compare(string_type(1, __lhs)) == 0;
} }
/** /**
...@@ -1289,8 +1254,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1289,8 +1254,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
const sub_match<_Bi_iter>& __rhs) const sub_match<_Bi_iter>& __rhs)
{ {
return __rhs.compare(typename sub_match<_Bi_iter>::string_type(1, __lhs)) typedef typename sub_match<_Bi_iter>::string_type string_type;
> 0; return __rhs.compare(string_type(1, __lhs)) > 0;
} }
/** /**
...@@ -1341,8 +1306,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1341,8 +1306,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator==(const sub_match<_Bi_iter>& __lhs, operator==(const sub_match<_Bi_iter>& __lhs,
typename iterator_traits<_Bi_iter>::value_type const& __rhs) typename iterator_traits<_Bi_iter>::value_type const& __rhs)
{ {
return __lhs.compare(typename sub_match<_Bi_iter>::string_type(1, __rhs)) typedef typename sub_match<_Bi_iter>::string_type string_type;
== 0; return __lhs.compare(string_type(1, __rhs)) == 0;
} }
/** /**
...@@ -1369,8 +1334,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1369,8 +1334,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<(const sub_match<_Bi_iter>& __lhs, operator<(const sub_match<_Bi_iter>& __lhs,
typename iterator_traits<_Bi_iter>::value_type const& __rhs) typename iterator_traits<_Bi_iter>::value_type const& __rhs)
{ {
return __lhs.compare(typename sub_match<_Bi_iter>::string_type(1, __rhs)) typedef typename sub_match<_Bi_iter>::string_type string_type;
< 0; return __lhs.compare(string_type(1, __rhs)) < 0;
} }
/** /**
...@@ -1460,9 +1425,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1460,9 +1425,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @nosubgrouping * @nosubgrouping
*/ */
template<typename _Bi_iter, template<typename _Bi_iter,
typename _Allocator = allocator<sub_match<_Bi_iter> > > typename _Alloc = allocator<sub_match<_Bi_iter> > >
class match_results class match_results
: private std::vector<sub_match<_Bi_iter>, _Allocator> : private std::vector<sub_match<_Bi_iter>, _Alloc>
{ {
private: private:
/* /*
...@@ -1476,25 +1441,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1476,25 +1441,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* [n+1] prefix * [n+1] prefix
* [n+2] suffix * [n+2] suffix
*/ */
typedef std::vector<sub_match<_Bi_iter>, _Allocator> _Base_type; typedef std::vector<sub_match<_Bi_iter>, _Alloc> _Base_type;
typedef std::iterator_traits<_Bi_iter> __iter_traits;
typedef regex_constants::match_flag_type match_flag_type;
public: public:
/** /**
* @name 10.? Public Types * @name 10.? Public Types
*/ */
//@{ //@{
typedef _Alloc allocator_type;
typedef sub_match<_Bi_iter> value_type; typedef sub_match<_Bi_iter> value_type;
typedef const value_type& const_reference; typedef const value_type& const_reference;
typedef const_reference reference; typedef const_reference reference;
typedef typename _Base_type::const_iterator const_iterator; typedef typename _Base_type::const_iterator const_iterator;
typedef const_iterator iterator; typedef const_iterator iterator;
typedef typename std::iterator_traits<_Bi_iter>::difference_type typedef typename __iter_traits::difference_type difference_type;
difference_type; typedef typename __iter_traits::value_type char_type;
typedef typename allocator_traits<_Allocator>::size_type typedef typename allocator_traits<_Alloc>::size_type size_type;
size_type;
typedef _Allocator allocator_type;
typedef typename std::iterator_traits<_Bi_iter>::value_type
char_type;
typedef std::basic_string<char_type> string_type; typedef std::basic_string<char_type> string_type;
//@} //@}
...@@ -1509,7 +1475,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1509,7 +1475,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @post size() returns 0 and str() returns an empty string. * @post size() returns 0 and str() returns an empty string.
*/ */
explicit explicit
match_results(const _Allocator& __a = _Allocator()) match_results(const _Alloc& __a = _Alloc())
: _Base_type(__a) : _Base_type(__a)
{ } { }
...@@ -1751,8 +1717,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1751,8 +1717,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Out_iter _Out_iter
format(_Out_iter __out, const char_type* __fmt_first, format(_Out_iter __out, const char_type* __fmt_first,
const char_type* __fmt_last, const char_type* __fmt_last,
regex_constants::match_flag_type __flags match_flag_type __flags = regex_constants::format_default) const
= regex_constants::format_default) const
{ return __out; } { return __out; }
/** /**
...@@ -1761,8 +1726,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1761,8 +1726,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Out_iter, typename _St, typename _Sa> template<typename _Out_iter, typename _St, typename _Sa>
_Out_iter _Out_iter
format(_Out_iter __out, const basic_string<char_type, _St, _Sa>& __fmt, format(_Out_iter __out, const basic_string<char_type, _St, _Sa>& __fmt,
regex_constants::match_flag_type __flags match_flag_type __flags = regex_constants::format_default) const
= regex_constants::format_default) const
{ {
return format(__out, __fmt.data(), __fmt.data() + __fmt.size(), return format(__out, __fmt.data(), __fmt.data() + __fmt.size(),
__flags); __flags);
...@@ -1774,8 +1738,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1774,8 +1738,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Out_iter, typename _St, typename _Sa> template<typename _Out_iter, typename _St, typename _Sa>
basic_string<char_type, _St, _Sa> basic_string<char_type, _St, _Sa>
format(const basic_string<char_type, _St, _Sa>& __fmt, format(const basic_string<char_type, _St, _Sa>& __fmt,
regex_constants::match_flag_type __flags match_flag_type __flags = regex_constants::format_default) const
= regex_constants::format_default) const
{ {
basic_string<char_type, _St, _Sa> __result; basic_string<char_type, _St, _Sa> __result;
format(std::back_inserter(__result), __fmt, __flags); format(std::back_inserter(__result), __fmt, __flags);
...@@ -1787,8 +1750,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1787,8 +1750,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/ */
string_type string_type
format(const char_type* __fmt, format(const char_type* __fmt,
regex_constants::match_flag_type __flags match_flag_type __flags = regex_constants::format_default) const
= regex_constants::format_default) const
{ {
string_type __result; string_type __result;
format(std::back_inserter(__result), format(std::back_inserter(__result),
...@@ -1827,7 +1789,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1827,7 +1789,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
//@} //@}
private: private:
friend class __regex::_SpecializedResults<_Bi_iter, _Allocator>; friend class __detail::_SpecializedResults<_Bi_iter, _Alloc>;
}; };
typedef match_results<const char*> cmatch; typedef match_results<const char*> cmatch;
...@@ -1843,10 +1805,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1843,10 +1805,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @returns true if the two objects refer to the same match, * @returns true if the two objects refer to the same match,
* false otherwise. * false otherwise.
*/ */
template<typename _Bi_iter, typename _Allocator> template<typename _Bi_iter, typename _Alloc>
inline bool inline bool
operator==(const match_results<_Bi_iter, _Allocator>& __m1, operator==(const match_results<_Bi_iter, _Alloc>& __m1,
const match_results<_Bi_iter, _Allocator>& __m2) const match_results<_Bi_iter, _Alloc>& __m2)
{ {
if (__m1.ready() != __m2.ready()) if (__m1.ready() != __m2.ready())
return false; return false;
...@@ -1867,10 +1829,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1867,10 +1829,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @returns true if the two objects do not refer to the same match, * @returns true if the two objects do not refer to the same match,
* false otherwise. * false otherwise.
*/ */
template<typename _Bi_iter, class _Allocator> template<typename _Bi_iter, class _Alloc>
inline bool inline bool
operator!=(const match_results<_Bi_iter, _Allocator>& __m1, operator!=(const match_results<_Bi_iter, _Alloc>& __m1,
const match_results<_Bi_iter, _Allocator>& __m2) const match_results<_Bi_iter, _Alloc>& __m2)
{ return !(__m1 == __m2); } { return !(__m1 == __m2); }
// [7.10.6] match_results swap // [7.10.6] match_results swap
...@@ -1881,10 +1843,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1881,10 +1843,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* *
* The contents of the two match_results objects are swapped. * The contents of the two match_results objects are swapped.
*/ */
template<typename _Bi_iter, typename _Allocator> template<typename _Bi_iter, typename _Alloc>
inline void inline void
swap(match_results<_Bi_iter, _Allocator>& __lhs, swap(match_results<_Bi_iter, _Alloc>& __lhs,
match_results<_Bi_iter, _Allocator>& __rhs) match_results<_Bi_iter, _Alloc>& __rhs)
{ __lhs.swap(__rhs); } { __lhs.swap(__rhs); }
// [7.11.2] Function template regex_match // [7.11.2] Function template regex_match
...@@ -1910,21 +1872,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1910,21 +1872,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* *
* @todo Implement this function. * @todo Implement this function.
*/ */
template<typename _Bi_iter, typename _Allocator, template<typename _Bi_iter, typename _Alloc,
typename _Ch_type, typename _Rx_traits> typename _Ch_type, typename _Rx_traits>
bool bool
regex_match(_Bi_iter __s, regex_match(_Bi_iter __s,
_Bi_iter __e, _Bi_iter __e,
match_results<_Bi_iter, _Allocator>& __m, match_results<_Bi_iter, _Alloc>& __m,
const basic_regex<_Ch_type, _Rx_traits>& __re, const basic_regex<_Ch_type, _Rx_traits>& __re,
regex_constants::match_flag_type __flags regex_constants::match_flag_type __flags
= regex_constants::match_default) = regex_constants::match_default)
{ {
__regex::_AutomatonPtr __a = __re._M_get_automaton(); __detail::_AutomatonPtr __a = __re._M_get_automaton();
__regex::_Automaton::_SizeT __sz = __a->_M_sub_count(); __detail::_Automaton::_SizeT __sz = __a->_M_sub_count();
__regex::_SpecializedCursor<_Bi_iter> __cs(__s, __e); __detail::_SpecializedCursor<_Bi_iter> __cs(__s, __e);
__regex::_SpecializedResults<_Bi_iter, _Allocator> __r(__sz, __cs, __m); __detail::_SpecializedResults<_Bi_iter, _Alloc> __r(__sz, __cs, __m);
__regex::_Grep_matcher __matcher(__cs, __r, __a, __flags); __detail::_Grep_matcher __matcher(__cs, __r, __a, __flags);
return __m[0].matched; return __m[0].matched;
} }
...@@ -1967,10 +1929,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1967,10 +1929,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* *
* @throws an exception of type regex_error. * @throws an exception of type regex_error.
*/ */
template<typename _Ch_type, typename _Allocator, typename _Rx_traits> template<typename _Ch_type, typename _Alloc, typename _Rx_traits>
inline bool inline bool
regex_match(const _Ch_type* __s, regex_match(const _Ch_type* __s,
match_results<const _Ch_type*, _Allocator>& __m, match_results<const _Ch_type*, _Alloc>& __m,
const basic_regex<_Ch_type, _Rx_traits>& __re, const basic_regex<_Ch_type, _Rx_traits>& __re,
regex_constants::match_flag_type __f regex_constants::match_flag_type __f
= regex_constants::match_default) = regex_constants::match_default)
...@@ -1991,11 +1953,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1991,11 +1953,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @throws an exception of type regex_error. * @throws an exception of type regex_error.
*/ */
template<typename _Ch_traits, typename _Ch_alloc, template<typename _Ch_traits, typename _Ch_alloc,
typename _Allocator, typename _Ch_type, typename _Rx_traits> typename _Alloc, typename _Ch_type, typename _Rx_traits>
inline bool inline bool
regex_match(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s, regex_match(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s,
match_results<typename basic_string<_Ch_type, match_results<typename basic_string<_Ch_type,
_Ch_traits, _Ch_alloc>::const_iterator, _Allocator>& __m, _Ch_traits, _Ch_alloc>::const_iterator, _Alloc>& __m,
const basic_regex<_Ch_type, _Rx_traits>& __re, const basic_regex<_Ch_type, _Rx_traits>& __re,
regex_constants::match_flag_type __flags regex_constants::match_flag_type __flags
= regex_constants::match_default) = regex_constants::match_default)
...@@ -2060,11 +2022,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2060,11 +2022,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* *
* @todo Implement this function. * @todo Implement this function.
*/ */
template<typename _Bi_iter, typename _Allocator, template<typename _Bi_iter, typename _Alloc,
typename _Ch_type, typename _Rx_traits> typename _Ch_type, typename _Rx_traits>
inline bool inline bool
regex_search(_Bi_iter __first, _Bi_iter __last, regex_search(_Bi_iter __first, _Bi_iter __last,
match_results<_Bi_iter, _Allocator>& __m, match_results<_Bi_iter, _Alloc>& __m,
const basic_regex<_Ch_type, _Rx_traits>& __re, const basic_regex<_Ch_type, _Rx_traits>& __re,
regex_constants::match_flag_type __flags regex_constants::match_flag_type __flags
= regex_constants::match_default) = regex_constants::match_default)
...@@ -2106,10 +2068,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2106,10 +2068,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* *
* @throws an exception of type regex_error. * @throws an exception of type regex_error.
*/ */
template<typename _Ch_type, class _Allocator, class _Rx_traits> template<typename _Ch_type, class _Alloc, class _Rx_traits>
inline bool inline bool
regex_search(const _Ch_type* __s, regex_search(const _Ch_type* __s,
match_results<const _Ch_type*, _Allocator>& __m, match_results<const _Ch_type*, _Alloc>& __m,
const basic_regex<_Ch_type, _Rx_traits>& __e, const basic_regex<_Ch_type, _Rx_traits>& __e,
regex_constants::match_flag_type __f regex_constants::match_flag_type __f
= regex_constants::match_default) = regex_constants::match_default)
...@@ -2168,12 +2130,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2168,12 +2130,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @throws an exception of type regex_error. * @throws an exception of type regex_error.
*/ */
template<typename _Ch_traits, typename _Ch_alloc, template<typename _Ch_traits, typename _Ch_alloc,
typename _Allocator, typename _Ch_type, typename _Alloc, typename _Ch_type,
typename _Rx_traits> typename _Rx_traits>
inline bool inline bool
regex_search(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s, regex_search(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s,
match_results<typename basic_string<_Ch_type, match_results<typename basic_string<_Ch_type,
_Ch_traits, _Ch_alloc>::const_iterator, _Allocator>& __m, _Ch_traits, _Ch_alloc>::const_iterator, _Alloc>& __m,
const basic_regex<_Ch_type, _Rx_traits>& __e, const basic_regex<_Ch_type, _Rx_traits>& __e,
regex_constants::match_flag_type __f regex_constants::match_flag_type __f
= regex_constants::match_default) = regex_constants::match_default)
...@@ -2249,7 +2211,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2249,7 +2211,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef const value_type& reference; typedef const value_type& reference;
typedef std::forward_iterator_tag iterator_category; typedef std::forward_iterator_tag iterator_category;
public:
/** /**
* @brief Provides a singular iterator, useful for indicating * @brief Provides a singular iterator, useful for indicating
* one-past-the-end of a range. * one-past-the-end of a range.
...@@ -2506,11 +2467,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2506,11 +2467,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/** @brief Token iterator for C-style NULL-terminated strings. */ /** @brief Token iterator for C-style NULL-terminated strings. */
typedef regex_token_iterator<const char*> cregex_token_iterator; typedef regex_token_iterator<const char*> cregex_token_iterator;
/** @brief Token iterator for standard strings. */ /** @brief Token iterator for standard strings. */
typedef regex_token_iterator<string::const_iterator> sregex_token_iterator; typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
#ifdef _GLIBCXX_USE_WCHAR_T #ifdef _GLIBCXX_USE_WCHAR_T
/** @brief Token iterator for C-style NULL-terminated wide strings. */ /** @brief Token iterator for C-style NULL-terminated wide strings. */
typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator; typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
/** @brief Token iterator for standard wide-character strings. */ /** @brief Token iterator for standard wide-character strings. */
typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
#endif #endif
......
// class template regex -*- C++ -*- // class template regex -*- C++ -*-
// Copyright (C) 2010, 2011 Free Software Foundation, Inc. // Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -30,10 +30,16 @@ ...@@ -30,10 +30,16 @@
namespace std _GLIBCXX_VISIBILITY(default) namespace std _GLIBCXX_VISIBILITY(default)
{ {
namespace __regex namespace __detail
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @addtogroup regex-detail
* @{
*/
/// Base class for scanner.
struct _Scanner_base struct _Scanner_base
{ {
typedef unsigned int _StateT; typedef unsigned int _StateT;
...@@ -45,16 +51,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -45,16 +51,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
virtual ~_Scanner_base() { }; virtual ~_Scanner_base() { };
}; };
// /**
// @brief Scans an input range for regex tokens. * @brief struct _Scanner. Scans an input range for regex tokens.
// *
// The %_Scanner class interprets the regular expression pattern in the input * The %_Scanner class interprets the regular expression pattern in
// range passed to its constructor as a sequence of parse tokens passed to * the input range passed to its constructor as a sequence of parse
// the regular expression compiler. The sequence of tokens provided depends * tokens passed to the regular expression compiler. The sequence
// on the flag settings passed to the constructor: different regular * of tokens provided depends on the flag settings passed to the
// expression grammars will interpret the same input pattern in * constructor: different regular expression grammars will interpret
// syntactically different ways. * the same input pattern in syntactically different ways.
// */
template<typename _InputIterator> template<typename _InputIterator>
class _Scanner: public _Scanner_base class _Scanner: public _Scanner_base
{ {
...@@ -65,7 +71,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -65,7 +71,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef regex_constants::syntax_option_type _FlagT; typedef regex_constants::syntax_option_type _FlagT;
typedef const std::ctype<_CharT> _CtypeT; typedef const std::ctype<_CharT> _CtypeT;
// Token types returned from the scanner. /// Token types returned from the scanner.
enum _TokenT enum _TokenT
{ {
_S_token_anychar, _S_token_anychar,
...@@ -99,7 +105,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -99,7 +105,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_S_token_unknown _S_token_unknown
}; };
public:
_Scanner(_IteratorT __begin, _IteratorT __end, _FlagT __flags, _Scanner(_IteratorT __begin, _IteratorT __end, _FlagT __flags,
std::locale __loc) std::locale __loc)
: _M_current(__begin) , _M_end(__end) , _M_flags(__flags), : _M_current(__begin) , _M_end(__end) , _M_flags(__flags),
...@@ -141,7 +146,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -141,7 +146,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
void void
_M_eat_collsymbol(); _M_eat_collsymbol();
private:
_IteratorT _M_current; _IteratorT _M_current;
_IteratorT _M_end; _IteratorT _M_end;
_FlagT _M_flags; _FlagT _M_flags;
...@@ -625,7 +629,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -625,7 +629,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
#endif #endif
// Builds an NFA from an input iterator interval. /// Builds an NFA from an input iterator interval.
template<typename _InIter, typename _TraitsT> template<typename _InIter, typename _TraitsT>
class _Compiler class _Compiler
{ {
...@@ -635,7 +639,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -635,7 +639,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef std::basic_string<_CharT> _StringT; typedef std::basic_string<_CharT> _StringT;
typedef regex_constants::syntax_option_type _FlagT; typedef regex_constants::syntax_option_type _FlagT;
public:
_Compiler(const _InIter& __b, const _InIter& __e, _Compiler(const _InIter& __b, const _InIter& __e,
_TraitsT& __traits, _FlagT __flags); _TraitsT& __traits, _FlagT __flags);
...@@ -704,7 +707,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -704,7 +707,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
int int
_M_cur_int_value(int __radix); _M_cur_int_value(int __radix);
private:
_TraitsT& _M_traits; _TraitsT& _M_traits;
_ScannerT _M_scanner; _ScannerT _M_scanner;
_StringT _M_cur_value; _StringT _M_cur_value;
...@@ -1102,8 +1104,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1102,8 +1104,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return _AutomatonPtr(new _Nfa(_Compiler<_InIter, _TraitsT>(__b, __e, __t, { return _AutomatonPtr(new _Nfa(_Compiler<_InIter, _TraitsT>(__b, __e, __t,
__f)._M_nfa())); } __f)._M_nfa())); }
//@} regex-detail
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
} // namespace __regex } // namespace __detail
} // namespace std } // namespace std
/* vim: set ts=8 sw=2 sts=2: */
// class template regex -*- C++ -*- // class template regex -*- C++ -*-
// Copyright (C) 2010, 2011 Free Software Foundation, Inc. // Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -33,6 +33,13 @@ ...@@ -33,6 +33,13 @@
namespace std _GLIBCXX_VISIBILITY(default) namespace std _GLIBCXX_VISIBILITY(default)
{ {
/** /**
* @defgroup regex Regular Expressions
*
* A facility for performing regular expression pattern matching.
* @{
*/
/**
* @namespace std::regex_constants * @namespace std::regex_constants
* @brief ISO C++-0x entities sub namespace for regex. * @brief ISO C++-0x entities sub namespace for regex.
*/ */
...@@ -76,14 +83,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -76,14 +83,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* Specifies that the matching of regular expressions against a character * Specifies that the matching of regular expressions against a character
* sequence shall be performed without regard to case. * sequence shall be performed without regard to case.
*/ */
static constexpr syntax_option_type icase = 1 << _S_icase; constexpr syntax_option_type icase = 1 << _S_icase;
/** /**
* Specifies that when a regular expression is matched against a character * Specifies that when a regular expression is matched against a character
* container sequence, no sub-expression matches are to be stored in the * container sequence, no sub-expression matches are to be stored in the
* supplied match_results structure. * supplied match_results structure.
*/ */
static constexpr syntax_option_type nosubs = 1 << _S_nosubs; constexpr syntax_option_type nosubs = 1 << _S_nosubs;
/** /**
* Specifies that the regular expression engine should pay more attention to * Specifies that the regular expression engine should pay more attention to
...@@ -91,13 +98,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -91,13 +98,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* speed with which regular expression objects are constructed. Otherwise * speed with which regular expression objects are constructed. Otherwise
* it has no detectable effect on the program output. * it has no detectable effect on the program output.
*/ */
static constexpr syntax_option_type optimize = 1 << _S_optimize; constexpr syntax_option_type optimize = 1 << _S_optimize;
/** /**
* Specifies that character ranges of the form [a-b] should be locale * Specifies that character ranges of the form [a-b] should be locale
* sensitive. * sensitive.
*/ */
static constexpr syntax_option_type collate = 1 << _S_collate; constexpr syntax_option_type collate = 1 << _S_collate;
/** /**
* Specifies that the grammar recognized by the regular expression engine is * Specifies that the grammar recognized by the regular expression engine is
...@@ -107,7 +114,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -107,7 +114,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* in the PERL scripting language but extended with elements found in the * in the PERL scripting language but extended with elements found in the
* POSIX regular expression grammar. * POSIX regular expression grammar.
*/ */
static constexpr syntax_option_type ECMAScript = 1 << _S_ECMAScript; constexpr syntax_option_type ECMAScript = 1 << _S_ECMAScript;
/** /**
* Specifies that the grammar recognized by the regular expression engine is * Specifies that the grammar recognized by the regular expression engine is
...@@ -116,7 +123,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -116,7 +123,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* Headers, Section 9, Regular Expressions [IEEE, Information Technology -- * Headers, Section 9, Regular Expressions [IEEE, Information Technology --
* Portable Operating System Interface (POSIX), IEEE Standard 1003.1-2001]. * Portable Operating System Interface (POSIX), IEEE Standard 1003.1-2001].
*/ */
static constexpr syntax_option_type basic = 1 << _S_basic; constexpr syntax_option_type basic = 1 << _S_basic;
/** /**
* Specifies that the grammar recognized by the regular expression engine is * Specifies that the grammar recognized by the regular expression engine is
...@@ -124,7 +131,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -124,7 +131,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* Portable Operating System Interface (POSIX), Base Definitions and Headers, * Portable Operating System Interface (POSIX), Base Definitions and Headers,
* Section 9, Regular Expressions. * Section 9, Regular Expressions.
*/ */
static constexpr syntax_option_type extended = 1 << _S_extended; constexpr syntax_option_type extended = 1 << _S_extended;
/** /**
* Specifies that the grammar recognized by the regular expression engine is * Specifies that the grammar recognized by the regular expression engine is
...@@ -134,7 +141,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -134,7 +141,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* \\\\, \\a, \\b, \\f, \\n, \\r, \\t , \\v, \\&apos;, &apos;, * \\\\, \\a, \\b, \\f, \\n, \\r, \\t , \\v, \\&apos;, &apos;,
* and \\ddd (where ddd is one, two, or three octal digits). * and \\ddd (where ddd is one, two, or three octal digits).
*/ */
static constexpr syntax_option_type awk = 1 << _S_awk; constexpr syntax_option_type awk = 1 << _S_awk;
/** /**
* Specifies that the grammar recognized by the regular expression engine is * Specifies that the grammar recognized by the regular expression engine is
...@@ -142,7 +149,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -142,7 +149,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* identical to syntax_option_type basic, except that newlines are treated * identical to syntax_option_type basic, except that newlines are treated
* as whitespace. * as whitespace.
*/ */
static constexpr syntax_option_type grep = 1 << _S_grep; constexpr syntax_option_type grep = 1 << _S_grep;
/** /**
* Specifies that the grammar recognized by the regular expression engine is * Specifies that the grammar recognized by the regular expression engine is
...@@ -150,7 +157,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -150,7 +157,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* IEEE Std 1003.1-2001. This option is identical to syntax_option_type * IEEE Std 1003.1-2001. This option is identical to syntax_option_type
* extended, except that newlines are treated as whitespace. * extended, except that newlines are treated as whitespace.
*/ */
static constexpr syntax_option_type egrep = 1 << _S_egrep; constexpr syntax_option_type egrep = 1 << _S_egrep;
//@} //@}
...@@ -193,56 +200,56 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -193,56 +200,56 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/** /**
* The default matching rules. * The default matching rules.
*/ */
static constexpr match_flag_type match_default = 0; constexpr match_flag_type match_default = 0;
/** /**
* The first character in the sequence [first, last) is treated as though it * The first character in the sequence [first, last) is treated as though it
* is not at the beginning of a line, so the character (^) in the regular * is not at the beginning of a line, so the character (^) in the regular
* expression shall not match [first, first). * expression shall not match [first, first).
*/ */
static constexpr match_flag_type match_not_bol = 1 << _S_not_bol; constexpr match_flag_type match_not_bol = 1 << _S_not_bol;
/** /**
* The last character in the sequence [first, last) is treated as though it * The last character in the sequence [first, last) is treated as though it
* is not at the end of a line, so the character ($) in the regular * is not at the end of a line, so the character ($) in the regular
* expression shall not match [last, last). * expression shall not match [last, last).
*/ */
static constexpr match_flag_type match_not_eol = 1 << _S_not_eol; constexpr match_flag_type match_not_eol = 1 << _S_not_eol;
/** /**
* The expression \\b is not matched against the sub-sequence * The expression \\b is not matched against the sub-sequence
* [first,first). * [first,first).
*/ */
static constexpr match_flag_type match_not_bow = 1 << _S_not_bow; constexpr match_flag_type match_not_bow = 1 << _S_not_bow;
/** /**
* The expression \\b should not be matched against the sub-sequence * The expression \\b should not be matched against the sub-sequence
* [last,last). * [last,last).
*/ */
static constexpr match_flag_type match_not_eow = 1 << _S_not_eow; constexpr match_flag_type match_not_eow = 1 << _S_not_eow;
/** /**
* If more than one match is possible then any match is an acceptable * If more than one match is possible then any match is an acceptable
* result. * result.
*/ */
static constexpr match_flag_type match_any = 1 << _S_any; constexpr match_flag_type match_any = 1 << _S_any;
/** /**
* The expression does not match an empty sequence. * The expression does not match an empty sequence.
*/ */
static constexpr match_flag_type match_not_null = 1 << _S_not_null; constexpr match_flag_type match_not_null = 1 << _S_not_null;
/** /**
* The expression only matches a sub-sequence that begins at first . * The expression only matches a sub-sequence that begins at first .
*/ */
static constexpr match_flag_type match_continuous = 1 << _S_continuous; constexpr match_flag_type match_continuous = 1 << _S_continuous;
/** /**
* --first is a valid iterator position. When this flag is set then the * --first is a valid iterator position. When this flag is set then the
* flags match_not_bol and match_not_bow are ignored by the regular * flags match_not_bol and match_not_bow are ignored by the regular
* expression algorithms 28.11 and iterators 28.12. * expression algorithms 28.11 and iterators 28.12.
*/ */
static constexpr match_flag_type match_prev_avail = 1 << _S_prev_avail; constexpr match_flag_type match_prev_avail = 1 << _S_prev_avail;
/** /**
* When a regular expression match is to be replaced by a new string, the * When a regular expression match is to be replaced by a new string, the
...@@ -270,7 +277,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -270,7 +277,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* undefined, use the empty string instead. If * undefined, use the empty string instead. If
* nn > match_results::size(), the result is implementation-defined. * nn > match_results::size(), the result is implementation-defined.
*/ */
static constexpr match_flag_type format_default = 0; constexpr match_flag_type format_default = 0;
/** /**
* When a regular expression match is to be replaced by a new string, the * When a regular expression match is to be replaced by a new string, the
...@@ -278,24 +285,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -278,24 +285,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* in IEEE Std 1003.1- 2001 [IEEE, Information Technology -- Portable * in IEEE Std 1003.1- 2001 [IEEE, Information Technology -- Portable
* Operating System Interface (POSIX), IEEE Standard 1003.1-2001]. * Operating System Interface (POSIX), IEEE Standard 1003.1-2001].
*/ */
static constexpr match_flag_type format_sed = 1 << _S_sed; constexpr match_flag_type format_sed = 1 << _S_sed;
/** /**
* During a search and replace operation, sections of the character * During a search and replace operation, sections of the character
* container sequence being searched that do not match the regular * container sequence being searched that do not match the regular
* expression shall not be copied to the output string. * expression shall not be copied to the output string.
*/ */
static constexpr match_flag_type format_no_copy = 1 << _S_no_copy; constexpr match_flag_type format_no_copy = 1 << _S_no_copy;
/** /**
* When specified during a search and replace operation, only the first * When specified during a search and replace operation, only the first
* occurrence of the regular expression shall be replaced. * occurrence of the regular expression shall be replaced.
*/ */
static constexpr match_flag_type format_first_only = 1 << _S_first_only; constexpr match_flag_type format_first_only = 1 << _S_first_only;
//@} //@}
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
} // namespace regex_constants } // namespace regex_constants
} // namespace
/* @} */ // group regex
} // namespace std
// class template regex -*- C++ -*- // class template regex -*- C++ -*-
// Copyright (C) 2010, 2011 Free Software Foundation, Inc. // Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -30,11 +30,17 @@ ...@@ -30,11 +30,17 @@
namespace std _GLIBCXX_VISIBILITY(default) namespace std _GLIBCXX_VISIBILITY(default)
{ {
namespace __regex namespace __detail
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
// ABC for pattern matching /**
* @defgroup regex-detail Base and Implementation Classes
* @ingroup regex
* @{
*/
/// ABC for pattern matching
struct _PatternCursor struct _PatternCursor
{ {
virtual ~_PatternCursor() { }; virtual ~_PatternCursor() { };
...@@ -42,7 +48,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -42,7 +48,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
virtual bool _M_at_end() const = 0; virtual bool _M_at_end() const = 0;
}; };
// Provides a cursor into the specific target string. /// Provides a cursor into the specific target string.
template<typename _FwdIterT> template<typename _FwdIterT>
class _SpecializedCursor class _SpecializedCursor
: public _PatternCursor : public _PatternCursor
...@@ -88,6 +94,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -88,6 +94,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__cursor(const _FwdIterT& __b, const _FwdIterT __e) __cursor(const _FwdIterT& __b, const _FwdIterT __e)
{ return _SpecializedCursor<_FwdIterT>(__b, __e); } { return _SpecializedCursor<_FwdIterT>(__b, __e); }
//@} regex-detail
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
} // namespace __regex } // namespace __detail
} // namespace } // namespace
// class template regex -*- C++ -*- // class template regex -*- C++ -*-
// Copyright (C) 2010, 2011 Free Software Foundation, Inc. // Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -32,6 +32,11 @@ ...@@ -32,6 +32,11 @@
namespace std _GLIBCXX_VISIBILITY(default) namespace std _GLIBCXX_VISIBILITY(default)
{ {
/**
* @addtogroup regex
* @{
*/
namespace regex_constants namespace regex_constants
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
...@@ -60,60 +65,60 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -60,60 +65,60 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}; };
/** The expression contained an invalid collating element name. */ /** The expression contained an invalid collating element name. */
static constexpr error_type error_collate(_S_error_collate); constexpr error_type error_collate(_S_error_collate);
/** The expression contained an invalid character class name. */ /** The expression contained an invalid character class name. */
static constexpr error_type error_ctype(_S_error_ctype); constexpr error_type error_ctype(_S_error_ctype);
/** /**
* The expression contained an invalid escaped character, or a trailing * The expression contained an invalid escaped character, or a trailing
* escape. * escape.
*/ */
static constexpr error_type error_escape(_S_error_escape); constexpr error_type error_escape(_S_error_escape);
/** The expression contained an invalid back reference. */ /** The expression contained an invalid back reference. */
static constexpr error_type error_backref(_S_error_backref); constexpr error_type error_backref(_S_error_backref);
/** The expression contained mismatched [ and ]. */ /** The expression contained mismatched [ and ]. */
static constexpr error_type error_brack(_S_error_brack); constexpr error_type error_brack(_S_error_brack);
/** The expression contained mismatched ( and ). */ /** The expression contained mismatched ( and ). */
static constexpr error_type error_paren(_S_error_paren); constexpr error_type error_paren(_S_error_paren);
/** The expression contained mismatched { and } */ /** The expression contained mismatched { and } */
static constexpr error_type error_brace(_S_error_brace); constexpr error_type error_brace(_S_error_brace);
/** The expression contained an invalid range in a {} expression. */ /** The expression contained an invalid range in a {} expression. */
static constexpr error_type error_badbrace(_S_error_badbrace); constexpr error_type error_badbrace(_S_error_badbrace);
/** /**
* The expression contained an invalid character range, * The expression contained an invalid character range,
* such as [b-a] in most encodings. * such as [b-a] in most encodings.
*/ */
static constexpr error_type error_range(_S_error_range); constexpr error_type error_range(_S_error_range);
/** /**
* There was insufficient memory to convert the expression into a * There was insufficient memory to convert the expression into a
* finite state machine. * finite state machine.
*/ */
static constexpr error_type error_space(_S_error_space); constexpr error_type error_space(_S_error_space);
/** /**
* One of <em>*?+{</em> was not preceded by a valid regular expression. * One of <em>*?+{</em> was not preceded by a valid regular expression.
*/ */
static constexpr error_type error_badrepeat(_S_error_badrepeat); constexpr error_type error_badrepeat(_S_error_badrepeat);
/** /**
* The complexity of an attempted match against a regular expression * The complexity of an attempted match against a regular expression
* exceeded a pre-set level. * exceeded a pre-set level.
*/ */
static constexpr error_type error_complexity(_S_error_complexity); constexpr error_type error_complexity(_S_error_complexity);
/** /**
* There was insufficient memory to determine whether the * There was insufficient memory to determine whether the
* regular expression could match the specified character sequence. * regular expression could match the specified character sequence.
*/ */
static constexpr error_type error_stack(_S_error_stack); constexpr error_type error_stack(_S_error_stack);
//@} //@}
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
...@@ -153,6 +158,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -153,6 +158,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return _M_code; } { return _M_code; }
}; };
//@} // group regex
void void
__throw_regex_error(regex_constants::error_type __ecode); __throw_regex_error(regex_constants::error_type __ecode);
......
// class template regex -*- C++ -*- // class template regex -*- C++ -*-
// Copyright (C) 2010, 2011 Free Software Foundation, Inc. // Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -40,11 +40,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -40,11 +40,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
namespace __regex namespace __detail
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
// A _Results facade specialized for wrapping a templated match_results. /**
* @defgroup regex-detail Base and Implementation Classes
* @ingroup regex
* @{
*/
/// A _Results facade specialized for wrapping a templated match_results.
template<typename _FwdIterT, typename _Alloc> template<typename _FwdIterT, typename _Alloc>
class _SpecializedResults class _SpecializedResults
: public _Results : public _Results
...@@ -95,12 +101,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -95,12 +101,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_results.at(__i).second = __c._M_pos()+1; _M_results.at(__i).second = __c._M_pos()+1;
} }
// A stack of states used in evaluating the NFA. /// A stack of states used in evaluating the NFA.
typedef std::stack<_StateIdT, std::vector<_StateIdT> > _StateStack; typedef std::stack<_StateIdT, std::vector<_StateIdT> > _StateStack;
// Executes a regular expression NFA/DFA over a range using a variant of /// Executes a regular expression NFA/DFA over a range using a
// the parallel execution algorithm featured in the grep utility, modified /// variant of the parallel execution algorithm featured in the grep
// to use Laurikari tags. /// utility, modified to use Laurikari tags.
class _Grep_matcher class _Grep_matcher
{ {
public: public:
...@@ -119,14 +125,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -119,14 +125,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_StateSet _StateSet
_M_e_closure(_StateStack& __stack, const _StateSet& __s); _M_e_closure(_StateStack& __stack, const _StateSet& __s);
private:
const std::shared_ptr<_Nfa> _M_nfa; const std::shared_ptr<_Nfa> _M_nfa;
_PatternCursor& _M_pattern; _PatternCursor& _M_pattern;
_Results& _M_results; _Results& _M_results;
}; };
//@} regex-detail
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
} // namespace __regex } // namespace __detail
} // namespace } // namespace std
#include <bits/regex_grep_matcher.tcc> #include <bits/regex_grep_matcher.tcc>
// class template regex -*- C++ -*- // class template regex -*- C++ -*-
// Copyright (C) 2010 Free Software Foundation, Inc. // Copyright (C) 2010, 2012 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -35,26 +35,26 @@ namespace std _GLIBCXX_VISIBILITY(default) ...@@ -35,26 +35,26 @@ namespace std _GLIBCXX_VISIBILITY(default)
namespace namespace
{ {
// A stack of states used in evaluating the NFA. // A stack of states used in evaluating the NFA.
typedef std::stack<std::__regex::_StateIdT, typedef std::stack<std::__detail::_StateIdT,
std::vector<std::__regex::_StateIdT> std::vector<std::__detail::_StateIdT>
> _StateStack; > _StateStack;
// Obtains the next state set given the current state set __s and the current // Obtains the next state set given the current state set __s and the current
// input character. // input character.
inline std::__regex::_StateSet inline std::__detail::_StateSet
__move(const std::__regex::_PatternCursor& __p, __move(const std::__detail::_PatternCursor& __p,
const std::__regex::_Nfa& __nfa, const std::__detail::_Nfa& __nfa,
const std::__regex::_StateSet& __s) const std::__detail::_StateSet& __s)
{ {
std::__regex::_StateSet __m; std::__detail::_StateSet __m;
for (std::__regex::_StateSet::const_iterator __i = __s.begin(); for (std::__detail::_StateSet::const_iterator __i = __s.begin();
__i != __s.end(); ++__i) __i != __s.end(); ++__i)
{ {
if (*__i == std::__regex::_S_invalid_state_id) if (*__i == std::__detail::_S_invalid_state_id)
continue; continue;
const std::__regex::_State& __state = __nfa[*__i]; const std::__detail::_State& __state = __nfa[*__i];
if (__state._M_opcode == std::__regex::_S_opcode_match if (__state._M_opcode == std::__detail::_S_opcode_match
&& __state._M_matches(__p)) && __state._M_matches(__p))
__m.insert(__state._M_next); __m.insert(__state._M_next);
} }
...@@ -63,13 +63,13 @@ namespace ...@@ -63,13 +63,13 @@ namespace
// returns true if (__s intersect __t) is not empty // returns true if (__s intersect __t) is not empty
inline bool inline bool
__includes_some(const std::__regex::_StateSet& __s, __includes_some(const std::__detail::_StateSet& __s,
const std::__regex::_StateSet& __t) const std::__detail::_StateSet& __t)
{ {
if (__s.size() > 0 && __t.size() > 0) if (__s.size() > 0 && __t.size() > 0)
{ {
std::__regex::_StateSet::const_iterator __first = __s.begin(); std::__detail::_StateSet::const_iterator __first = __s.begin();
std::__regex::_StateSet::const_iterator __second = __t.begin(); std::__detail::_StateSet::const_iterator __second = __t.begin();
while (__first != __s.end() && __second != __t.end()) while (__first != __s.end() && __second != __t.end())
{ {
if (*__first < *__second) if (*__first < *__second)
...@@ -86,9 +86,9 @@ namespace ...@@ -86,9 +86,9 @@ namespace
// If an identified state __u is not already in the current state set __e, // If an identified state __u is not already in the current state set __e,
// insert it and push it on the current state stack __s. // insert it and push it on the current state stack __s.
inline void inline void
__add_visited_state(const std::__regex::_StateIdT __u, __add_visited_state(const std::__detail::_StateIdT __u,
_StateStack& __s, _StateStack& __s,
std::__regex::_StateSet& __e) std::__detail::_StateSet& __e)
{ {
if (__e.count(__u) == 0) if (__e.count(__u) == 0)
{ {
...@@ -99,7 +99,7 @@ namespace ...@@ -99,7 +99,7 @@ namespace
} // anonymous namespace } // anonymous namespace
namespace __regex namespace __detail
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
...@@ -109,7 +109,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -109,7 +109,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
regex_constants::match_flag_type __flags) regex_constants::match_flag_type __flags)
: _M_nfa(static_pointer_cast<_Nfa>(__nfa)), _M_pattern(__p), _M_results(__r) : _M_nfa(static_pointer_cast<_Nfa>(__nfa)), _M_pattern(__p), _M_results(__r)
{ {
__regex::_StateSet __t = this->_M_e_closure(_M_nfa->_M_start()); __detail::_StateSet __t = this->_M_e_closure(_M_nfa->_M_start());
for (; !_M_pattern._M_at_end(); _M_pattern._M_next()) for (; !_M_pattern._M_at_end(); _M_pattern._M_next())
__t = this->_M_e_closure(__move(_M_pattern, *_M_nfa, __t)); __t = this->_M_e_closure(__move(_M_pattern, *_M_nfa, __t));
...@@ -175,5 +175,5 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -175,5 +175,5 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
} // namespace __regex } // namespace __detail
} // namespace } // namespace
// class template regex -*- C++ -*- // class template regex -*- C++ -*-
// Copyright (C) 2010, 2011 Free Software Foundation, Inc. // Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -30,11 +30,16 @@ ...@@ -30,11 +30,16 @@
namespace std _GLIBCXX_VISIBILITY(default) namespace std _GLIBCXX_VISIBILITY(default)
{ {
namespace __regex namespace __detail
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Base class for, um, automata. Could be an NFA or a DFA. Your choice. /**
* @addtogroup regex-detail
* @{
*/
/// Base class for, um, automata. Could be an NFA or a DFA. Your choice.
class _Automaton class _Automaton
{ {
public: public:
...@@ -53,11 +58,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -53,11 +58,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif #endif
}; };
// Generic shared pointer to an automaton. /// Generic shared pointer to an automaton.
typedef std::shared_ptr<_Automaton> _AutomatonPtr; typedef std::shared_ptr<_Automaton> _AutomatonPtr;
// Operation codes that define the type of transitions within the base NFA /// Operation codes that define the type of transitions within the base NFA
// that represents the regular expression. /// that represents the regular expression.
enum _Opcode enum _Opcode
{ {
_S_opcode_unknown = 0, _S_opcode_unknown = 0,
...@@ -68,16 +73,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -68,16 +73,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_S_opcode_accept = 255 _S_opcode_accept = 255
}; };
// Provides a generic facade for a templated match_results. /// Provides a generic facade for a templated match_results.
struct _Results struct _Results
{ {
virtual void _M_set_pos(int __i, int __j, const _PatternCursor& __p) = 0; virtual void _M_set_pos(int __i, int __j, const _PatternCursor& __p) = 0;
virtual void _M_set_matched(int __i, bool __is_matched) = 0; virtual void _M_set_matched(int __i, bool __is_matched) = 0;
}; };
// Tags current state (for subexpr begin/end). /// Tags current state (for subexpr begin/end).
typedef std::function<void (const _PatternCursor&, _Results&)> _Tagger; typedef std::function<void (const _PatternCursor&, _Results&)> _Tagger;
/// Start state tag.
template<typename _FwdIterT, typename _TraitsT> template<typename _FwdIterT, typename _TraitsT>
struct _StartTagger struct _StartTagger
{ {
...@@ -93,6 +99,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -93,6 +99,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
int _M_index; int _M_index;
}; };
/// End state tag.
template<typename _FwdIterT, typename _TraitsT> template<typename _FwdIterT, typename _TraitsT>
struct _EndTagger struct _EndTagger
{ {
...@@ -108,15 +115,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -108,15 +115,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
int _M_index; int _M_index;
_FwdIterT _M_pos; _FwdIterT _M_pos;
}; };
// Indicates if current state matches cursor current.
/// Indicates if current state matches cursor current.
typedef std::function<bool (const _PatternCursor&)> _Matcher; typedef std::function<bool (const _PatternCursor&)> _Matcher;
// Matches any character /// Matches any character
inline bool inline bool
_AnyMatcher(const _PatternCursor&) _AnyMatcher(const _PatternCursor&)
{ return true; } { return true; }
// Matches a single character /// Matches a single character
template<typename _InIterT, typename _TraitsT> template<typename _InIterT, typename _TraitsT>
struct _CharMatcher struct _CharMatcher
{ {
...@@ -139,7 +147,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -139,7 +147,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
char_type _M_c; char_type _M_c;
}; };
// Matches a character range (bracket expression) /// Matches a character range (bracket expression)
template<typename _InIterT, typename _TraitsT> template<typename _InIterT, typename _TraitsT>
struct _RangeMatcher struct _RangeMatcher
{ {
...@@ -183,20 +191,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -183,20 +191,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
bool _M_is_non_matching; bool _M_is_non_matching;
}; };
// Identifies a state in the NFA. /// Identifies a state in the NFA.
typedef int _StateIdT; typedef int _StateIdT;
// The special case in which a state identifier is not an index. /// The special case in which a state identifier is not an index.
static const _StateIdT _S_invalid_state_id = -1; static const _StateIdT _S_invalid_state_id = -1;
// An individual state in an NFA /**
// * @brief struct _State
// In this case a "state" is an entry in the NFA definition coupled with its *
// outgoing transition(s). All states have a single outgoing transition, * An individual state in an NFA
// except for accepting states (which have no outgoing transitions) and alt *
// states, which have two outgoing transitions. * In this case a "state" is an entry in the NFA definition coupled
// * with its outgoing transition(s). All states have a single outgoing
* transition, except for accepting states (which have no outgoing
* transitions) and alt states, which have two outgoing transitions.
*/
struct _State struct _State
{ {
typedef int _OpcodeT; typedef int _OpcodeT;
...@@ -236,22 +247,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -236,22 +247,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}; };
// The Grep Matcher works on sets of states. Here are sets of states. /// The Grep Matcher works on sets of states. Here are sets of states.
typedef std::set<_StateIdT> _StateSet; typedef std::set<_StateIdT> _StateSet;
// A collection of all states making up an NFA /**
// * @brief struct _Nfa
// An NFA is a 4-tuple M = (K, S, s, F), where *
// K is a finite set of states, * A collection of all states making up an NFA.
// S is the alphabet of the NFA, *
// s is the initial state, * An NFA is a 4-tuple M = (K, S, s, F), where
// F is a set of final (accepting) states. * K is a finite set of states,
// * S is the alphabet of the NFA,
// This NFA class is templated on S, a type that will hold values of the * s is the initial state,
// underlying alphabet (without regard to semantics of that alphabet). The * F is a set of final (accepting) states.
// other elements of the tuple are generated during construction of the NFA *
// and are available through accessor member functions. * This NFA class is templated on S, a type that will hold values of the
// * underlying alphabet (without regard to semantics of that alphabet). The
* other elements of the tuple are generated during construction of the NFA
* and are available through accessor member functions.
*/
class _Nfa class _Nfa
: public _Automaton, public std::vector<_State> : public _Automaton, public std::vector<_State>
{ {
...@@ -260,7 +274,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -260,7 +274,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef unsigned int _SizeT; typedef unsigned int _SizeT;
typedef regex_constants::syntax_option_type _FlagT; typedef regex_constants::syntax_option_type _FlagT;
public:
_Nfa(_FlagT __f) _Nfa(_FlagT __f)
: _M_flags(__f), _M_start_state(0), _M_subexpr_count(0) : _M_flags(__f), _M_start_state(0), _M_subexpr_count(0)
{ } { }
...@@ -309,7 +322,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -309,7 +322,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_StateIdT _StateIdT
_M_insert_subexpr_begin(const _Tagger& __t) _M_insert_subexpr_begin(const _Tagger& __t)
{ {
this->push_back(_StateT(_S_opcode_subexpr_begin, _M_subexpr_count++, __t)); this->push_back(_StateT(_S_opcode_subexpr_begin, _M_subexpr_count++,
__t));
return this->size()-1; return this->size()-1;
} }
...@@ -332,9 +346,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -332,9 +346,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_SizeT _M_subexpr_count; _SizeT _M_subexpr_count;
}; };
// Describes a sequence of one or more %_State, its current start and end(s). /// Describes a sequence of one or more %_State, its current start
// /// and end(s). This structure contains fragments of an NFA during
// This structure contains fragments of an NFA during construction. /// construction.
class _StateSeq class _StateSeq
{ {
public: public:
...@@ -392,8 +406,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -392,8 +406,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}; };
//@} regex-detail
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
} // namespace __regex } // namespace __detail
} // namespace std } // namespace std
#include <bits/regex_nfa.tcc> #include <bits/regex_nfa.tcc>
......
// class template regex -*- C++ -*- // class template regex -*- C++ -*-
// Copyright (C) 2010, 2011 Free Software Foundation, Inc. // Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
namespace std _GLIBCXX_VISIBILITY(default) namespace std _GLIBCXX_VISIBILITY(default)
{ {
namespace __regex namespace __detail
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
...@@ -170,5 +170,5 @@ _M_clone() ...@@ -170,5 +170,5 @@ _M_clone()
{ return 0; } { return 0; }
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
} // namespace __regex } // namespace __detail
} // namespace } // namespace
...@@ -25,4 +25,4 @@ ...@@ -25,4 +25,4 @@
#include <vector> #include <vector>
// { dg-error "multiple inlined namespaces" "" { target *-*-* } 263 } // { dg-error "multiple inlined namespaces" "" { target *-*-* } 262 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment