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)
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.
19 #ifndef BOOST_C_REGEX_TRAITS_HPP_INCLUDED
20 #define BOOST_C_REGEX_TRAITS_HPP_INCLUDED
22 #ifndef BOOST_REGEX_CONFIG_HPP
23 #include <boost/regex/config.hpp>
25 #ifndef BOOST_REGEX_WORKAROUND_HPP
26 #include <boost/regex/v4/regex_workaround.hpp>
31 #ifdef BOOST_NO_STDC_NAMESPACE
33 using ::strlen; using ::tolower;
39 #pragma warning(disable: 4103)
41 #ifdef BOOST_HAS_ABI_HEADERS
42 # include BOOST_ABI_PREFIX
50 template <class charT>
51 struct c_regex_traits;
54 struct BOOST_REGEX_DECL c_regex_traits<char>
57 typedef char char_type;
58 typedef std::size_t size_type;
59 typedef std::string string_type;
61 typedef boost::uint32_t char_class_type;
63 static size_type length(const char_type* p)
65 return (std::strlen)(p);
68 char translate(char c) const
72 char translate_nocase(char c) const
74 return static_cast<char>((std::tolower)(static_cast<unsigned char>(c)));
77 static string_type BOOST_REGEX_CALL transform(const char* p1, const char* p2);
78 static string_type BOOST_REGEX_CALL transform_primary(const char* p1, const char* p2);
80 static char_class_type BOOST_REGEX_CALL lookup_classname(const char* p1, const char* p2);
81 static string_type BOOST_REGEX_CALL lookup_collatename(const char* p1, const char* p2);
83 static bool BOOST_REGEX_CALL isctype(char, char_class_type);
84 static int BOOST_REGEX_CALL value(char, int);
86 locale_type imbue(locale_type l)
88 locale_type getloc()const
89 { return locale_type(); }
92 // this type is not copyable:
93 c_regex_traits(const c_regex_traits&);
94 c_regex_traits& operator=(const c_regex_traits&);
97 #ifndef BOOST_NO_WREGEX
99 struct BOOST_REGEX_DECL c_regex_traits<wchar_t>
102 typedef wchar_t char_type;
103 typedef std::size_t size_type;
104 typedef std::wstring string_type;
105 struct locale_type{};
106 typedef boost::uint32_t char_class_type;
108 static size_type length(const char_type* p)
110 return (std::wcslen)(p);
113 wchar_t translate(wchar_t c) const
117 wchar_t translate_nocase(wchar_t c) const
119 return (std::towlower)(c);
122 static string_type BOOST_REGEX_CALL transform(const wchar_t* p1, const wchar_t* p2);
123 static string_type BOOST_REGEX_CALL transform_primary(const wchar_t* p1, const wchar_t* p2);
125 static char_class_type BOOST_REGEX_CALL lookup_classname(const wchar_t* p1, const wchar_t* p2);
126 static string_type BOOST_REGEX_CALL lookup_collatename(const wchar_t* p1, const wchar_t* p2);
128 static bool BOOST_REGEX_CALL isctype(wchar_t, char_class_type);
129 static int BOOST_REGEX_CALL value(wchar_t, int);
131 locale_type imbue(locale_type l)
133 locale_type getloc()const
134 { return locale_type(); }
137 // this type is not copyable:
138 c_regex_traits(const c_regex_traits&);
139 c_regex_traits& operator=(const c_regex_traits&);
142 #ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
144 // Provide an unsigned short version as well, so the user can link to this
145 // no matter whether they build with /Zc:wchar_t or not (MSVC specific).
148 struct BOOST_REGEX_DECL c_regex_traits<unsigned short>
151 typedef unsigned short char_type;
152 typedef std::size_t size_type;
153 typedef std::basic_string<unsigned short> string_type;
154 struct locale_type{};
155 typedef boost::uint32_t char_class_type;
157 static size_type length(const char_type* p)
159 return (std::wcslen)((const wchar_t*)p);
162 unsigned short translate(unsigned short c) const
166 unsigned short translate_nocase(unsigned short c) const
168 return (std::towlower)((wchar_t)c);
171 static string_type BOOST_REGEX_CALL transform(const unsigned short* p1, const unsigned short* p2);
172 static string_type BOOST_REGEX_CALL transform_primary(const unsigned short* p1, const unsigned short* p2);
174 static char_class_type BOOST_REGEX_CALL lookup_classname(const unsigned short* p1, const unsigned short* p2);
175 static string_type BOOST_REGEX_CALL lookup_collatename(const unsigned short* p1, const unsigned short* p2);
177 static bool BOOST_REGEX_CALL isctype(unsigned short, char_class_type);
178 static int BOOST_REGEX_CALL value(unsigned short, int);
180 locale_type imbue(locale_type l)
182 locale_type getloc()const
183 { return locale_type(); }
186 // this type is not copyable:
187 c_regex_traits(const c_regex_traits&);
188 c_regex_traits& operator=(const c_regex_traits&);
193 #endif // BOOST_NO_WREGEX
198 #pragma warning(push)
199 #pragma warning(disable: 4103)
201 #ifdef BOOST_HAS_ABI_HEADERS
202 # include BOOST_ABI_SUFFIX