1 ///////////////////////////////////////////////////////////////////////////////
2 // assert_eol_matcher.hpp
4 // Copyright 2008 Eric Niebler. Distributed under the Boost
5 // Software License, Version 1.0. (See accompanying file
6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 #ifndef BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_ASSERT_EOL_MATCHER_HPP_EAN_10_04_2005
9 #define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_ASSERT_EOL_MATCHER_HPP_EAN_10_04_2005
11 // MS compatible compilers support #pragma once
16 #include <boost/next_prior.hpp>
17 #include <boost/xpressive/detail/detail_fwd.hpp>
18 #include <boost/xpressive/detail/core/quant_style.hpp>
19 #include <boost/xpressive/detail/core/state.hpp>
20 #include <boost/xpressive/detail/core/matcher/assert_line_base.hpp>
22 namespace boost { namespace xpressive { namespace detail
25 ///////////////////////////////////////////////////////////////////////////////
28 template<typename Traits>
29 struct assert_eol_matcher
30 : assert_line_base<Traits>
32 typedef typename Traits::char_type char_type;
34 assert_eol_matcher(Traits const &tr)
35 : assert_line_base<Traits>(tr)
39 template<typename BidiIter, typename Next>
40 bool match(match_state<BidiIter> &state, Next const &next) const
44 if(!state.flags_.match_eol_)
51 char_type ch = *state.cur_;
53 // If the current character is not a newline, we're not at the end of a line
54 if(!traits_cast<Traits>(state).isctype(ch, this->newline_))
58 // There is no line-break between \r and \n
59 else if(ch == this->nl_ && (!state.bos() || state.flags_.match_prev_avail_) && *boost::prior(state.cur_) == this->cr_)
65 return next.match(state);