Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //  Copyright (c) 2001-2011 Hartmut Kaiser
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_GENERATOR_JANUARY_13_2009_1002AM)
0008 #define BOOST_SPIRIT_GENERATOR_JANUARY_13_2009_1002AM
0009 
0010 #if defined(_MSC_VER)
0011 #pragma once
0012 #endif
0013 
0014 #include <boost/mpl/has_xxx.hpp>
0015 #include <boost/mpl/int.hpp>
0016 #include <boost/spirit/home/karma/domain.hpp>
0017 
0018 namespace boost { namespace spirit { namespace karma
0019 {
0020     struct generator_properties
0021     {
0022         enum enum_type {
0023             no_properties = 0,
0024             buffering = 0x01,        // generator requires buffering
0025             counting = 0x02,         // generator requires counting
0026             tracking = 0x04,         // generator requires position tracking
0027             disabling = 0x08,        // generator requires disabling of output
0028 
0029             countingbuffer = 0x03,   // buffering | counting
0030             all_properties = 0x0f    // buffering | counting | tracking | disabling
0031         };
0032     };
0033 
0034     template <typename Derived>
0035     struct generator
0036     {
0037         struct generator_id;
0038         typedef mpl::int_<generator_properties::no_properties> properties;
0039         typedef Derived derived_type;
0040         typedef karma::domain domain;
0041 
0042         // Requirement: g.generate(o, context, delimiter, attr) -> bool
0043         //
0044         //  g:          a generator
0045         //  o:          output iterator
0046         //  context:    enclosing rule context (can be unused_type)
0047         //  delimit:    delimiter (can be unused_type)
0048         //  attr:       attribute (can be unused_type)
0049 
0050         // Requirement: g.what(context) -> info
0051         //
0052         //  g:          a generator
0053         //  context:    enclosing rule context (can be unused_type)
0054 
0055         // Requirement: G::template attribute<Ctx, Iter>::type
0056         //
0057         //  G:          a generator type
0058         //  Ctx:        A context type (can be unused_type)
0059         //  Iter:       An iterator type (always unused_type)
0060 
0061         Derived const& derived() const
0062         {
0063             return *static_cast<Derived const*>(this);
0064         }
0065     };
0066 
0067     template <typename Derived>
0068     struct primitive_generator : generator<Derived>
0069     {
0070         struct primitive_generator_id;
0071     };
0072 
0073     template <typename Derived>
0074     struct nary_generator : generator<Derived>
0075     {
0076         struct nary_generator_id;
0077 
0078         // Requirement: g.elements -> fusion sequence
0079         //
0080         // g:   a composite generator
0081 
0082         // Requirement: G::elements_type -> fusion sequence
0083         //
0084         // G:   a composite generator type
0085     };
0086 
0087     template <typename Derived>
0088     struct unary_generator : generator<Derived>
0089     {
0090         struct unary_generator_id;
0091 
0092         // Requirement: g.subject -> subject generator
0093         //
0094         // g:   a unary generator
0095 
0096         // Requirement: G::subject_type -> subject generator type
0097         //
0098         // G:   a unary generator type
0099     };
0100 
0101     template <typename Derived>
0102     struct binary_generator : generator<Derived>
0103     {
0104         struct binary_generator_id;
0105 
0106         // Requirement: g.left -> left generator
0107         //
0108         // g:   a binary generator
0109 
0110         // Requirement: G::left_type -> left generator type
0111         //
0112         // G:   a binary generator type
0113 
0114         // Requirement: g.right -> right generator
0115         //
0116         // g:   a binary generator
0117 
0118         // Requirement: G::right_type -> right generator type
0119         //
0120         // G:   a binary generator type
0121     };
0122 
0123 }}}
0124 
0125 namespace boost { namespace spirit { namespace traits // classification
0126 {
0127     namespace detail
0128     {
0129         // generator tags
0130         BOOST_MPL_HAS_XXX_TRAIT_DEF(generator_id)
0131         BOOST_MPL_HAS_XXX_TRAIT_DEF(primitive_generator_id)
0132         BOOST_MPL_HAS_XXX_TRAIT_DEF(nary_generator_id)
0133         BOOST_MPL_HAS_XXX_TRAIT_DEF(unary_generator_id)
0134         BOOST_MPL_HAS_XXX_TRAIT_DEF(binary_generator_id)
0135     }
0136 
0137     // check for generator tags
0138     template <typename T>
0139     struct is_generator : detail::has_generator_id<T> {};
0140 
0141     template <typename T>
0142     struct is_primitive_generator : detail::has_primitive_generator_id<T> {};
0143 
0144     template <typename T>
0145     struct is_nary_generator : detail::has_nary_generator_id<T> {};
0146 
0147     template <typename T>
0148     struct is_unary_generator : detail::has_unary_generator_id<T> {};
0149 
0150     template <typename T>
0151     struct is_binary_generator : detail::has_binary_generator_id<T> {};
0152 
0153     // check for generator properties
0154     template <typename T>
0155     struct properties_of : T::properties {};
0156 
0157 }}}
0158 
0159 #endif