// Copyright (c) 2001-2008 Hartmut Kaiser // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #if !defined(BOOST_SPIRIT_KARMA_META_GRAMMAR_MAY_04_2007_0853AM) #define BOOST_SPIRIT_KARMA_META_GRAMMAR_MAY_04_2007_0853AM #if defined(_MSC_VER) && (_MSC_VER >= 1020) #pragma once // MS compatible compilers support #pragma once #endif #include #include #include #include #include #include #include namespace boost { namespace spirit { namespace karma { /////////////////////////////////////////////////////////////////////////// // forwards /////////////////////////////////////////////////////////////////////////// template struct any_binary_director; template struct binary_lit_director; struct binary_padding_director; struct main_meta_grammar; template struct is_valid_expr; template struct expr_transform; /////////////////////////////////////////////////////////////////////////// // get the director of an integer based binary literal type /////////////////////////////////////////////////////////////////////////// template struct extract_literal_bin_director { typedef binary_lit_director< boost::integer::native, sizeof(T)*CHAR_BIT > type; }; /////////////////////////////////////////////////////////////////////////// // get the director of a binary tag /////////////////////////////////////////////////////////////////////////// template struct extract_binary_director; // native endian binaries template <> struct extract_binary_director { typedef any_binary_director type; }; template <> struct extract_binary_director { typedef any_binary_director type; }; template <> struct extract_binary_director { typedef any_binary_director type; }; // big endian binaries template <> struct extract_binary_director { typedef any_binary_director type; }; template <> struct extract_binary_director { typedef any_binary_director type; }; // little endian binaries template <> struct extract_binary_director { typedef any_binary_director type; }; template <> struct extract_binary_director { typedef any_binary_director type; }; #ifdef BOOST_HAS_LONG_LONG template <> struct extract_binary_director { typedef any_binary_director type; }; template <> struct extract_binary_director { typedef any_binary_director type; }; template <> struct extract_binary_director { typedef any_binary_director type; }; #endif /////////////////////////////////////////////////////////////////////////// // get the director of a binary literal tag /////////////////////////////////////////////////////////////////////////// template struct extract_binary_lit_director; // native endian binaries template struct extract_binary_lit_director { typedef binary_lit_director type; }; template struct extract_binary_lit_director { typedef binary_lit_director type; }; template struct extract_binary_lit_director { typedef binary_lit_director type; }; // big endian binaries template struct extract_binary_lit_director { typedef binary_lit_director type; }; template struct extract_binary_lit_director { typedef binary_lit_director type; }; // little endian binaries template struct extract_binary_lit_director { typedef binary_lit_director type; }; template struct extract_binary_lit_director { typedef binary_lit_director type; }; #ifdef BOOST_HAS_LONG_LONG template struct extract_binary_lit_director { typedef binary_lit_director type; }; template struct extract_binary_lit_director { typedef binary_lit_director type; }; template struct extract_binary_lit_director { typedef binary_lit_director type; }; #endif /////////////////////////////////////////////////////////////////////////// // binary meta-grammar /////////////////////////////////////////////////////////////////////////// // literals: 10, 10L, 10LL struct int_binary_meta_grammar : meta_grammar::compose_empty< proto::if_< is_int_lit_tag() >, karma::domain, mpl::identity > > { }; struct binary_meta_grammar : proto::or_< meta_grammar::compose_empty< proto::if_< is_binary_tag() >, karma::domain, mpl::identity > >, meta_grammar::compose_function1_eval< proto::function< proto::if_< is_binary_tag() >, int_binary_meta_grammar >, karma::domain, mpl::identity > >, meta_grammar::function1_rule< karma::domain, tag::pad, binary_padding_director > > { }; /////////////////////////////////////////////////////////////////////////// // These specializations non-intrusively hooks into the Karma meta-grammar. // (see karma/meta_grammar.hpp) /////////////////////////////////////////////////////////////////////////// template struct is_valid_expr< Expr, typename enable_if< proto::matches >::type > : mpl::true_ { }; template struct expr_transform< Expr, typename enable_if< proto::matches >::type > : mpl::identity { }; }}} #endif