1 ///////////////////////////////////////////////////////////////////////////////
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_STRING_MATCHER_HPP_EAN_10_04_2005
9 #define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_STRING_MATCHER_HPP_EAN_10_04_2005
11 // MS compatible compilers support #pragma once
12 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
17 #include <boost/mpl/bool.hpp>
18 #include <boost/xpressive/detail/detail_fwd.hpp>
19 #include <boost/xpressive/detail/core/quant_style.hpp>
20 #include <boost/xpressive/detail/core/state.hpp>
21 #include <boost/xpressive/detail/utility/algorithm.hpp>
22 #include <boost/xpressive/detail/utility/traits_utils.hpp>
24 namespace boost { namespace xpressive { namespace detail
26 ///////////////////////////////////////////////////////////////////////////////
29 template<typename Traits, typename ICase>
31 : quant_style_fixed_unknown_width
33 typedef typename Traits::char_type char_type;
34 typedef typename Traits::string_type string_type;
35 typedef ICase icase_type;
37 char_type const *end_;
39 string_matcher(string_type const &str, Traits const &tr)
43 typename range_iterator<string_type>::type cur = boost::begin(this->str_);
44 typename range_iterator<string_type>::type end = boost::end(this->str_);
45 for(; cur != end; ++cur)
47 *cur = detail::translate(*cur, tr, icase_type());
49 this->end_ = detail::data_end(str_);
52 string_matcher(string_matcher<Traits, ICase> const &that)
54 , end_(detail::data_end(str_))
58 template<typename BidiIter, typename Next>
59 bool match(match_state<BidiIter> &state, Next const &next) const
61 BidiIter const tmp = state.cur_;
62 char_type const *begin = detail::data_begin(this->str_);
63 for(; begin != this->end_; ++begin, ++state.cur_)
66 (detail::translate(*state.cur_, traits_cast<Traits>(state), icase_type()) != *begin))
82 detail::width get_width() const
84 return boost::size(this->str_);