]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/spirit/home/classic/meta/impl/fundamental.ipp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / spirit / home / classic / meta / impl / fundamental.ipp
CommitLineData
7c673cae
FG
1/*=============================================================================
2 Copyright (c) 2002-2003 Hartmut Kaiser
3 http://spirit.sourceforge.net/
4
5 Use, modification and distribution is subject to the Boost Software
6 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 http://www.boost.org/LICENSE_1_0.txt)
8=============================================================================*/
9#if !defined(BOOST_SPIRIT_FUNDAMENTAL_IPP)
10#define BOOST_SPIRIT_FUNDAMENTAL_IPP
11
12#include <boost/mpl/int.hpp>
13
14namespace boost { namespace spirit {
15
16BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
17
18namespace impl
19{
20 ///////////////////////////////////////////////////////////////////////////
21 //
22 // Helper template for counting the number of nodes contained in a
23 // given parser type.
24 // All parser_category type parsers are counted as nodes.
25 //
26 ///////////////////////////////////////////////////////////////////////////
27 template <typename CategoryT>
28 struct nodes;
29
30 template <>
31 struct nodes<plain_parser_category> {
32
33 template <typename ParserT, typename LeafCountT>
34 struct count {
35
20effc67 36 BOOST_STATIC_CONSTANT(int, value = (LeafCountT::value + 1));
7c673cae
FG
37 };
38 };
39
40 template <>
41 struct nodes<unary_parser_category> {
42
43 template <typename ParserT, typename LeafCountT>
44 struct count {
45
46 typedef typename ParserT::subject_t subject_t;
47 typedef typename subject_t::parser_category_t subject_category_t;
48
20effc67
TL
49 BOOST_STATIC_CONSTANT(int, value = (nodes<subject_category_t>
50 ::template count<subject_t, LeafCountT>::value + 1));
7c673cae
FG
51 };
52 };
53
54 template <>
55 struct nodes<action_parser_category> {
56
57 template <typename ParserT, typename LeafCountT>
58 struct count {
59
60 typedef typename ParserT::subject_t subject_t;
61 typedef typename subject_t::parser_category_t subject_category_t;
62
20effc67
TL
63 BOOST_STATIC_CONSTANT(int, value = (nodes<subject_category_t>
64 ::template count<subject_t, LeafCountT>::value + 1));
7c673cae
FG
65 };
66 };
67
68 template <>
69 struct nodes<binary_parser_category> {
70
71 template <typename ParserT, typename LeafCountT>
72 struct count {
73
74 typedef typename ParserT::left_t left_t;
75 typedef typename ParserT::right_t right_t;
76 typedef typename left_t::parser_category_t left_category_t;
77 typedef typename right_t::parser_category_t right_category_t;
78
79 typedef count self_t;
80
20effc67 81 BOOST_STATIC_CONSTANT(int,
7c673cae 82 leftcount = (nodes<left_category_t>
20effc67
TL
83 ::template count<left_t, LeafCountT>::value));
84 BOOST_STATIC_CONSTANT(int,
7c673cae 85 rightcount = (nodes<right_category_t>
20effc67
TL
86 ::template count<right_t, LeafCountT>::value));
87 BOOST_STATIC_CONSTANT(int,
88 value = ((self_t::leftcount) + (self_t::rightcount) + 1));
7c673cae
FG
89 };
90 };
91
92 ///////////////////////////////////////////////////////////////////////////
93 //
94 // Helper template for counting the number of leaf nodes contained in a
95 // given parser type.
96 // Only plain_parser_category type parsers are counted as leaf nodes.
97 //
98 ///////////////////////////////////////////////////////////////////////////
99 template <typename CategoryT>
100 struct leafs;
101
102 template <>
103 struct leafs<plain_parser_category> {
104
105 template <typename ParserT, typename LeafCountT>
106 struct count {
107
20effc67 108 BOOST_STATIC_CONSTANT(int, value = (LeafCountT::value + 1));
7c673cae
FG
109 };
110 };
111
112 template <>
113 struct leafs<unary_parser_category> {
114
115 template <typename ParserT, typename LeafCountT>
116 struct count {
117
118 typedef typename ParserT::subject_t subject_t;
119 typedef typename subject_t::parser_category_t subject_category_t;
120
20effc67
TL
121 BOOST_STATIC_CONSTANT(int, value = (leafs<subject_category_t>
122 ::template count<subject_t, LeafCountT>::value));
7c673cae
FG
123 };
124 };
125
126 template <>
127 struct leafs<action_parser_category> {
128
129 template <typename ParserT, typename LeafCountT>
130 struct count {
131
132 typedef typename ParserT::subject_t subject_t;
133 typedef typename subject_t::parser_category_t subject_category_t;
134
20effc67
TL
135 BOOST_STATIC_CONSTANT(int, value = (leafs<subject_category_t>
136 ::template count<subject_t, LeafCountT>::value));
7c673cae
FG
137 };
138 };
139
140 template <>
141 struct leafs<binary_parser_category> {
142
143 template <typename ParserT, typename LeafCountT>
144 struct count {
145
146 typedef typename ParserT::left_t left_t;
147 typedef typename ParserT::right_t right_t;
148 typedef typename left_t::parser_category_t left_category_t;
149 typedef typename right_t::parser_category_t right_category_t;
150
151 typedef count self_t;
152
20effc67 153 BOOST_STATIC_CONSTANT(int,
7c673cae 154 leftcount = (leafs<left_category_t>
20effc67
TL
155 ::template count<left_t, LeafCountT>::value));
156 BOOST_STATIC_CONSTANT(int,
7c673cae 157 rightcount = (leafs<right_category_t>
20effc67
TL
158 ::template count<right_t, LeafCountT>::value));
159 BOOST_STATIC_CONSTANT(int,
160 value = (self_t::leftcount + self_t::rightcount));
7c673cae
FG
161 };
162 };
163
164} // namespace impl
165
166///////////////////////////////////////////////////////////////////////////////
167BOOST_SPIRIT_CLASSIC_NAMESPACE_END
168
169}} // namespace boost::spirit
170
171#endif // !defined(BOOST_SPIRIT_FUNDAMENTAL_IPP)