1 /*=============================================================================
2 Copyright (c) 2001-2014 Joel de Guzman
3 http://spirit.sourceforge.net/
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 =============================================================================*/
8 #if !defined(BOOST_SPIRIT_X3_ATTRIBUTE_CATEGORY_JAN_4_2012_1150AM)
9 #define BOOST_SPIRIT_X3_ATTRIBUTE_CATEGORY_JAN_4_2012_1150AM
11 #include <boost/mpl/identity.hpp>
12 #include <boost/mpl/logical.hpp>
13 #include <boost/mpl/eval_if.hpp>
14 #include <boost/fusion/include/copy.hpp>
15 #include <boost/fusion/include/is_sequence.hpp>
16 #include <boost/fusion/support/category_of.hpp>
17 #include <boost/spirit/home/x3/support/traits/is_variant.hpp>
18 #include <boost/spirit/home/x3/support/traits/container_traits.hpp>
20 namespace boost { namespace spirit { namespace x3
25 namespace boost { namespace spirit { namespace x3 { namespace traits
27 struct unused_attribute {};
28 struct plain_attribute {};
29 struct container_attribute {};
30 struct tuple_attribute {};
31 struct associative_attribute {};
32 struct variant_attribute {};
33 struct optional_attribute {};
35 template <typename T, typename Enable = void>
36 struct attribute_category
37 : mpl::identity<plain_attribute> {};
40 struct attribute_category<unused_type>
41 : mpl::identity<unused_attribute> {};
44 struct attribute_category<unused_type const>
45 : mpl::identity<unused_attribute> {};
48 struct attribute_category< T
50 typename mpl::eval_if<
51 fusion::traits::is_sequence<T>
52 , fusion::traits::is_associative<T>
55 : mpl::identity<associative_attribute> {};
58 struct attribute_category< T
61 fusion::traits::is_sequence<T>
62 , mpl::not_<fusion::traits::is_associative<T> >
64 : mpl::identity<tuple_attribute> {};
67 struct attribute_category<T,
68 typename enable_if<traits::is_variant<T>>::type>
69 : mpl::identity<variant_attribute> {};
72 struct attribute_category<T,
73 typename enable_if<traits::is_container<T>>::type>
74 : mpl::identity<container_attribute> {};