Chris@16: /*============================================================================= Chris@16: Copyright (c) 2001-2011 Joel de Guzman Chris@16: Chris@16: Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: ==============================================================================*/ Chris@16: #if !defined(BOOST_SPIRIT_CHAR_CLASS_APRIL_16_2006_1051AM) Chris@16: #define BOOST_SPIRIT_CHAR_CLASS_APRIL_16_2006_1051AM Chris@16: Chris@16: #if defined(_MSC_VER) Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { namespace spirit Chris@16: { Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Enablers Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // enables alnum, alpha, graph, etc. Chris@16: template Chris@16: struct use_terminal > Chris@16: : mpl::true_ {}; Chris@16: }} Chris@16: Chris@16: namespace boost { namespace spirit { namespace qi Chris@16: { Chris@16: // hoist the char classification namespaces into qi sub-namespaces of the Chris@16: // same name Chris@16: namespace ascii { using namespace boost::spirit::ascii; } Chris@16: namespace iso8859_1 { using namespace boost::spirit::iso8859_1; } Chris@16: namespace standard { using namespace boost::spirit::standard; } Chris@16: namespace standard_wide { using namespace boost::spirit::standard_wide; } Chris@16: #if defined(BOOST_SPIRIT_UNICODE) Chris@16: namespace unicode { using namespace boost::spirit::unicode; } Chris@16: #endif Chris@16: Chris@16: // Import the standard namespace into the qi namespace. This allows Chris@16: // for default handling of all character/string related operations if not Chris@16: // prefixed with a character set namespace. Chris@16: using namespace boost::spirit::standard; Chris@16: Chris@16: // Import encoding Chris@16: using spirit::encoding; Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Generic char classification parser (for alnum, alpha, graph, etc.) Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct char_class Chris@16: : char_parser, typename Tag::char_encoding::char_type> Chris@16: { Chris@16: typedef typename Tag::char_encoding char_encoding; Chris@16: typedef typename Tag::char_class classification; Chris@16: Chris@16: template Chris@16: bool test(CharParam ch, Context&) const Chris@16: { Chris@16: using spirit::char_class::classify; Chris@16: return traits::ischar::call(ch) && Chris@16: classify::is(classification(), ch); Chris@16: } Chris@16: Chris@16: template Chris@16: info what(Context& /*context*/) const Chris@16: { Chris@16: typedef spirit::char_class::what what_; Chris@16: return info(what_::is(classification())); Chris@16: } Chris@16: }; Chris@16: Chris@16: namespace detail Chris@16: { Chris@16: template Chris@16: struct make_char_class : mpl::identity {}; Chris@16: Chris@16: template <> Chris@16: struct make_char_class : mpl::identity {}; Chris@16: Chris@16: template <> Chris@16: struct make_char_class : mpl::identity {}; Chris@16: } Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Parser generators: make_xxx function (objects) Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct make_primitive, Modifiers> Chris@16: { Chris@16: static bool const no_case = Chris@16: has_modifier >::value; Chris@16: Chris@16: typedef typename Chris@16: spirit::detail::get_encoding::type Chris@16: char_encoding; Chris@16: Chris@16: typedef tag::char_code< Chris@16: typename detail::make_char_class::type Chris@16: , char_encoding> Chris@16: tag; Chris@16: Chris@16: typedef char_class result_type; Chris@16: result_type operator()(unused_type, unused_type) const Chris@16: { Chris@16: return result_type(); Chris@16: } Chris@16: }; Chris@16: }}} Chris@16: Chris@16: #endif