Back to home page

EIC code displayed by LXR

 
 

    


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

0001 ///////////////////////////////////////////////////////////////////////////////
0002 /// \file regex_traits.hpp
0003 /// Includes the C regex traits or the CPP regex traits header file depending on the
0004 /// BOOST_XPRESSIVE_USE_C_TRAITS macro.
0005 //
0006 //  Copyright 2008 Eric Niebler. Distributed under the Boost
0007 //  Software License, Version 1.0. (See accompanying file
0008 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 
0010 #ifndef BOOST_XPRESSIVE_REGEX_TRAITS_HPP_EAN_10_04_2005
0011 #define BOOST_XPRESSIVE_REGEX_TRAITS_HPP_EAN_10_04_2005
0012 
0013 // MS compatible compilers support #pragma once
0014 #if defined(_MSC_VER)
0015 # pragma once
0016 #endif
0017 
0018 #include <boost/type_traits/is_convertible.hpp>
0019 #include <boost/xpressive/detail/detail_fwd.hpp>
0020 
0021 #ifdef BOOST_XPRESSIVE_USE_C_TRAITS
0022 # include <boost/xpressive/traits/c_regex_traits.hpp>
0023 #else
0024 # include <boost/xpressive/traits/cpp_regex_traits.hpp>
0025 #endif
0026 
0027 namespace boost { namespace xpressive
0028 {
0029 
0030 ///////////////////////////////////////////////////////////////////////////////
0031 // regex_traits_version_1_tag
0032 /// Tag used to denote that a traits class conforms to the version 1 traits
0033 /// interface.
0034 struct regex_traits_version_1_tag
0035 {
0036 };
0037 
0038 ///////////////////////////////////////////////////////////////////////////////
0039 // regex_traits_version_2_tag
0040 /// Tag used to denote that a traits class conforms to the version 2 traits
0041 /// interface.
0042 struct regex_traits_version_2_tag
0043   : regex_traits_version_1_tag
0044 {
0045 };
0046 
0047 ///////////////////////////////////////////////////////////////////////////////
0048 // regex_traits_version_1_case_fold_tag DEPRECATED use has_fold_case trait
0049 /// INTERNAL ONLY
0050 ///
0051 struct regex_traits_version_1_case_fold_tag
0052   : regex_traits_version_1_tag
0053 {
0054 };
0055 
0056 ///////////////////////////////////////////////////////////////////////////////
0057 // has_fold_case
0058 /// Trait used to denote that a traits class has the fold_case member function.
0059 template<typename Traits>
0060 struct has_fold_case
0061   : is_convertible<
0062         typename Traits::version_tag *
0063       , regex_traits_version_1_case_fold_tag *
0064     >
0065 {
0066 };
0067 
0068 ///////////////////////////////////////////////////////////////////////////////
0069 // regex_traits
0070 /// Thin wrapper around the default regex_traits implementation, either
0071 /// cpp_regex_traits or c_regex_traits
0072 ///
0073 template<typename Char, typename Impl>
0074 struct regex_traits
0075   : Impl
0076 {
0077     typedef typename Impl::locale_type locale_type;
0078 
0079     regex_traits()
0080       : Impl()
0081     {
0082     }
0083 
0084     explicit regex_traits(locale_type const &loc)
0085       : Impl(loc)
0086     {
0087     }
0088 };
0089 
0090 ///////////////////////////////////////////////////////////////////////////////
0091 // lookup_classname
0092 /// INTERNAL ONLY
0093 template<typename Traits, std::size_t N>
0094 inline typename Traits::char_class_type
0095 lookup_classname(Traits const &traits, char const (&cname)[N], bool icase)
0096 {
0097     typename Traits::char_type name[N] = {0};
0098     for(std::size_t j = 0; j < N-1; ++j)
0099     {
0100         name[j] = traits.widen(cname[j]);
0101     }
0102     return traits.lookup_classname(name, name + N - 1, icase);
0103 }
0104 
0105 }}
0106 
0107 #endif