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 regex_traits.hpp
15 * VERSION see <boost/version.hpp>
16 * DESCRIPTION: Declares regular expression traits classes.
19 #ifndef BOOST_REGEX_TRAITS_HPP_INCLUDED
20 #define BOOST_REGEX_TRAITS_HPP_INCLUDED
22 #include <boost/regex/config.hpp>
23 #include <boost/regex/v5/regex_workaround.hpp>
24 #include <boost/regex/v5/syntax_type.hpp>
25 #include <boost/regex/v5/error_type.hpp>
26 #include <boost/regex/v5/regex_traits_defaults.hpp>
27 #include <boost/regex/v5/cpp_regex_traits.hpp>
28 #include <boost/regex/v5/c_regex_traits.hpp>
29 #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
30 # include <boost/regex/v5/w32_regex_traits.hpp>
32 #include <boost/regex_fwd.hpp>
36 template <class charT, class implementationT >
37 struct regex_traits : public implementationT
39 regex_traits() : implementationT() {}
43 // class regex_traits_wrapper.
44 // this is what our implementation will actually store;
45 // it provides default implementations of the "optional"
46 // interfaces that we support, in addition to the
47 // required "standard" ones:
49 namespace BOOST_REGEX_DETAIL_NS{
52 struct has_boost_extensions_tag
55 static double checker(U*, typename U::boost_extensions_tag* = nullptr);
56 static char checker(...);
59 static const bool value = sizeof(checker(get())) > 1;
63 template <class BaseT>
64 struct default_wrapper : public BaseT
66 typedef typename BaseT::char_type char_type;
67 std::string error_string(::boost::regex_constants::error_type e)const
69 return ::boost::BOOST_REGEX_DETAIL_NS::get_default_error_string(e);
71 ::boost::regex_constants::syntax_type syntax_type(char_type c)const
73 return (char_type(c & 0x7f) == c) ? get_default_syntax_type(static_cast<char>(c)) : ::boost::regex_constants::syntax_char;
75 ::boost::regex_constants::escape_syntax_type escape_syntax_type(char_type c)const
77 return (char_type(c & 0x7f) == c) ? get_default_escape_syntax_type(static_cast<char>(c)) : ::boost::regex_constants::escape_type_identity;
79 std::intmax_t toi(const char_type*& p1, const char_type* p2, int radix)const
81 return ::boost::BOOST_REGEX_DETAIL_NS::global_toi(p1, p2, radix, *this);
83 char_type translate(char_type c, bool icase)const
85 return (icase ? this->translate_nocase(c) : this->translate(c));
87 char_type translate(char_type c)const
89 return BaseT::translate(c);
91 char_type tolower(char_type c)const
93 return ::boost::BOOST_REGEX_DETAIL_NS::global_lower(c);
95 char_type toupper(char_type c)const
97 return ::boost::BOOST_REGEX_DETAIL_NS::global_upper(c);
101 template <class BaseT, bool has_extensions>
102 struct compute_wrapper_base
106 template <class BaseT>
107 struct compute_wrapper_base<BaseT, false>
109 typedef default_wrapper<BaseT> type;
112 } // namespace BOOST_REGEX_DETAIL_NS
114 template <class BaseT>
115 struct regex_traits_wrapper
116 : public ::boost::BOOST_REGEX_DETAIL_NS::compute_wrapper_base<
118 ::boost::BOOST_REGEX_DETAIL_NS::has_boost_extensions_tag<BaseT>::value
121 regex_traits_wrapper(){}
123 regex_traits_wrapper(const regex_traits_wrapper&);
124 regex_traits_wrapper& operator=(const regex_traits_wrapper&);