]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/xpressive/include/boost/xpressive/detail/core/quant_style.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / xpressive / include / boost / xpressive / detail / core / quant_style.hpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // quant_style.hpp
3 //
4 // Copyright 2008 Eric Niebler. Distributed under the Boost
5 // Software License, Version 1.0. (See accompanying file
6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7
8 #ifndef BOOST_XPRESSIVE_DETAIL_CORE_QUANT_STYLE_HPP_EAN_10_04_2005
9 #define BOOST_XPRESSIVE_DETAIL_CORE_QUANT_STYLE_HPP_EAN_10_04_2005
10
11 // MS compatible compilers support #pragma once
12 #if defined(_MSC_VER)
13 # pragma once
14 #endif
15
16 #include <boost/config.hpp>
17 #include <boost/mpl/has_xxx.hpp>
18 #include <boost/xpressive/detail/utility/width.hpp>
19 #include <boost/xpressive/detail/detail_fwd.hpp>
20
21 namespace boost { namespace xpressive { namespace detail
22 {
23
24 BOOST_MPL_HAS_XXX_TRAIT_DEF(is_boost_xpressive_xpression_)
25
26 ///////////////////////////////////////////////////////////////////////////////
27 // is_xpr
28 //
29 template<typename Xpr>
30 struct is_xpr
31 : has_is_boost_xpressive_xpression_<Xpr>
32 {};
33
34 ///////////////////////////////////////////////////////////////////////////////
35 // quant_enum
36 //
37 enum quant_enum
38 {
39 quant_none,
40 quant_fixed_width,
41 quant_variable_width
42 };
43
44 ///////////////////////////////////////////////////////////////////////////////
45 // quant_style
46 //
47 template<quant_enum QuantStyle, std::size_t Width = unknown_width::value, bool Pure = true>
48 struct quant_style
49 {
50 typedef void is_boost_xpressive_xpression_;
51
52 // Which quantification strategy to use?
53 BOOST_STATIC_CONSTANT(int, quant = QuantStyle);
54
55 // how many characters this matcher consumes
56 BOOST_STATIC_CONSTANT(std::size_t, width = Width);
57
58 // whether this matcher has observable side-effects
59 BOOST_STATIC_CONSTANT(bool, pure = Pure);
60
61 static detail::width get_width()
62 {
63 return width;
64 }
65 };
66
67 #define BOOST_XPR_QUANT_STYLE(Style, Width, Pure) \
68 typedef void is_boost_xpressive_xpression_; \
69 BOOST_STATIC_CONSTANT(int, quant = Style); \
70 BOOST_STATIC_CONSTANT(std::size_t, width = Width); \
71 BOOST_STATIC_CONSTANT(bool, pure = Pure); \
72 static detail::width get_width() { return width; } \
73 /**/
74
75 // // Replace transmogrify stupidity with rebindable matchers/placeholders
76 //#define BOOST_XPR_IDENTITY_REBIND(TYPE) \/
77 // template<typename BidiIter, typename ICase, typename Traits> \/
78 // struct rebind \/
79 // { \/
80 // typedef TYPE type; \/
81 // }; \/
82 // /**/
83
84 ///////////////////////////////////////////////////////////////////////////////
85 // quant_style_none
86 // this sub-expression cannot be quantified
87 typedef quant_style<quant_none> quant_style_none;
88
89 ///////////////////////////////////////////////////////////////////////////////
90 // quant_style_fixed_unknown_width
91 // this sub-expression is fixed width for the purpose of quantification, but
92 // the width cannot be determined at compile time. An example would be the
93 // string_matcher or the mark_matcher.
94 typedef quant_style<quant_fixed_width> quant_style_fixed_unknown_width;
95
96 ///////////////////////////////////////////////////////////////////////////////
97 // quant_style_variable_width
98 // this sub-expression can match a variable number of characters
99 typedef quant_style<quant_variable_width> quant_style_variable_width;
100
101 ///////////////////////////////////////////////////////////////////////////////
102 // quant_style_fixed_width
103 // for when the sub-expression has a fixed width that is known at compile time
104 template<std::size_t Width>
105 struct quant_style_fixed_width
106 : quant_style<quant_fixed_width, Width>
107 {
108 };
109
110 ///////////////////////////////////////////////////////////////////////////////
111 // quant_style_assertion
112 // a zero-width assertion.
113 struct quant_style_assertion
114 : quant_style<quant_none, 0>
115 {
116 };
117
118 ///////////////////////////////////////////////////////////////////////////////
119 // quant_type
120 //
121 template<typename Matcher>
122 struct quant_type
123 : mpl::int_<Matcher::quant>
124 {
125 };
126
127 }}} // namespace boost::xpressive::detail
128
129 #endif