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;
37 #ifdef BOOST_HAS_ABI_HEADERS
38 # include BOOST_ABI_PREFIX
43 template <class charT>
44 struct c_regex_traits;
47 struct BOOST_REGEX_DECL c_regex_traits<char>
50 typedef char char_type;
51 typedef std::size_t size_type;
52 typedef std::string string_type;
54 typedef boost::uint32_t char_class_type;
56 static size_type length(const char_type* p)
58 return (std::strlen)(p);
61 char translate(char c) const
65 char translate_nocase(char c) const
67 return static_cast<char>((std::tolower)(static_cast<unsigned char>(c)));
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);
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);
76 static bool BOOST_REGEX_CALL isctype(char, char_class_type);
77 static int BOOST_REGEX_CALL value(char, int);
79 locale_type imbue(locale_type l)
81 locale_type getloc()const
82 { return locale_type(); }
85 // this type is not copyable:
86 c_regex_traits(const c_regex_traits&);
87 c_regex_traits& operator=(const c_regex_traits&);
90 #ifndef BOOST_NO_WREGEX
92 struct BOOST_REGEX_DECL c_regex_traits<wchar_t>
95 typedef wchar_t char_type;
96 typedef std::size_t size_type;
97 typedef std::wstring string_type;
99 typedef boost::uint32_t char_class_type;
101 static size_type length(const char_type* p)
103 return (std::wcslen)(p);
106 wchar_t translate(wchar_t c) const
110 wchar_t translate_nocase(wchar_t c) const
112 return (std::towlower)(c);
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);
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);
121 static bool BOOST_REGEX_CALL isctype(wchar_t, char_class_type);
122 static int BOOST_REGEX_CALL value(wchar_t, int);
124 locale_type imbue(locale_type l)
126 locale_type getloc()const
127 { return locale_type(); }
130 // this type is not copyable:
131 c_regex_traits(const c_regex_traits&);
132 c_regex_traits& operator=(const c_regex_traits&);
135 #ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
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).
141 struct BOOST_REGEX_DECL c_regex_traits<unsigned short>
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;
150 static size_type length(const char_type* p)
152 return (std::wcslen)((const wchar_t*)p);
155 unsigned short translate(unsigned short c) const
159 unsigned short translate_nocase(unsigned short c) const
161 return (std::towlower)((wchar_t)c);
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);
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);
170 static bool BOOST_REGEX_CALL isctype(unsigned short, char_class_type);
171 static int BOOST_REGEX_CALL value(unsigned short, int);
173 locale_type imbue(locale_type l)
175 locale_type getloc()const
176 { return locale_type(); }
179 // this type is not copyable:
180 c_regex_traits(const c_regex_traits&);
181 c_regex_traits& operator=(const c_regex_traits&);
186 #endif // BOOST_NO_WREGEX
190 #ifdef BOOST_HAS_ABI_HEADERS
191 # include BOOST_ABI_SUFFIX