Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:47:43

0001 /*=============================================================================
0002     Copyright (c) 2001-2011 Joel de Guzman
0003 
0004     Distributed under the Boost Software License, Version 1.0. (See accompanying
0005     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 ==============================================================================*/
0007 #if !defined(BOOST_SPIRIT_CHAR_CLASS_APRIL_16_2006_1051AM)
0008 #define BOOST_SPIRIT_CHAR_CLASS_APRIL_16_2006_1051AM
0009 
0010 #if defined(_MSC_VER)
0011 #pragma once
0012 #endif
0013 
0014 #include <boost/spirit/home/qi/char/char_parser.hpp>
0015 #include <boost/spirit/home/qi/domain.hpp>
0016 #include <boost/spirit/home/support/char_class.hpp>
0017 #include <boost/spirit/home/support/common_terminals.hpp>
0018 #include <boost/spirit/home/support/info.hpp>
0019 #include <boost/spirit/home/support/modify.hpp>
0020 #include <boost/spirit/home/support/detail/get_encoding.hpp>
0021 #include <boost/mpl/eval_if.hpp>
0022 
0023 namespace boost { namespace spirit
0024 {
0025     ///////////////////////////////////////////////////////////////////////////
0026     // Enablers
0027     ///////////////////////////////////////////////////////////////////////////
0028     // enables alnum, alpha, graph, etc.
0029     template <typename CharClass, typename CharEncoding>
0030     struct use_terminal<qi::domain, tag::char_code<CharClass, CharEncoding> >
0031       : mpl::true_ {};
0032 }}
0033 
0034 namespace boost { namespace spirit { namespace qi
0035 {
0036     // hoist the char classification namespaces into qi sub-namespaces of the
0037     // same name
0038     namespace ascii { using namespace boost::spirit::ascii; }
0039     namespace iso8859_1 { using namespace boost::spirit::iso8859_1; }
0040     namespace standard { using namespace boost::spirit::standard; }
0041     namespace standard_wide { using namespace boost::spirit::standard_wide; }
0042 #if defined(BOOST_SPIRIT_UNICODE)
0043     namespace unicode { using namespace boost::spirit::unicode; }
0044 #endif
0045 
0046     // Import the standard namespace into the qi namespace. This allows
0047     // for default handling of all character/string related operations if not
0048     // prefixed with a character set namespace.
0049     using namespace boost::spirit::standard;
0050 
0051     // Import encoding
0052     using spirit::encoding;
0053 
0054     ///////////////////////////////////////////////////////////////////////////
0055     // Generic char classification parser (for alnum, alpha, graph, etc.)
0056     ///////////////////////////////////////////////////////////////////////////
0057     template <typename Tag>
0058     struct char_class
0059       : char_parser<char_class<Tag>, typename Tag::char_encoding::char_type>
0060     {
0061         typedef typename Tag::char_encoding char_encoding;
0062         typedef typename Tag::char_class classification;
0063 
0064         template <typename CharParam, typename Context>
0065         bool test(CharParam ch, Context&) const
0066         {
0067             using spirit::char_class::classify;
0068             return traits::ischar<CharParam, char_encoding>::call(ch) &&
0069                    classify<char_encoding>::is(classification(), ch);
0070         }
0071 
0072         template <typename Context>
0073         info what(Context& /*context*/) const
0074         {
0075             typedef spirit::char_class::what<char_encoding> what_;
0076             return info(what_::is(classification()));
0077         }
0078     };
0079 
0080     namespace detail
0081     {
0082         template <typename Tag, bool no_case = false>
0083         struct make_char_class : mpl::identity<Tag> {};
0084 
0085         template <>
0086         struct make_char_class<tag::lower, true> : mpl::identity<tag::alpha> {};
0087 
0088         template <>
0089         struct make_char_class<tag::upper, true> : mpl::identity<tag::alpha> {};
0090     }
0091 
0092     ///////////////////////////////////////////////////////////////////////////
0093     // Parser generators: make_xxx function (objects)
0094     ///////////////////////////////////////////////////////////////////////////
0095     template <typename CharClass, typename CharEncoding, typename Modifiers>
0096     struct make_primitive<tag::char_code<CharClass, CharEncoding>, Modifiers>
0097     {
0098         static bool const no_case =
0099             has_modifier<Modifiers, tag::char_code_base<tag::no_case> >::value;
0100 
0101         typedef typename
0102             spirit::detail::get_encoding<Modifiers, CharEncoding>::type
0103         char_encoding;
0104 
0105         typedef tag::char_code<
0106             typename detail::make_char_class<CharClass, no_case>::type
0107           , char_encoding>
0108         tag;
0109 
0110         typedef char_class<tag> result_type;
0111         result_type operator()(unused_type, unused_type) const
0112         {
0113             return result_type();
0114         }
0115     };
0116 }}}
0117 
0118 #endif