Warning, file /include/boost/xpressive/detail/core/optimize.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_XPRESSIVE_DETAIL_CORE_OPTIMIZE_HPP_EAN_10_04_2005
0009 #define BOOST_XPRESSIVE_DETAIL_CORE_OPTIMIZE_HPP_EAN_10_04_2005
0010
0011 #include <string>
0012 #include <utility>
0013 #include <boost/mpl/bool.hpp>
0014 #include <boost/intrusive_ptr.hpp>
0015 #include <boost/iterator/iterator_traits.hpp>
0016 #include <boost/xpressive/detail/core/finder.hpp>
0017 #include <boost/xpressive/detail/core/linker.hpp>
0018 #include <boost/xpressive/detail/core/peeker.hpp>
0019 #include <boost/xpressive/detail/core/regex_impl.hpp>
0020
0021 namespace boost { namespace xpressive { namespace detail
0022 {
0023
0024
0025
0026
0027 template<typename BidiIter, typename Traits>
0028 intrusive_ptr<finder<BidiIter> > optimize_regex
0029 (
0030 xpression_peeker<typename iterator_value<BidiIter>::type> const &peeker
0031 , Traits const &tr
0032 , mpl::false_
0033 )
0034 {
0035 if(peeker.line_start())
0036 {
0037 return intrusive_ptr<finder<BidiIter> >
0038 (
0039 new line_start_finder<BidiIter, Traits>(tr)
0040 );
0041 }
0042 else if(peeker.leading_simple_repeat())
0043 {
0044 return intrusive_ptr<finder<BidiIter> >
0045 (
0046 new leading_simple_repeat_finder<BidiIter>()
0047 );
0048 }
0049 else if(256 != peeker.bitset().count())
0050 {
0051 return intrusive_ptr<finder<BidiIter> >
0052 (
0053 new hash_peek_finder<BidiIter, Traits>(peeker.bitset())
0054 );
0055 }
0056
0057 return intrusive_ptr<finder<BidiIter> >();
0058 }
0059
0060
0061
0062
0063 template<typename BidiIter, typename Traits>
0064 intrusive_ptr<finder<BidiIter> > optimize_regex
0065 (
0066 xpression_peeker<typename iterator_value<BidiIter>::type> const &peeker
0067 , Traits const &tr
0068 , mpl::true_
0069 )
0070 {
0071 typedef typename iterator_value<BidiIter>::type char_type;
0072
0073
0074 peeker_string<char_type> const &str = peeker.get_string();
0075 if(str.begin_ != str.end_)
0076 {
0077 BOOST_ASSERT(1 == peeker.bitset().count());
0078 return intrusive_ptr<finder<BidiIter> >
0079 (
0080 new boyer_moore_finder<BidiIter, Traits>(str.begin_, str.end_, tr, str.icase_)
0081 );
0082 }
0083
0084 return optimize_regex<BidiIter>(peeker, tr, mpl::false_());
0085 }
0086
0087
0088
0089
0090 template<typename BidiIter, typename Traits>
0091 void common_compile
0092 (
0093 intrusive_ptr<matchable_ex<BidiIter> const> const ®ex
0094 , regex_impl<BidiIter> &impl
0095 , Traits const &tr
0096 )
0097 {
0098 typedef typename iterator_value<BidiIter>::type char_type;
0099
0100
0101 xpression_linker<char_type> linker(tr);
0102 regex->link(linker);
0103
0104
0105 hash_peek_bitset<char_type> bset;
0106 xpression_peeker<char_type> peeker(bset, tr, linker.has_backrefs());
0107 regex->peek(peeker);
0108
0109
0110 impl.finder_ = optimize_regex<BidiIter>(peeker, tr, is_random<BidiIter>());
0111 impl.xpr_ = regex;
0112 }
0113
0114 }}}
0115
0116 #endif