Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / spirit / home / x3 / support / traits / attribute_category.hpp
1 /*=============================================================================
2     Copyright (c) 2001-2014 Joel de Guzman
3     http://spirit.sourceforge.net/
4
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
10
11 #if defined(_MSC_VER)
12 #pragma once
13 #endif
14
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>
23
24 namespace boost { namespace spirit { namespace x3
25 {
26    struct unused_type;
27 }}}
28
29 namespace boost { namespace spirit { namespace x3 { namespace traits
30 {
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 {};
38
39     template <typename T, typename Enable = void>
40     struct attribute_category
41         : mpl::identity<plain_attribute> {};
42
43     template <>
44     struct attribute_category<unused_type>
45         : mpl::identity<unused_attribute> {};
46
47     template <>
48     struct attribute_category<unused_type const>
49         : mpl::identity<unused_attribute> {};
50
51     template <typename T>
52     struct attribute_category< T
53         , typename enable_if<
54               typename mpl::eval_if< 
55                   fusion::traits::is_sequence<T>
56                   , fusion::traits::is_associative<T>
57                   , mpl::false_
58                   >::type >::type >
59         : mpl::identity<associative_attribute> {};
60
61     template <typename T>
62     struct attribute_category< T
63         , typename enable_if<
64               mpl::and_<
65                   fusion::traits::is_sequence<T>
66                   , mpl::not_<fusion::traits::is_associative<T> > 
67                   > >::type >
68         : mpl::identity<tuple_attribute> {};
69
70     template <typename T>
71     struct attribute_category<T,
72         typename enable_if<traits::is_variant<T>>::type>
73         : mpl::identity<variant_attribute> {};
74
75     template <typename T>
76     struct attribute_category<T,
77         typename enable_if<traits::is_container<T>>::type>
78         : mpl::identity<container_attribute> {};
79
80 }}}}
81
82 #endif