Index: basic_regex.hpp =================================================================== --- basic_regex.hpp (révision 48432) +++ basic_regex.hpp (copie de travail) @@ -148,6 +148,48 @@ { return this->m_mark_count; } + std::pair BOOST_REGEX_CALL get_mark(size_type index)const + { + std::pair mark(0,0) ; + + if(!mark_count() && index < mark_count()) + return mark ; + + mark.first = mark.second = this->m_expression ; + + if(index == 0) + { + std::advance(mark.second, this->m_expression_len) ; + return mark ; + } + + ::boost::re_detail::re_syntax_base const * state = get_first_state() ; + ::boost::re_detail::re_brace const * state_brace = 0 ; + + do + { + if(state->type != ::boost::re_detail::syntax_element_startmark + && state->type != ::boost::re_detail::syntax_element_endmark) + continue ; + + state_brace = static_cast(state) ; + if(state_brace->index != (int) index) + continue ; + + if(state_brace->type == ::boost::re_detail::syntax_element_startmark) + std::advance(mark.first, state_brace->position) ; + else if(state_brace->type == ::boost::re_detail::syntax_element_endmark) + { + std::advance(mark.second, state_brace->position+1) ; + state = 0 ; + break ; + } + + } while((state = state->next.p)) ; + + return mark ; + } + const re_detail::re_syntax_base* get_first_state()const { return this->m_first_state; @@ -405,6 +447,11 @@ return (m_pimpl.get() ? m_pimpl->mark_count() : 0); } + std::pair BOOST_REGEX_CALL get_mark(size_type index)const + { + return (m_pimpl.get() ? m_pimpl->get_mark(index) : std::pair(0,0)); + } + int status()const { return (m_pimpl.get() ? m_pimpl->status() : regex_constants::error_empty); Index: basic_regex_parser.hpp =================================================================== --- basic_regex_parser.hpp (révision 48432) +++ basic_regex_parser.hpp (copie de travail) @@ -371,6 +371,7 @@ markid = ++m_mark_count; re_brace* pb = static_cast(this->append_state(syntax_element_startmark, sizeof(re_brace))); pb->index = markid; + pb->position = ::boost::re_detail::distance(m_base, m_position - 1) ; std::ptrdiff_t last_paren_start = this->getoffset(pb); // back up insertion point for alternations, and set new point: std::ptrdiff_t last_alt_point = m_alt_insert_point; @@ -421,6 +422,7 @@ // pb = static_cast(this->append_state(syntax_element_endmark, sizeof(re_brace))); pb->index = markid; + pb->position = ::boost::re_detail::distance(m_base, m_position-1) ; this->m_paren_start = last_paren_start; // // restore the alternate insertion point: @@ -1549,6 +1551,7 @@ m_position = pc; re_brace* pb = static_cast(this->append_state(syntax_element_backref, sizeof(re_brace))); pb->index = i; + pb->position = ::boost::re_detail::distance(m_base, m_position) ; } else { @@ -1786,6 +1789,7 @@ // make a note of whether we have a case change: m_has_case_change = ((opts & regbase::icase) != (this->flags() & regbase::icase)); pb->index = markid = 0; + pb->position = ::boost::re_detail::distance(m_base, m_position) ; if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_mark) { // update flags and carry on as normal: @@ -1896,6 +1900,7 @@ // pb = static_cast(this->append_state(syntax_element_endmark, sizeof(re_brace))); pb->index = markid; + pb->position = ::boost::re_detail::distance(m_base, m_position) ; this->m_paren_start = last_paren_start; // // restore the alternate insertion point: Index: states.hpp =================================================================== --- states.hpp (révision 48432) +++ states.hpp (copie de travail) @@ -156,6 +156,7 @@ // The index to match, can be zero (don't mark the sub-expression) // or negative (for perl style (?...) extentions): int index; + std::ptrdiff_t position ; }; /*** struct re_dot **************************************************