Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #ifndef BOOST_METAPARSE_V1_ONE_CHAR_HPP
0002 #define BOOST_METAPARSE_V1_ONE_CHAR_HPP
0003 
0004 // Copyright Abel Sinkovics (abel@sinkovics.hu)  2009 - 2011.
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/error/unexpected_end_of_input.hpp>
0010 #include <boost/metaparse/v1/next_char.hpp>
0011 #include <boost/metaparse/v1/next_line.hpp>
0012 #include <boost/metaparse/v1/accept.hpp>
0013 #include <boost/metaparse/v1/reject.hpp>
0014 #include <boost/metaparse/v1/get_prev_char.hpp>
0015 
0016 #include <boost/mpl/empty.hpp>
0017 #include <boost/mpl/eval_if.hpp>
0018 #include <boost/mpl/front.hpp>
0019 #include <boost/mpl/pop_front.hpp>
0020 #include <boost/mpl/bool.hpp>
0021 
0022 namespace boost
0023 {
0024   namespace metaparse
0025   {
0026     namespace v1
0027     {
0028       struct one_char
0029       {
0030       private:
0031         template <class C, class Pos>
0032         struct next_pos :
0033           boost::mpl::eval_if<
0034             boost::mpl::bool_<
0035               C::type::value == '\r'
0036               || (
0037                 C::type::value == '\n'
0038                 && get_prev_char<Pos>::type::value != '\r'
0039               )
0040             >,
0041             next_line<Pos, C>,
0042             next_char<Pos, C>
0043           >
0044         {};
0045 
0046         template <class S, class NextPos>
0047         struct unchecked :
0048           accept<
0049             typename boost::mpl::front<S>::type,
0050             boost::mpl::pop_front<S>,
0051             NextPos
0052           >
0053         {};
0054       public:
0055         typedef one_char type;
0056         
0057         template <class S, class Pos>
0058         struct apply :
0059           boost::mpl::eval_if<
0060             typename boost::mpl::empty<S>::type,
0061             reject<error::unexpected_end_of_input, Pos>,
0062             unchecked<S, next_pos<boost::mpl::front<S>, Pos> >
0063           >
0064         {};
0065       };
0066     }
0067   }
0068 }
0069 
0070 #endif
0071