Chris@16
|
1 /*
|
Chris@16
|
2 *
|
Chris@16
|
3 * Copyright (c) 2003
|
Chris@16
|
4 * John Maddock
|
Chris@16
|
5 *
|
Chris@16
|
6 * Use, modification and distribution are subject to the
|
Chris@16
|
7 * Boost Software License, Version 1.0. (See accompanying file
|
Chris@16
|
8 * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
9 *
|
Chris@16
|
10 */
|
Chris@16
|
11
|
Chris@16
|
12 /*
|
Chris@16
|
13 * LOCATION: see http://www.boost.org for most recent version.
|
Chris@16
|
14 * FILE regex_traits.hpp
|
Chris@16
|
15 * VERSION see <boost/version.hpp>
|
Chris@16
|
16 * DESCRIPTION: Declares regular expression traits classes.
|
Chris@16
|
17 */
|
Chris@16
|
18
|
Chris@16
|
19 #ifndef BOOST_REGEX_TRAITS_HPP_INCLUDED
|
Chris@16
|
20 #define BOOST_REGEX_TRAITS_HPP_INCLUDED
|
Chris@16
|
21
|
Chris@16
|
22 #ifndef BOOST_REGEX_CONFIG_HPP
|
Chris@16
|
23 #include <boost/regex/config.hpp>
|
Chris@16
|
24 #endif
|
Chris@16
|
25 #ifndef BOOST_REGEX_WORKAROUND_HPP
|
Chris@16
|
26 #include <boost/regex/v4/regex_workaround.hpp>
|
Chris@16
|
27 #endif
|
Chris@16
|
28 #ifndef BOOST_REGEX_SYNTAX_TYPE_HPP
|
Chris@16
|
29 #include <boost/regex/v4/syntax_type.hpp>
|
Chris@16
|
30 #endif
|
Chris@16
|
31 #ifndef BOOST_REGEX_ERROR_TYPE_HPP
|
Chris@16
|
32 #include <boost/regex/v4/error_type.hpp>
|
Chris@16
|
33 #endif
|
Chris@16
|
34 #ifndef BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED
|
Chris@16
|
35 #include <boost/regex/v4/regex_traits_defaults.hpp>
|
Chris@16
|
36 #endif
|
Chris@16
|
37 #ifndef BOOST_NO_STD_LOCALE
|
Chris@16
|
38 # ifndef BOOST_CPP_REGEX_TRAITS_HPP_INCLUDED
|
Chris@16
|
39 # include <boost/regex/v4/cpp_regex_traits.hpp>
|
Chris@16
|
40 # endif
|
Chris@16
|
41 #endif
|
Chris@16
|
42 #if !BOOST_WORKAROUND(__BORLANDC__, < 0x560)
|
Chris@16
|
43 # ifndef BOOST_C_REGEX_TRAITS_HPP_INCLUDED
|
Chris@16
|
44 # include <boost/regex/v4/c_regex_traits.hpp>
|
Chris@16
|
45 # endif
|
Chris@16
|
46 #endif
|
Chris@16
|
47 #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
|
Chris@16
|
48 # ifndef BOOST_W32_REGEX_TRAITS_HPP_INCLUDED
|
Chris@16
|
49 # include <boost/regex/v4/w32_regex_traits.hpp>
|
Chris@16
|
50 # endif
|
Chris@16
|
51 #endif
|
Chris@16
|
52 #ifndef BOOST_REGEX_FWD_HPP_INCLUDED
|
Chris@16
|
53 #include <boost/regex_fwd.hpp>
|
Chris@16
|
54 #endif
|
Chris@16
|
55
|
Chris@16
|
56 #include "boost/mpl/has_xxx.hpp"
|
Chris@16
|
57 #include <boost/static_assert.hpp>
|
Chris@16
|
58
|
Chris@16
|
59 #ifdef BOOST_MSVC
|
Chris@16
|
60 #pragma warning(push)
|
Chris@16
|
61 #pragma warning(disable: 4103)
|
Chris@16
|
62 #endif
|
Chris@16
|
63 #ifdef BOOST_HAS_ABI_HEADERS
|
Chris@16
|
64 # include BOOST_ABI_PREFIX
|
Chris@16
|
65 #endif
|
Chris@16
|
66 #ifdef BOOST_MSVC
|
Chris@16
|
67 #pragma warning(pop)
|
Chris@16
|
68 #endif
|
Chris@16
|
69
|
Chris@16
|
70 namespace boost{
|
Chris@16
|
71
|
Chris@16
|
72 template <class charT, class implementationT >
|
Chris@16
|
73 struct regex_traits : public implementationT
|
Chris@16
|
74 {
|
Chris@16
|
75 regex_traits() : implementationT() {}
|
Chris@16
|
76 };
|
Chris@16
|
77
|
Chris@16
|
78 //
|
Chris@16
|
79 // class regex_traits_wrapper.
|
Chris@16
|
80 // this is what our implementation will actually store;
|
Chris@16
|
81 // it provides default implementations of the "optional"
|
Chris@16
|
82 // interfaces that we support, in addition to the
|
Chris@16
|
83 // required "standard" ones:
|
Chris@16
|
84 //
|
Chris@16
|
85 namespace re_detail{
|
Chris@101
|
86 #if !BOOST_WORKAROUND(__HP_aCC, < 60000)
|
Chris@16
|
87 BOOST_MPL_HAS_XXX_TRAIT_DEF(boost_extensions_tag)
|
Chris@16
|
88 #else
|
Chris@16
|
89 template<class T>
|
Chris@16
|
90 struct has_boost_extensions_tag
|
Chris@16
|
91 {
|
Chris@16
|
92 BOOST_STATIC_CONSTANT(bool, value = false);
|
Chris@16
|
93 };
|
Chris@16
|
94 #endif
|
Chris@16
|
95
|
Chris@16
|
96 template <class BaseT>
|
Chris@16
|
97 struct default_wrapper : public BaseT
|
Chris@16
|
98 {
|
Chris@16
|
99 typedef typename BaseT::char_type char_type;
|
Chris@16
|
100 std::string error_string(::boost::regex_constants::error_type e)const
|
Chris@16
|
101 {
|
Chris@16
|
102 return ::boost::re_detail::get_default_error_string(e);
|
Chris@16
|
103 }
|
Chris@16
|
104 ::boost::regex_constants::syntax_type syntax_type(char_type c)const
|
Chris@16
|
105 {
|
Chris@16
|
106 return ((c & 0x7f) == c) ? get_default_syntax_type(static_cast<char>(c)) : ::boost::regex_constants::syntax_char;
|
Chris@16
|
107 }
|
Chris@16
|
108 ::boost::regex_constants::escape_syntax_type escape_syntax_type(char_type c)const
|
Chris@16
|
109 {
|
Chris@16
|
110 return ((c & 0x7f) == c) ? get_default_escape_syntax_type(static_cast<char>(c)) : ::boost::regex_constants::escape_type_identity;
|
Chris@16
|
111 }
|
Chris@16
|
112 int toi(const char_type*& p1, const char_type* p2, int radix)const
|
Chris@16
|
113 {
|
Chris@16
|
114 return ::boost::re_detail::global_toi(p1, p2, radix, *this);
|
Chris@16
|
115 }
|
Chris@16
|
116 char_type translate(char_type c, bool icase)const
|
Chris@16
|
117 {
|
Chris@16
|
118 return (icase ? this->translate_nocase(c) : this->translate(c));
|
Chris@16
|
119 }
|
Chris@16
|
120 char_type translate(char_type c)const
|
Chris@16
|
121 {
|
Chris@16
|
122 return BaseT::translate(c);
|
Chris@16
|
123 }
|
Chris@16
|
124 char_type tolower(char_type c)const
|
Chris@16
|
125 {
|
Chris@16
|
126 return ::boost::re_detail::global_lower(c);
|
Chris@16
|
127 }
|
Chris@16
|
128 char_type toupper(char_type c)const
|
Chris@16
|
129 {
|
Chris@16
|
130 return ::boost::re_detail::global_upper(c);
|
Chris@16
|
131 }
|
Chris@16
|
132 };
|
Chris@16
|
133
|
Chris@16
|
134 template <class BaseT, bool has_extensions>
|
Chris@16
|
135 struct compute_wrapper_base
|
Chris@16
|
136 {
|
Chris@16
|
137 typedef BaseT type;
|
Chris@16
|
138 };
|
Chris@101
|
139 #if !BOOST_WORKAROUND(__HP_aCC, < 60000)
|
Chris@16
|
140 template <class BaseT>
|
Chris@16
|
141 struct compute_wrapper_base<BaseT, false>
|
Chris@16
|
142 {
|
Chris@16
|
143 typedef default_wrapper<BaseT> type;
|
Chris@16
|
144 };
|
Chris@16
|
145 #else
|
Chris@16
|
146 template <>
|
Chris@16
|
147 struct compute_wrapper_base<c_regex_traits<char>, false>
|
Chris@16
|
148 {
|
Chris@16
|
149 typedef default_wrapper<c_regex_traits<char> > type;
|
Chris@16
|
150 };
|
Chris@16
|
151 #ifndef BOOST_NO_WREGEX
|
Chris@16
|
152 template <>
|
Chris@16
|
153 struct compute_wrapper_base<c_regex_traits<wchar_t>, false>
|
Chris@16
|
154 {
|
Chris@16
|
155 typedef default_wrapper<c_regex_traits<wchar_t> > type;
|
Chris@16
|
156 };
|
Chris@16
|
157 #endif
|
Chris@16
|
158 #endif
|
Chris@16
|
159
|
Chris@16
|
160 } // namespace re_detail
|
Chris@16
|
161
|
Chris@16
|
162 template <class BaseT>
|
Chris@16
|
163 struct regex_traits_wrapper
|
Chris@16
|
164 : public ::boost::re_detail::compute_wrapper_base<
|
Chris@16
|
165 BaseT,
|
Chris@16
|
166 ::boost::re_detail::has_boost_extensions_tag<BaseT>::value
|
Chris@16
|
167 >::type
|
Chris@16
|
168 {
|
Chris@16
|
169 regex_traits_wrapper(){}
|
Chris@16
|
170 private:
|
Chris@16
|
171 regex_traits_wrapper(const regex_traits_wrapper&);
|
Chris@16
|
172 regex_traits_wrapper& operator=(const regex_traits_wrapper&);
|
Chris@16
|
173 };
|
Chris@16
|
174
|
Chris@16
|
175 } // namespace boost
|
Chris@16
|
176
|
Chris@16
|
177 #ifdef BOOST_MSVC
|
Chris@16
|
178 #pragma warning(push)
|
Chris@16
|
179 #pragma warning(disable: 4103)
|
Chris@16
|
180 #endif
|
Chris@16
|
181 #ifdef BOOST_HAS_ABI_HEADERS
|
Chris@16
|
182 # include BOOST_ABI_SUFFIX
|
Chris@16
|
183 #endif
|
Chris@16
|
184 #ifdef BOOST_MSVC
|
Chris@16
|
185 #pragma warning(pop)
|
Chris@16
|
186 #endif
|
Chris@16
|
187
|
Chris@16
|
188 #endif // include
|
Chris@16
|
189
|