]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/quickbook/src/value_tags.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / tools / quickbook / src / value_tags.hpp
1 /*=============================================================================
2 Copyright (c) 2011 Daniel James
3
4 Use, modification and distribution is subject to the Boost Software
5 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt)
7 =============================================================================*/
8
9 #if !defined(BOOST_SPIRIT_QUICKBOOK_VALUES_TAGS_HPP)
10 #define BOOST_SPIRIT_QUICKBOOK_VALUES_TAGS_HPP
11
12 #include <boost/preprocessor/stringize.hpp>
13 #include <boost/preprocessor/seq/enum.hpp>
14 #include <boost/preprocessor/seq/for_each.hpp>
15 #include <boost/preprocessor/seq/elem.hpp>
16 #include <boost/range/irange.hpp>
17 #include <cassert>
18
19 #define QUICKBOOK_VALUE_TAGS(tags_name, start_index, values) \
20 struct tags_name { \
21 enum tags_name##_enum { \
22 previous_index = start_index - 1, \
23 BOOST_PP_SEQ_ENUM(values), \
24 end_index \
25 }; \
26 \
27 static char const* name(int value) { \
28 switch(value) {\
29 case 0: \
30 return "null"; \
31 BOOST_PP_SEQ_FOR_EACH(QUICKBOOK_VALUE_CASE, _, values) \
32 default: \
33 assert(false); return ""; \
34 }; \
35 } \
36 \
37 typedef boost::integer_range<int> range_type; \
38 static range_type tags() { return boost::irange(start_index, (int) end_index); } \
39 static bool is_tag(int value) { \
40 return value >= start_index && value < (int) end_index; \
41 } \
42 };
43
44 #define QUICKBOOK_VALUE_CASE(r, _, value) \
45 case value: return BOOST_PP_STRINGIZE(value);
46
47 #define QUICKBOOK_VALUE_NAMED_TAGS(tags_name, start_index, values) \
48 struct tags_name { \
49 enum tags_name##_enum { \
50 previous_index = start_index - 1 \
51 BOOST_PP_SEQ_FOR_EACH(QUICKBOOK_VALUE_NAMED_ENUM, _, values), \
52 end_index \
53 }; \
54 \
55 static char const* name(int value) { \
56 switch(value) {\
57 case 0: \
58 return "null"; \
59 BOOST_PP_SEQ_FOR_EACH(QUICKBOOK_VALUE_NAMED_CASE, _, values) \
60 default: \
61 assert(false); return ""; \
62 }; \
63 } \
64 \
65 typedef boost::integer_range<int> range_type; \
66 static range_type tags() { return boost::irange(start_index, (int) end_index); } \
67 static bool is_tag(int value) { \
68 return value >= start_index && value < (int) end_index; \
69 } \
70 };
71
72 #define QUICKBOOK_VALUE_NAMED_ENUM(r, _, value) \
73 , BOOST_PP_SEQ_ELEM(0, value)
74
75 #define QUICKBOOK_VALUE_NAMED_CASE(r, _, value) \
76 case BOOST_PP_SEQ_ELEM(0, value): return BOOST_PP_SEQ_ELEM(1, value);
77
78
79 #endif