]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | #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> | |
19 | ||
20 | namespace boost { namespace spirit { namespace x3 | |
21 | { | |
22 | struct unused_type; | |
23 | }}} | |
24 | ||
25 | namespace boost { namespace spirit { namespace x3 { namespace traits | |
26 | { | |
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 {}; | |
34 | ||
35 | template <typename T, typename Enable = void> | |
36 | struct attribute_category | |
37 | : mpl::identity<plain_attribute> {}; | |
38 | ||
39 | template <> | |
40 | struct attribute_category<unused_type> | |
41 | : mpl::identity<unused_attribute> {}; | |
42 | ||
43 | template <> | |
44 | struct attribute_category<unused_type const> | |
45 | : mpl::identity<unused_attribute> {}; | |
46 | ||
47 | template <typename T> | |
48 | struct attribute_category< T | |
49 | , typename enable_if< | |
50 | typename mpl::eval_if< | |
51 | fusion::traits::is_sequence<T> | |
52 | , fusion::traits::is_associative<T> | |
53 | , mpl::false_ | |
54 | >::type >::type > | |
55 | : mpl::identity<associative_attribute> {}; | |
56 | ||
57 | template <typename T> | |
58 | struct attribute_category< T | |
59 | , typename enable_if< | |
60 | mpl::and_< | |
61 | fusion::traits::is_sequence<T> | |
62 | , mpl::not_<fusion::traits::is_associative<T> > | |
63 | > >::type > | |
64 | : mpl::identity<tuple_attribute> {}; | |
65 | ||
66 | template <typename T> | |
67 | struct attribute_category<T, | |
68 | typename enable_if<traits::is_variant<T>>::type> | |
69 | : mpl::identity<variant_attribute> {}; | |
70 | ||
71 | template <typename T> | |
72 | struct attribute_category<T, | |
73 | typename enable_if<traits::is_container<T>>::type> | |
74 | : mpl::identity<container_attribute> {}; | |
75 | ||
76 | }}}} | |
77 | ||
78 | #endif |