Chris@16: // Copyright (c) 2001-2011 Hartmut Kaiser 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_GENERATOR_JANUARY_13_2009_1002AM) Chris@16: #define BOOST_SPIRIT_GENERATOR_JANUARY_13_2009_1002AM 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: Chris@16: namespace boost { namespace spirit { namespace karma Chris@16: { Chris@16: struct generator_properties Chris@16: { Chris@16: enum enum_type { Chris@16: no_properties = 0, Chris@16: buffering = 0x01, // generator requires buffering Chris@16: counting = 0x02, // generator requires counting Chris@16: tracking = 0x04, // generator requires position tracking Chris@16: disabling = 0x08, // generator requires disabling of output Chris@16: Chris@16: countingbuffer = 0x03, // buffering | counting Chris@16: all_properties = 0x0f // buffering | counting | tracking | disabling Chris@16: }; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct generator Chris@16: { Chris@16: struct generator_id; Chris@16: typedef mpl::int_ properties; Chris@16: typedef Derived derived_type; Chris@16: typedef karma::domain domain; Chris@16: Chris@16: // Requirement: g.generate(o, context, delimiter, attr) -> bool Chris@16: // Chris@16: // g: a generator Chris@16: // o: output iterator Chris@16: // context: enclosing rule context (can be unused_type) Chris@16: // delimit: delimiter (can be unused_type) Chris@16: // attr: attribute (can be unused_type) Chris@16: Chris@16: // Requirement: g.what(context) -> info Chris@16: // Chris@16: // g: a generator Chris@16: // context: enclosing rule context (can be unused_type) Chris@16: Chris@16: // Requirement: G::template attribute::type Chris@16: // Chris@16: // G: a generator type Chris@16: // Ctx: A context type (can be unused_type) Chris@16: // Iter: An iterator type (always unused_type) Chris@16: Chris@16: Derived const& derived() const Chris@16: { Chris@16: return *static_cast(this); Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: struct primitive_generator : generator Chris@16: { Chris@16: struct primitive_generator_id; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct nary_generator : generator Chris@16: { Chris@16: struct nary_generator_id; Chris@16: Chris@16: // Requirement: g.elements -> fusion sequence Chris@16: // Chris@16: // g: a composite generator Chris@16: Chris@16: // Requirement: G::elements_type -> fusion sequence Chris@16: // Chris@16: // G: a composite generator type Chris@16: }; Chris@16: Chris@16: template Chris@16: struct unary_generator : generator Chris@16: { Chris@16: struct unary_generator_id; Chris@16: Chris@16: // Requirement: g.subject -> subject generator Chris@16: // Chris@16: // g: a unary generator Chris@16: Chris@16: // Requirement: G::subject_type -> subject generator type Chris@16: // Chris@16: // G: a unary generator type Chris@16: }; Chris@16: Chris@16: template Chris@16: struct binary_generator : generator Chris@16: { Chris@16: struct binary_generator_id; Chris@16: Chris@16: // Requirement: g.left -> left generator Chris@16: // Chris@16: // g: a binary generator Chris@16: Chris@16: // Requirement: G::left_type -> left generator type Chris@16: // Chris@16: // G: a binary generator type Chris@16: Chris@16: // Requirement: g.right -> right generator Chris@16: // Chris@16: // g: a binary generator Chris@16: Chris@16: // Requirement: G::right_type -> right generator type Chris@16: // Chris@16: // G: a binary generator type Chris@16: }; Chris@16: Chris@16: }}} Chris@16: Chris@16: namespace boost { namespace spirit { namespace traits // classification Chris@16: { Chris@16: namespace detail Chris@16: { Chris@16: // generator tags Chris@16: BOOST_MPL_HAS_XXX_TRAIT_DEF(generator_id) Chris@16: BOOST_MPL_HAS_XXX_TRAIT_DEF(primitive_generator_id) Chris@16: BOOST_MPL_HAS_XXX_TRAIT_DEF(nary_generator_id) Chris@16: BOOST_MPL_HAS_XXX_TRAIT_DEF(unary_generator_id) Chris@16: BOOST_MPL_HAS_XXX_TRAIT_DEF(binary_generator_id) Chris@16: } Chris@16: Chris@16: // check for generator tags Chris@16: template Chris@16: struct is_generator : detail::has_generator_id {}; Chris@16: Chris@16: template Chris@16: struct is_primitive_generator : detail::has_primitive_generator_id {}; Chris@16: Chris@16: template Chris@16: struct is_nary_generator : detail::has_nary_generator_id {}; Chris@16: Chris@16: template Chris@16: struct is_unary_generator : detail::has_unary_generator_id {}; Chris@16: Chris@16: template Chris@16: struct is_binary_generator : detail::has_binary_generator_id {}; Chris@16: Chris@16: // check for generator properties Chris@16: template Chris@16: struct properties_of : T::properties {}; Chris@16: Chris@16: }}} Chris@16: Chris@16: #endif