| 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. | 
|---|
| 5 | // | 
|---|
| 6 | //  Copyright 2004 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) | 
|---|
| 9 |  | 
|---|
| 10 | #ifndef BOOST_XPRESSIVE_REGEX_TRAITS_HPP_EAN_10_04_2005 | 
|---|
| 11 | #define BOOST_XPRESSIVE_REGEX_TRAITS_HPP_EAN_10_04_2005 | 
|---|
| 12 |  | 
|---|
| 13 | // MS compatible compilers support #pragma once | 
|---|
| 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) | 
|---|
| 15 | # pragma once | 
|---|
| 16 | #endif | 
|---|
| 17 |  | 
|---|
| 18 | #include <boost/xpressive/detail/detail_fwd.hpp> | 
|---|
| 19 |  | 
|---|
| 20 | #ifdef BOOST_XPRESSIVE_USE_C_TRAITS | 
|---|
| 21 | # include <boost/xpressive/traits/c_regex_traits.hpp> | 
|---|
| 22 | #else | 
|---|
| 23 | # include <boost/xpressive/traits/cpp_regex_traits.hpp> | 
|---|
| 24 | #endif | 
|---|
| 25 |  | 
|---|
| 26 | namespace boost { namespace xpressive | 
|---|
| 27 | { | 
|---|
| 28 |  | 
|---|
| 29 | /////////////////////////////////////////////////////////////////////////////// | 
|---|
| 30 | // regex_traits_version_1_tag | 
|---|
| 31 | /// Tag used to denote that a traits class conforms to the version 1 traits | 
|---|
| 32 | /// interface. | 
|---|
| 33 | struct regex_traits_version_1_tag | 
|---|
| 34 | { | 
|---|
| 35 | }; | 
|---|
| 36 |  | 
|---|
| 37 | /////////////////////////////////////////////////////////////////////////////// | 
|---|
| 38 | // regex_traits_version_1_case_fold_tag | 
|---|
| 39 | /// Tag used to denote that a traits class has the fold_case member function. | 
|---|
| 40 | struct regex_traits_version_1_case_fold_tag | 
|---|
| 41 |   : regex_traits_version_1_tag | 
|---|
| 42 | { | 
|---|
| 43 | }; | 
|---|
| 44 |  | 
|---|
| 45 | /////////////////////////////////////////////////////////////////////////////// | 
|---|
| 46 | // regex_traits | 
|---|
| 47 | /// Thin wrapper around the default regex_traits implementation, either | 
|---|
| 48 | /// cpp_regex_traits or c_regex_traits | 
|---|
| 49 | /// | 
|---|
| 50 | template<typename Char, typename Impl> | 
|---|
| 51 | struct regex_traits | 
|---|
| 52 |   : Impl | 
|---|
| 53 | { | 
|---|
| 54 |     typedef typename Impl::locale_type locale_type; | 
|---|
| 55 |  | 
|---|
| 56 |     regex_traits() | 
|---|
| 57 |       : Impl() | 
|---|
| 58 |     { | 
|---|
| 59 |     } | 
|---|
| 60 |  | 
|---|
| 61 |     explicit regex_traits(locale_type const &loc) | 
|---|
| 62 |       : Impl(loc) | 
|---|
| 63 |     { | 
|---|
| 64 |     } | 
|---|
| 65 | }; | 
|---|
| 66 |  | 
|---|
| 67 | /////////////////////////////////////////////////////////////////////////////// | 
|---|
| 68 | // lookup_classname | 
|---|
| 69 | /// INTERNAL ONLY | 
|---|
| 70 | template<typename Traits, std::size_t N> | 
|---|
| 71 | inline typename Traits::char_class_type | 
|---|
| 72 | lookup_classname(Traits const &traits, char const (&cname)[N], bool icase) | 
|---|
| 73 | { | 
|---|
| 74 |     typename Traits::char_type name[N] = {0}; | 
|---|
| 75 |     for(std::size_t j = 0; j < N-1; ++j) | 
|---|
| 76 |     { | 
|---|
| 77 |         name[j] = traits.widen(cname[j]); | 
|---|
| 78 |     } | 
|---|
| 79 |     return traits.lookup_classname(name, name + N - 1, icase); | 
|---|
| 80 | } | 
|---|
| 81 |  | 
|---|
| 82 | }} | 
|---|
| 83 |  | 
|---|
| 84 | #endif | 
|---|