diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-11-24 20:33:19 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-11-24 20:35:17 (GMT) |
commit | 332d60c56dfaa11fdd135088279d15cd5983b3d4 (patch) | |
tree | dd77717a4e1732da929d5ff8a0471fa3f005e201 /3rdParty/Boost/src/boost/regex/v4/match_results.hpp | |
parent | 90c44a10fec26d2a0935b2d62e82b6a5be028373 (diff) | |
download | swift-contrib-332d60c56dfaa11fdd135088279d15cd5983b3d4.zip swift-contrib-332d60c56dfaa11fdd135088279d15cd5983b3d4.tar.bz2 |
Upgraded Boost to 1.45.0.
Diffstat (limited to '3rdParty/Boost/src/boost/regex/v4/match_results.hpp')
-rw-r--r-- | 3rdParty/Boost/src/boost/regex/v4/match_results.hpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/3rdParty/Boost/src/boost/regex/v4/match_results.hpp b/3rdParty/Boost/src/boost/regex/v4/match_results.hpp index cd6b9eb..ca9898f 100644 --- a/3rdParty/Boost/src/boost/regex/v4/match_results.hpp +++ b/3rdParty/Boost/src/boost/regex/v4/match_results.hpp @@ -38,7 +38,6 @@ namespace boost{ namespace re_detail{ -template <class charT> class named_subexpressions; } @@ -69,7 +68,7 @@ public: typedef typename re_detail::regex_iterator_traits< BidiIterator>::value_type char_type; typedef std::basic_string<char_type> string_type; - typedef re_detail::named_subexpressions_base<char_type> named_sub_type; + typedef re_detail::named_subexpressions named_sub_type; // construct/copy/destroy: explicit match_results(const Allocator& a = Allocator()) @@ -225,10 +224,15 @@ public: // const_reference named_subexpression(const char_type* i, const char_type* j) const { + // + // Scan for the leftmost *matched* subexpression with the specified named: + // if(m_is_singular) raise_logic_error(); - int index = m_named_subs->get_id(i, j); - return index > 0 ? (*this)[index] : m_null; + re_detail::named_subexpressions::range_type r = m_named_subs->equal_range(i, j); + while((r.first != r.second) && ((*this)[r.first->index].matched == false)) + ++r.first; + return r.first != r.second ? (*this)[r.first->index] : m_null; } template <class charT> const_reference named_subexpression(const charT* i, const charT* j) const @@ -243,10 +247,20 @@ public: } int named_subexpression_index(const char_type* i, const char_type* j) const { + // + // Scan for the leftmost *matched* subexpression with the specified named. + // If none found then return the leftmost expression with that name, + // otherwise an invalid index: + // if(m_is_singular) raise_logic_error(); - int index = m_named_subs->get_id(i, j); - return index > 0 ? index : -20; + re_detail::named_subexpressions::range_type s, r; + s = r = m_named_subs->equal_range(i, j); + while((r.first != r.second) && ((*this)[r.first->index].matched == false)) + ++r.first; + if(r.first == r.second) + r = s; + return r.first != r.second ? r.first->index : -20; } template <class charT> int named_subexpression_index(const charT* i, const charT* j) const @@ -393,7 +407,6 @@ public: std::swap(m_subs, that.m_subs); std::swap(m_named_subs, that.m_named_subs); std::swap(m_last_closed_paren, that.m_last_closed_paren); - std::swap(m_is_singular, that.m_is_singular); if(m_is_singular) { if(!that.m_is_singular) @@ -412,6 +425,7 @@ public: std::swap(m_base, that.m_base); std::swap(m_null, that.m_null); } + std::swap(m_is_singular, that.m_is_singular); } bool operator==(const match_results& that)const { @@ -457,7 +471,7 @@ public: void BOOST_REGEX_CALL set_second(BidiIterator i, size_type pos, bool m = true, bool escape_k = false) { if(pos) - m_last_closed_paren = pos; + m_last_closed_paren = static_cast<int>(pos); pos += 2; BOOST_ASSERT(m_subs.size() > pos); m_subs[pos].second = i; |