File indexing completed on 2025-01-18 09:53:48
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_LOGICAL_NEWLINE_MATCHER_HPP_EAN_10_04_2005
0009 #define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_LOGICAL_NEWLINE_MATCHER_HPP_EAN_10_04_2005
0010
0011
0012 #if defined(_MSC_VER)
0013 # pragma once
0014 #endif
0015
0016 #include <boost/xpressive/detail/detail_fwd.hpp>
0017 #include <boost/xpressive/detail/core/quant_style.hpp>
0018 #include <boost/xpressive/detail/core/state.hpp>
0019
0020 namespace boost { namespace xpressive { namespace detail
0021 {
0022
0023
0024
0025
0026 template<typename Traits>
0027 struct logical_newline_matcher
0028 : quant_style_variable_width
0029 {
0030 typedef typename Traits::char_type char_type;
0031 typedef typename Traits::char_class_type char_class_type;
0032
0033 logical_newline_matcher(Traits const &tr)
0034 : newline_(lookup_classname(tr, "newline"))
0035 , nl_(tr.widen('\n'))
0036 , cr_(tr.widen('\r'))
0037 {
0038 }
0039
0040 template<typename BidiIter, typename Next>
0041 bool match(match_state<BidiIter> &state, Next const &next) const
0042 {
0043 if(state.eos())
0044 {
0045 return false;
0046 }
0047
0048 char_type ch = *state.cur_;
0049 if(traits_cast<Traits>(state).isctype(ch, this->newline_))
0050 {
0051 ++state.cur_;
0052 if(this->cr_ == ch && !state.eos() && this->nl_ == *state.cur_)
0053 {
0054 ++state.cur_;
0055 if(next.match(state))
0056 {
0057 return true;
0058 }
0059 --state.cur_;
0060 }
0061 else if(next.match(state))
0062 {
0063 return true;
0064 }
0065
0066 --state.cur_;
0067 }
0068 return false;
0069 }
0070
0071 char_class_type newline() const
0072 {
0073 return this->newline_;
0074 }
0075
0076 private:
0077 char_class_type newline_;
0078 char_type nl_, cr_;
0079 };
0080
0081 }}}
0082
0083 #endif