1 | /*
|
---|
2 | *
|
---|
3 | * Copyright (c) 2004
|
---|
4 | * John Maddock
|
---|
5 | *
|
---|
6 | * Use, modification and distribution are subject to the
|
---|
7 | * Boost 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 | */
|
---|
11 |
|
---|
12 | /*
|
---|
13 | * LOCATION: see http://www.boost.org for most recent version.
|
---|
14 | * FILE c_regex_traits.hpp
|
---|
15 | * VERSION see <boost/version.hpp>
|
---|
16 | * DESCRIPTION: Declares regular expression traits class that wraps the global C locale.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef BOOST_C_REGEX_TRAITS_HPP_INCLUDED
|
---|
20 | #define BOOST_C_REGEX_TRAITS_HPP_INCLUDED
|
---|
21 |
|
---|
22 | #ifndef BOOST_REGEX_CONFIG_HPP
|
---|
23 | #include <boost/regex/config.hpp>
|
---|
24 | #endif
|
---|
25 | #ifndef BOOST_REGEX_WORKAROUND_HPP
|
---|
26 | #include <boost/regex/v4/regex_workaround.hpp>
|
---|
27 | #endif
|
---|
28 |
|
---|
29 | #include <cctype>
|
---|
30 |
|
---|
31 | #ifdef BOOST_NO_STDC_NAMESPACE
|
---|
32 | namespace std{
|
---|
33 | using ::strlen; using ::tolower;
|
---|
34 | }
|
---|
35 | #endif
|
---|
36 |
|
---|
37 | #ifdef BOOST_HAS_ABI_HEADERS
|
---|
38 | # include BOOST_ABI_PREFIX
|
---|
39 | #endif
|
---|
40 |
|
---|
41 | namespace boost{
|
---|
42 |
|
---|
43 | template <class charT>
|
---|
44 | struct c_regex_traits;
|
---|
45 |
|
---|
46 | template<>
|
---|
47 | struct BOOST_REGEX_DECL c_regex_traits<char>
|
---|
48 | {
|
---|
49 | c_regex_traits(){}
|
---|
50 | typedef char char_type;
|
---|
51 | typedef std::size_t size_type;
|
---|
52 | typedef std::string string_type;
|
---|
53 | struct locale_type{};
|
---|
54 | typedef boost::uint32_t char_class_type;
|
---|
55 |
|
---|
56 | static size_type length(const char_type* p)
|
---|
57 | {
|
---|
58 | return (std::strlen)(p);
|
---|
59 | }
|
---|
60 |
|
---|
61 | char translate(char c) const
|
---|
62 | {
|
---|
63 | return c;
|
---|
64 | }
|
---|
65 | char translate_nocase(char c) const
|
---|
66 | {
|
---|
67 | return static_cast<char>((std::tolower)(static_cast<unsigned char>(c)));
|
---|
68 | }
|
---|
69 |
|
---|
70 | static string_type BOOST_REGEX_CALL transform(const char* p1, const char* p2);
|
---|
71 | static string_type BOOST_REGEX_CALL transform_primary(const char* p1, const char* p2);
|
---|
72 |
|
---|
73 | static char_class_type BOOST_REGEX_CALL lookup_classname(const char* p1, const char* p2);
|
---|
74 | static string_type BOOST_REGEX_CALL lookup_collatename(const char* p1, const char* p2);
|
---|
75 |
|
---|
76 | static bool BOOST_REGEX_CALL isctype(char, char_class_type);
|
---|
77 | static int BOOST_REGEX_CALL value(char, int);
|
---|
78 |
|
---|
79 | locale_type imbue(locale_type l)
|
---|
80 | { return l; }
|
---|
81 | locale_type getloc()const
|
---|
82 | { return locale_type(); }
|
---|
83 |
|
---|
84 | private:
|
---|
85 | // this type is not copyable:
|
---|
86 | c_regex_traits(const c_regex_traits&);
|
---|
87 | c_regex_traits& operator=(const c_regex_traits&);
|
---|
88 | };
|
---|
89 |
|
---|
90 | #ifndef BOOST_NO_WREGEX
|
---|
91 | template<>
|
---|
92 | struct BOOST_REGEX_DECL c_regex_traits<wchar_t>
|
---|
93 | {
|
---|
94 | c_regex_traits(){}
|
---|
95 | typedef wchar_t char_type;
|
---|
96 | typedef std::size_t size_type;
|
---|
97 | typedef std::wstring string_type;
|
---|
98 | struct locale_type{};
|
---|
99 | typedef boost::uint32_t char_class_type;
|
---|
100 |
|
---|
101 | static size_type length(const char_type* p)
|
---|
102 | {
|
---|
103 | return (std::wcslen)(p);
|
---|
104 | }
|
---|
105 |
|
---|
106 | wchar_t translate(wchar_t c) const
|
---|
107 | {
|
---|
108 | return c;
|
---|
109 | }
|
---|
110 | wchar_t translate_nocase(wchar_t c) const
|
---|
111 | {
|
---|
112 | return (std::towlower)(c);
|
---|
113 | }
|
---|
114 |
|
---|
115 | static string_type BOOST_REGEX_CALL transform(const wchar_t* p1, const wchar_t* p2);
|
---|
116 | static string_type BOOST_REGEX_CALL transform_primary(const wchar_t* p1, const wchar_t* p2);
|
---|
117 |
|
---|
118 | static char_class_type BOOST_REGEX_CALL lookup_classname(const wchar_t* p1, const wchar_t* p2);
|
---|
119 | static string_type BOOST_REGEX_CALL lookup_collatename(const wchar_t* p1, const wchar_t* p2);
|
---|
120 |
|
---|
121 | static bool BOOST_REGEX_CALL isctype(wchar_t, char_class_type);
|
---|
122 | static int BOOST_REGEX_CALL value(wchar_t, int);
|
---|
123 |
|
---|
124 | locale_type imbue(locale_type l)
|
---|
125 | { return l; }
|
---|
126 | locale_type getloc()const
|
---|
127 | { return locale_type(); }
|
---|
128 |
|
---|
129 | private:
|
---|
130 | // this type is not copyable:
|
---|
131 | c_regex_traits(const c_regex_traits&);
|
---|
132 | c_regex_traits& operator=(const c_regex_traits&);
|
---|
133 | };
|
---|
134 |
|
---|
135 | #ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
|
---|
136 | //
|
---|
137 | // Provide an unsigned short version as well, so the user can link to this
|
---|
138 | // no matter whether they build with /Zc:wchar_t or not (MSVC specific).
|
---|
139 | //
|
---|
140 | template<>
|
---|
141 | struct BOOST_REGEX_DECL c_regex_traits<unsigned short>
|
---|
142 | {
|
---|
143 | c_regex_traits(){}
|
---|
144 | typedef unsigned short char_type;
|
---|
145 | typedef std::size_t size_type;
|
---|
146 | typedef std::basic_string<unsigned short> string_type;
|
---|
147 | struct locale_type{};
|
---|
148 | typedef boost::uint32_t char_class_type;
|
---|
149 |
|
---|
150 | static size_type length(const char_type* p)
|
---|
151 | {
|
---|
152 | return (std::wcslen)((const wchar_t*)p);
|
---|
153 | }
|
---|
154 |
|
---|
155 | unsigned short translate(unsigned short c) const
|
---|
156 | {
|
---|
157 | return c;
|
---|
158 | }
|
---|
159 | unsigned short translate_nocase(unsigned short c) const
|
---|
160 | {
|
---|
161 | return (std::towlower)((wchar_t)c);
|
---|
162 | }
|
---|
163 |
|
---|
164 | static string_type BOOST_REGEX_CALL transform(const unsigned short* p1, const unsigned short* p2);
|
---|
165 | static string_type BOOST_REGEX_CALL transform_primary(const unsigned short* p1, const unsigned short* p2);
|
---|
166 |
|
---|
167 | static char_class_type BOOST_REGEX_CALL lookup_classname(const unsigned short* p1, const unsigned short* p2);
|
---|
168 | static string_type BOOST_REGEX_CALL lookup_collatename(const unsigned short* p1, const unsigned short* p2);
|
---|
169 |
|
---|
170 | static bool BOOST_REGEX_CALL isctype(unsigned short, char_class_type);
|
---|
171 | static int BOOST_REGEX_CALL value(unsigned short, int);
|
---|
172 |
|
---|
173 | locale_type imbue(locale_type l)
|
---|
174 | { return l; }
|
---|
175 | locale_type getloc()const
|
---|
176 | { return locale_type(); }
|
---|
177 |
|
---|
178 | private:
|
---|
179 | // this type is not copyable:
|
---|
180 | c_regex_traits(const c_regex_traits&);
|
---|
181 | c_regex_traits& operator=(const c_regex_traits&);
|
---|
182 | };
|
---|
183 |
|
---|
184 | #endif
|
---|
185 |
|
---|
186 | #endif // BOOST_NO_WREGEX
|
---|
187 |
|
---|
188 | }
|
---|
189 |
|
---|
190 | #ifdef BOOST_HAS_ABI_HEADERS
|
---|
191 | # include BOOST_ABI_SUFFIX
|
---|
192 | #endif
|
---|
193 |
|
---|
194 | #endif
|
---|
195 |
|
---|
196 |
|
---|
197 |
|
---|