From 3b889db8d1f286e95f59b62978bac58bdd3bf94b Mon Sep 17 00:00:00 2001 From: Pavol Droba Date: Mon, 11 Apr 2005 07:39:34 +0000 Subject: [PATCH] Split iterator fixed. Now it returns also last empty match if appropriate [SVN r28096] --- .../boost/algorithm/string/find_iterator.hpp | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/include/boost/algorithm/string/find_iterator.hpp b/include/boost/algorithm/string/find_iterator.hpp index de92184..580f125 100644 --- a/include/boost/algorithm/string/find_iterator.hpp +++ b/include/boost/algorithm/string/find_iterator.hpp @@ -246,7 +246,9 @@ namespace boost { base_type(Other), m_Match(Other.m_Match), m_Next(Other.m_Next), - m_End(Other.m_End) {} + m_End(Other.m_End), + m_bEof(false) + {} //! Constructor /*! @@ -261,7 +263,8 @@ namespace boost { detail::find_iterator_base(Finder,0), m_Match(Begin,Begin), m_Next(Begin), - m_End(End) + m_End(End), + m_bEof(false) { increment(); } @@ -277,7 +280,8 @@ namespace boost { detail::find_iterator_base(Finder,0), m_Match(begin(Col),begin(Col)), m_Next(begin(Col)), - m_End(end(Col)) + m_End(end(Col)), + m_bEof(false) { increment(); } @@ -296,6 +300,16 @@ namespace boost { void increment() { match_type FindMatch=this->do_find( m_Next, m_End ); + + if(FindMatch.begin()==m_End && FindMatch.end()==m_End) + { + if(m_Match.end()==m_End) + { + // Mark iterator as eof + m_bEof=true; + } + } + m_Match=match_type( m_Next, FindMatch.begin() ); m_Next=FindMatch.end(); } @@ -310,7 +324,7 @@ namespace boost { ( m_Match==Other.m_Match && m_Next==Other.m_Next && - m_End==Other.m_End + m_End==Other.m_End ); } @@ -325,12 +339,7 @@ namespace boost { */ bool eof() const { - return - this->is_null() || - ( - m_Match.begin() == m_End && - m_Match.end() == m_End - ); + return this->is_null() || m_bEof; } private: @@ -338,6 +347,7 @@ namespace boost { match_type m_Match; input_iterator_type m_Next; input_iterator_type m_End; + bool m_bEof; }; //! split iterator construction helper