1 ///////////////////////////////////////////////////////////////////////////////
2 /// \file regex_traits.hpp
3 /// Includes the C regex traits or the CPP regex traits header file depending on the
4 /// BOOST_XPRESSIVE_USE_C_TRAITS macro.
6 // Copyright 2008 Eric Niebler. Distributed under the Boost
7 // Software License, Version 1.0. (See accompanying file
8 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 #ifndef BOOST_XPRESSIVE_REGEX_TRAITS_HPP_EAN_10_04_2005
11 #define BOOST_XPRESSIVE_REGEX_TRAITS_HPP_EAN_10_04_2005
13 // MS compatible compilers support #pragma once
18 #include <boost/type_traits/is_convertible.hpp>
19 #include <boost/xpressive/detail/detail_fwd.hpp>
21 #ifdef BOOST_XPRESSIVE_USE_C_TRAITS
22 # include <boost/xpressive/traits/c_regex_traits.hpp>
24 # include <boost/xpressive/traits/cpp_regex_traits.hpp>
27 namespace boost { namespace xpressive
30 ///////////////////////////////////////////////////////////////////////////////
31 // regex_traits_version_1_tag
32 /// Tag used to denote that a traits class conforms to the version 1 traits
34 struct regex_traits_version_1_tag
38 ///////////////////////////////////////////////////////////////////////////////
39 // regex_traits_version_2_tag
40 /// Tag used to denote that a traits class conforms to the version 2 traits
42 struct regex_traits_version_2_tag
43 : regex_traits_version_1_tag
47 ///////////////////////////////////////////////////////////////////////////////
48 // regex_traits_version_1_case_fold_tag DEPRECATED use has_fold_case trait
51 struct regex_traits_version_1_case_fold_tag
52 : regex_traits_version_1_tag
56 ///////////////////////////////////////////////////////////////////////////////
58 /// Trait used to denote that a traits class has the fold_case member function.
59 template<typename Traits>
62 typename Traits::version_tag *
63 , regex_traits_version_1_case_fold_tag *
68 ///////////////////////////////////////////////////////////////////////////////
70 /// Thin wrapper around the default regex_traits implementation, either
71 /// cpp_regex_traits or c_regex_traits
73 template<typename Char, typename Impl>
77 typedef typename Impl::locale_type locale_type;
84 explicit regex_traits(locale_type const &loc)
90 ///////////////////////////////////////////////////////////////////////////////
93 template<typename Traits, std::size_t N>
94 inline typename Traits::char_class_type
95 lookup_classname(Traits const &traits, char const (&cname)[N], bool icase)
97 typename Traits::char_type name[N] = {0};
98 for(std::size_t j = 0; j < N-1; ++j)
100 name[j] = traits.widen(cname[j]);
102 return traits.lookup_classname(name, name + N - 1, icase);