/////////////////////////////////////////////////////////////////////////////// // transmogrify.hpp // // Copyright 2004 Eric Niebler. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_XPRESSIVE_DETAIL_STATIC_PRODUCTIONS_TRANSMOGRIFY_HPP_EAN_10_04_2005 #define BOOST_XPRESSIVE_DETAIL_STATIC_PRODUCTIONS_TRANSMOGRIFY_HPP_EAN_10_04_2005 // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif #include // for std::strlen #include #include #include #include #include #include #include #include namespace boost { namespace xpressive { namespace detail { /////////////////////////////////////////////////////////////////////////////// // transmogrify // template struct transmogrify { typedef Matcher type; static type const &call(Matcher const &m, dont_care) { return m; } }; template struct transmogrify { typedef assert_bol_matcher type; template static type call(assert_bol_placeholder, Visitor &visitor) { return type(visitor.traits()); } }; template struct transmogrify { typedef assert_eol_matcher type; template static type call(assert_eol_placeholder, Visitor &visitor) { return type(visitor.traits()); } }; template struct transmogrify { typedef logical_newline_matcher type; template static type call(logical_newline_placeholder, Visitor &visitor) { return type(visitor.traits()); } }; template struct transmogrify > { typedef typename iterator_value::type char_type; typedef literal_matcher type; template static type call(literal_placeholder const &m, Visitor &visitor) { char_type ch = char_cast(m.ch_, visitor.traits()); return type(ch, visitor.traits()); } }; template struct transmogrify > { // By design, we don't widen character ranges. typedef typename iterator_value::type char_type; BOOST_MPL_ASSERT((is_same)); typedef range_matcher type; template static type call(range_placeholder const &m, Visitor &visitor) { return type(m.ch_min_, m.ch_max_, m.not_, visitor.traits()); } }; template struct transmogrify > { typedef typename iterator_value::type char_type; typedef string_matcher type; template static type call(string_placeholder const &m, Visitor &visitor) { return type(string_cast(m.str_, visitor.traits()), visitor.traits()); } }; template struct transmogrify { typedef mark_matcher type; template static type call(mark_placeholder const &m, Visitor &visitor) { return type(m.mark_number_, visitor.traits()); } }; template struct transmogrify { typedef posix_charset_matcher type; template static type call(posix_charset_placeholder const &m, Visitor &visitor) { char const *name_end = m.name_ + std::strlen(m.name_); return type(visitor.traits().lookup_classname(m.name_, name_end, ICase::value), m.not_); } }; template struct transmogrify > { typedef set_matcher type; template static type call(set_matcher m, Visitor &visitor) { m.nocase(visitor.traits()); return m; } }; template struct transmogrify > { typedef assert_word_matcher type; template static type call(dont_care, Visitor &visitor) { return type(visitor.traits()); } }; template struct transmogrify > { typedef typename mpl::if_c < ByRef , regex_byref_matcher , regex_matcher >::type type; static type call(regex_placeholder const &m, dont_care) { return type(m.impl_); } }; template struct transmogrify { typedef regex_byref_matcher type; template static type call(self_placeholder, Visitor &visitor) { return type(visitor.self()); } }; }}} #endif