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
15 #include <boost/mpl/identity.hpp>
16 #include <boost/mpl/logical.hpp>
17 #include <boost/mpl/eval_if.hpp>
18 #include <boost/fusion/include/copy.hpp>
19 #include <boost/fusion/include/is_sequence.hpp>
20 #include <boost/fusion/support/category_of.hpp>
21 #include <boost/spirit/home/x3/support/traits/is_variant.hpp>
22 #include <boost/spirit/home/x3/support/traits/container_traits.hpp>
24 namespace boost { namespace spirit { namespace x3
29 namespace boost { namespace spirit { namespace x3 { namespace traits
31 struct unused_attribute {};
32 struct plain_attribute {};
33 struct container_attribute {};
34 struct tuple_attribute {};
35 struct associative_attribute {};
36 struct variant_attribute {};
37 struct optional_attribute {};
39 template <typename T, typename Enable = void>
40 struct attribute_category
41 : mpl::identity<plain_attribute> {};
44 struct attribute_category<unused_type>
45 : mpl::identity<unused_attribute> {};
48 struct attribute_category<unused_type const>
49 : mpl::identity<unused_attribute> {};
52 struct attribute_category< T
54 typename mpl::eval_if<
55 fusion::traits::is_sequence<T>
56 , fusion::traits::is_associative<T>
59 : mpl::identity<associative_attribute> {};
62 struct attribute_category< T
65 fusion::traits::is_sequence<T>
66 , mpl::not_<fusion::traits::is_associative<T> >
68 : mpl::identity<tuple_attribute> {};
71 struct attribute_category<T,
72 typename enable_if<traits::is_variant<T>>::type>
73 : mpl::identity<variant_attribute> {};
76 struct attribute_category<T,
77 typename enable_if<traits::is_container<T>>::type>
78 : mpl::identity<container_attribute> {};