Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:40:49

0001 #ifndef BOOST_METAPARSE_V1_IMPL_STRING_ITERATOR_HPP
0002 #define BOOST_METAPARSE_V1_IMPL_STRING_ITERATOR_HPP
0003 
0004 // Copyright Abel Sinkovics (abel@sinkovics.hu)  2013.
0005 // Distributed under the Boost Software License, Version 1.0.
0006 //    (See accompanying file LICENSE_1_0.txt or copy at
0007 //          http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 #include <boost/metaparse/v1/impl/string_iterator_tag.hpp>
0010 #include <boost/metaparse/v1/impl/at_c.hpp>
0011 
0012 
0013 #include <boost/mpl/iterator_tags.hpp>
0014 #include <boost/mpl/int.hpp>
0015 #include <boost/mpl/bool.hpp>
0016 
0017 #include <boost/type_traits/is_same.hpp>
0018 
0019 namespace boost
0020 {
0021   namespace metaparse
0022   {
0023     namespace v1
0024     {
0025       namespace impl
0026       {
0027         // string_iterator
0028         template <class S, int N>
0029         struct string_iterator
0030         {
0031           typedef string_iterator type;
0032           typedef string_iterator_tag tag;
0033           typedef boost::mpl::random_access_iterator_tag category;
0034         };
0035 
0036         // advance_c
0037 
0038         template <class S, int N>
0039         struct advance_c;
0040 
0041         template <class S, int N, int P>
0042         struct advance_c<string_iterator<S, N>, P> :
0043           string_iterator<S, N + P>
0044         {};
0045 
0046         // distance
0047 
0048         template <class A, class B>
0049         struct distance;
0050 
0051         template <class S, int A, int B>
0052         struct distance<string_iterator<S, A>, string_iterator<S, B> > :
0053           boost::mpl::int_<B - A>
0054         {};
0055       }
0056     }
0057   }
0058 }
0059 
0060 namespace boost
0061 {
0062   namespace mpl
0063   {
0064     // advance
0065     template <class S>
0066     struct advance_impl;
0067 
0068     template <>
0069     struct advance_impl<boost::metaparse::v1::impl::string_iterator_tag>
0070     {
0071       typedef advance_impl type;
0072 
0073       template <class S, class N>
0074       struct apply :
0075         boost::metaparse::v1::impl::advance_c<
0076           typename S::type, N::type::value
0077         >
0078       {};
0079     };
0080 
0081     // distance
0082     template <class S>
0083     struct distance_impl;
0084 
0085     template <>
0086     struct distance_impl<boost::metaparse::v1::impl::string_iterator_tag>
0087     {
0088       typedef distance_impl type;
0089 
0090       template <class A, class B>
0091       struct apply :
0092         boost::metaparse::v1::impl::distance<
0093           typename A::type,
0094           typename B::type
0095         >
0096       {};
0097     };
0098 
0099     // next
0100     template <class S>
0101     struct next;
0102 
0103     template <class S, int N>
0104     struct next<boost::metaparse::v1::impl::string_iterator<S, N> > :
0105       boost::metaparse::v1::impl::string_iterator<S, N + 1>
0106     {};
0107 
0108     // prior
0109     template <class S>
0110     struct prior;
0111 
0112     template <class S, int N>
0113     struct prior<boost::metaparse::v1::impl::string_iterator<S, N> > :
0114       boost::metaparse::v1::impl::string_iterator<S, N - 1>
0115     {};
0116 
0117     // deref
0118     template <class S>
0119     struct deref;
0120 
0121     template <class S, int N>
0122     struct deref<boost::metaparse::v1::impl::string_iterator<S, N> > :
0123       boost::metaparse::v1::impl::at_c<S, N>
0124     {};
0125 
0126     // equal_to
0127     template <class A, class B>
0128     struct equal_to_impl;
0129 
0130     template <>
0131     struct equal_to_impl<
0132       boost::metaparse::v1::impl::string_iterator_tag,
0133       boost::metaparse::v1::impl::string_iterator_tag
0134     >
0135     {
0136       typedef equal_to_impl type;
0137 
0138       template <class A, class B>
0139       struct apply : is_same<typename A::type, typename B::type> {};
0140     };
0141 
0142     template <class T>
0143     struct equal_to_impl<boost::metaparse::v1::impl::string_iterator_tag, T>
0144     {
0145       typedef equal_to_impl type;
0146       
0147       template <class, class>
0148       struct apply : false_ {};
0149     };
0150     
0151     template <class T>
0152     struct equal_to_impl<T, boost::metaparse::v1::impl::string_iterator_tag> :
0153       equal_to_impl<boost::metaparse::v1::impl::string_iterator_tag, T>
0154     {};
0155   }
0156 }
0157 
0158 #endif
0159