Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:53:49

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // quant_style.hpp
0003 //
0004 //  Copyright 2008 Eric Niebler. Distributed under the Boost
0005 //  Software License, Version 1.0. (See accompanying file
0006 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 
0008 #ifndef BOOST_XPRESSIVE_DETAIL_CORE_QUANT_STYLE_HPP_EAN_10_04_2005
0009 #define BOOST_XPRESSIVE_DETAIL_CORE_QUANT_STYLE_HPP_EAN_10_04_2005
0010 
0011 // MS compatible compilers support #pragma once
0012 #if defined(_MSC_VER)
0013 # pragma once
0014 #endif
0015 
0016 #include <boost/config.hpp>
0017 #include <boost/mpl/has_xxx.hpp>
0018 #include <boost/xpressive/detail/utility/width.hpp>
0019 #include <boost/xpressive/detail/detail_fwd.hpp>
0020 
0021 namespace boost { namespace xpressive { namespace detail
0022 {
0023 
0024 BOOST_MPL_HAS_XXX_TRAIT_DEF(is_boost_xpressive_xpression_)
0025 
0026 ///////////////////////////////////////////////////////////////////////////////
0027 // is_xpr
0028 //
0029 template<typename Xpr>
0030 struct is_xpr
0031   : has_is_boost_xpressive_xpression_<Xpr>
0032 {};
0033 
0034 ///////////////////////////////////////////////////////////////////////////////
0035 // quant_enum
0036 //
0037 enum quant_enum
0038 {
0039     quant_none,
0040     quant_fixed_width,
0041     quant_variable_width
0042 };
0043 
0044 ///////////////////////////////////////////////////////////////////////////////
0045 // quant_style
0046 //
0047 template<quant_enum QuantStyle, std::size_t Width = unknown_width::value, bool Pure = true>
0048 struct quant_style
0049 {
0050     typedef void is_boost_xpressive_xpression_;
0051 
0052     // Which quantification strategy to use?
0053     BOOST_STATIC_CONSTANT(int, quant = QuantStyle);
0054 
0055     // how many characters this matcher consumes
0056     BOOST_STATIC_CONSTANT(std::size_t, width = Width);
0057 
0058     // whether this matcher has observable side-effects
0059     BOOST_STATIC_CONSTANT(bool, pure = Pure);
0060 
0061     static detail::width get_width()
0062     {
0063         return width;
0064     }
0065 };
0066 
0067 #define BOOST_XPR_QUANT_STYLE(Style, Width, Pure)                               \
0068     typedef void is_boost_xpressive_xpression_;                                 \
0069     BOOST_STATIC_CONSTANT(int, quant = Style);                                  \
0070     BOOST_STATIC_CONSTANT(std::size_t, width = Width);                          \
0071     BOOST_STATIC_CONSTANT(bool, pure = Pure);                                   \
0072     static detail::width get_width() { return width; }                          \
0073     /**/
0074 
0075 //    // Replace transmogrify stupidity with rebindable matchers/placeholders
0076 //#define BOOST_XPR_IDENTITY_REBIND(TYPE)                                         \/
0077 //    template<typename BidiIter, typename ICase, typename Traits>                \/
0078 //    struct rebind                                                               \/
0079 //    {                                                                           \/
0080 //        typedef TYPE type;                                                      \/
0081 //    };                                                                          \/
0082 //    /**/
0083 
0084 ///////////////////////////////////////////////////////////////////////////////
0085 // quant_style_none
0086 //  this sub-expression cannot be quantified
0087 typedef quant_style<quant_none> quant_style_none;
0088 
0089 ///////////////////////////////////////////////////////////////////////////////
0090 // quant_style_fixed_unknown_width
0091 //  this sub-expression is fixed width for the purpose of quantification, but
0092 //  the width cannot be determined at compile time. An example would be the
0093 //  string_matcher or the mark_matcher.
0094 typedef quant_style<quant_fixed_width> quant_style_fixed_unknown_width;
0095 
0096 ///////////////////////////////////////////////////////////////////////////////
0097 // quant_style_variable_width
0098 //  this sub-expression can match a variable number of characters
0099 typedef quant_style<quant_variable_width> quant_style_variable_width;
0100 
0101 ///////////////////////////////////////////////////////////////////////////////
0102 // quant_style_fixed_width
0103 //  for when the sub-expression has a fixed width that is known at compile time
0104 template<std::size_t Width>
0105 struct quant_style_fixed_width
0106   : quant_style<quant_fixed_width, Width>
0107 {
0108 };
0109 
0110 ///////////////////////////////////////////////////////////////////////////////
0111 // quant_style_assertion
0112 //  a zero-width assertion.
0113 struct quant_style_assertion
0114   : quant_style<quant_none, 0>
0115 {
0116 };
0117 
0118 ///////////////////////////////////////////////////////////////////////////////
0119 // quant_type
0120 //
0121 template<typename Matcher>
0122 struct quant_type
0123   : mpl::int_<Matcher::quant>
0124 {
0125 };
0126 
0127 }}} // namespace boost::xpressive::detail
0128 
0129 #endif