1 ///////////////////////////////////////////////////////////////////////////////
2 // assert_bol_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_BOL_MATCHER_HPP_EAN_10_04_2005
9 #define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_ASSERT_BOL_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_bol_matcher
30 : assert_line_base<Traits>
32 typedef typename Traits::char_type char_type;
34 assert_bol_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_bol_)
51 char_type ch = *boost::prior(state.cur_);
53 // If the previous character is not a newline, we're not at the start 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->cr_ && !state.eos() && *state.cur_ == this->nl_)
65 return next.match(state);