1 ///////////////////////////////////////////////////////////////////////////////
2 // logical_newline_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_LOGICAL_NEWLINE_MATCHER_HPP_EAN_10_04_2005
9 #define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_LOGICAL_NEWLINE_MATCHER_HPP_EAN_10_04_2005
11 // MS compatible compilers support #pragma once
16 #include <boost/xpressive/detail/detail_fwd.hpp>
17 #include <boost/xpressive/detail/core/quant_style.hpp>
18 #include <boost/xpressive/detail/core/state.hpp>
20 namespace boost { namespace xpressive { namespace detail
23 //////////////////////////////////////////////////////////////////////////
24 // logical_newline_matcher
26 template<typename Traits>
27 struct logical_newline_matcher
28 : quant_style_variable_width
30 typedef typename Traits::char_type char_type;
31 typedef typename Traits::char_class_type char_class_type;
33 logical_newline_matcher(Traits const &tr)
34 : newline_(lookup_classname(tr, "newline"))
40 template<typename BidiIter, typename Next>
41 bool match(match_state<BidiIter> &state, Next const &next) const
48 char_type ch = *state.cur_;
49 if(traits_cast<Traits>(state).isctype(ch, this->newline_))
52 if(this->cr_ == ch && !state.eos() && this->nl_ == *state.cur_)
61 else if(next.match(state))
71 char_class_type newline() const
73 return this->newline_;
77 char_class_type newline_;