3 * Copyright (c) 1998-2009 John Maddock
4 * Copyright 2008 Eric Niebler.
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_format.hpp
15 * VERSION see <boost/version.hpp>
16 * DESCRIPTION: Provides formatting output routines for search and replace
17 * operations. Note this is an internal header file included
18 * by regex.hpp, do not include on its own.
21 #ifndef BOOST_REGEX_FORMAT_HPP
22 #define BOOST_REGEX_FORMAT_HPP
24 #include <boost/type_traits/is_pointer.hpp>
25 #include <boost/type_traits/is_function.hpp>
26 #include <boost/type_traits/is_class.hpp>
27 #include <boost/type_traits/is_same.hpp>
28 #include <boost/type_traits/is_convertible.hpp>
29 #include <boost/type_traits/remove_pointer.hpp>
30 #include <boost/type_traits/remove_cv.hpp>
31 #include <boost/mpl/if.hpp>
32 #include <boost/mpl/and.hpp>
33 #include <boost/mpl/not.hpp>
34 #ifndef BOOST_NO_SFINAE
35 #include <boost/mpl/has_xxx.hpp>
42 #pragma warning(disable: 4103)
44 #ifdef BOOST_HAS_ABI_HEADERS
45 # include BOOST_ABI_PREFIX
52 // Forward declaration:
54 template <class BidiIterator, class Allocator = BOOST_DEDUCED_TYPENAME std::vector<sub_match<BidiIterator> >::allocator_type >
60 // struct trivial_format_traits:
61 // defines minimum localisation support for formatting
62 // in the case that the actual regex traits is unavailable.
64 template <class charT>
65 struct trivial_format_traits
67 typedef charT char_type;
69 static std::ptrdiff_t length(const charT* p)
71 return global_length(p);
73 static charT tolower(charT c)
75 return ::boost::re_detail::global_lower(c);
77 static charT toupper(charT c)
79 return ::boost::re_detail::global_upper(c);
81 static int value(const charT c, int radix)
83 int result = global_value(c);
84 return result >= radix ? -1 : result;
86 int toi(const charT*& p1, const charT* p2, int radix)const
88 return global_toi(p1, p2, radix, *this);
92 template <class OutputIterator, class Results, class traits, class ForwardIter>
93 class basic_regex_formatter
96 typedef typename traits::char_type char_type;
97 basic_regex_formatter(OutputIterator o, const Results& r, const traits& t)
98 : m_traits(t), m_results(r), m_out(o), m_state(output_copy), m_restore_state(output_copy), m_have_conditional(false) {}
99 OutputIterator format(ForwardIter p1, ForwardIter p2, match_flag_type f);
100 OutputIterator format(ForwardIter p1, match_flag_type f)
102 return format(p1, p1 + m_traits.length(p1), f);
105 typedef typename Results::value_type sub_match_type;
116 void put(char_type c);
117 void put(const sub_match_type& sub);
120 void format_escape();
121 void format_conditional();
122 void format_until_scope_end();
123 bool handle_perl_verb(bool have_brace);
125 inline typename Results::value_type const& get_named_sub(ForwardIter i, ForwardIter j, const mpl::false_&)
127 std::vector<char_type> v(i, j);
128 return (i != j) ? this->m_results.named_subexpression(&v[0], &v[0] + v.size())
129 : this->m_results.named_subexpression(static_cast<const char_type*>(0), static_cast<const char_type*>(0));
131 inline typename Results::value_type const& get_named_sub(ForwardIter i, ForwardIter j, const mpl::true_&)
133 return this->m_results.named_subexpression(i, j);
135 inline typename Results::value_type const& get_named_sub(ForwardIter i, ForwardIter j)
137 typedef typename boost::is_convertible<ForwardIter, const char_type*>::type tag_type;
138 return get_named_sub(i, j, tag_type());
140 inline int get_named_sub_index(ForwardIter i, ForwardIter j, const mpl::false_&)
142 std::vector<char_type> v(i, j);
143 return (i != j) ? this->m_results.named_subexpression_index(&v[0], &v[0] + v.size())
144 : this->m_results.named_subexpression_index(static_cast<const char_type*>(0), static_cast<const char_type*>(0));
146 inline int get_named_sub_index(ForwardIter i, ForwardIter j, const mpl::true_&)
148 return this->m_results.named_subexpression_index(i, j);
150 inline int get_named_sub_index(ForwardIter i, ForwardIter j)
152 typedef typename boost::is_convertible<ForwardIter, const char_type*>::type tag_type;
153 return get_named_sub_index(i, j, tag_type());
155 inline int toi(ForwardIter& i, ForwardIter j, int base, const boost::mpl::false_&)
159 std::vector<char_type> v(i, j);
160 const char_type* start = &v[0];
161 const char_type* pos = start;
162 int r = m_traits.toi(pos, &v[0] + v.size(), base);
163 std::advance(i, pos - start);
168 inline int toi(ForwardIter& i, ForwardIter j, int base, const boost::mpl::true_&)
170 return m_traits.toi(i, j, base);
172 inline int toi(ForwardIter& i, ForwardIter j, int base)
174 typedef typename boost::is_convertible<ForwardIter, const char_type*&>::type tag_type;
175 return toi(i, j, base, tag_type());
178 const traits& m_traits; // the traits class for localised formatting operations
179 const Results& m_results; // the match_results being used.
180 OutputIterator m_out; // where to send output.
181 ForwardIter m_position; // format string, current position
182 ForwardIter m_end; // format string end
183 match_flag_type m_flags; // format flags to use
184 output_state m_state; // what to do with the next character
185 output_state m_restore_state; // what state to restore to.
186 bool m_have_conditional; // we are parsing a conditional
188 basic_regex_formatter(const basic_regex_formatter&);
189 basic_regex_formatter& operator=(const basic_regex_formatter&);
192 template <class OutputIterator, class Results, class traits, class ForwardIter>
193 OutputIterator basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format(ForwardIter p1, ForwardIter p2, match_flag_type f)
202 template <class OutputIterator, class Results, class traits, class ForwardIter>
203 void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format_all()
206 while(m_position != m_end)
211 if(m_flags & ::boost::regex_constants::format_sed)
223 if(m_flags & boost::regex_constants::format_all)
226 bool have_conditional = m_have_conditional;
227 m_have_conditional = false;
228 format_until_scope_end();
229 m_have_conditional = have_conditional;
230 if(m_position == m_end)
232 BOOST_ASSERT(*m_position == static_cast<char_type>(')'));
233 ++m_position; // skip the closing ')'
240 if(m_flags & boost::regex_constants::format_all)
248 if((m_flags & boost::regex_constants::format_all) && m_have_conditional)
256 if(m_flags & boost::regex_constants::format_all)
259 format_conditional();
266 if((m_flags & format_sed) == 0)
271 // fall through, not a special character:
280 template <class OutputIterator, class Results, class traits, class ForwardIter>
281 void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format_perl()
284 // On entry *m_position points to a '$' character
285 // output the information that goes with it:
287 BOOST_ASSERT(*m_position == '$');
289 // see if this is a trailing '$':
291 if(++m_position == m_end)
299 // OK find out what kind it is:
301 bool have_brace = false;
302 ForwardIter save_position = m_position;
307 put(this->m_results[0]);
311 put(this->m_results.prefix());
315 put(this->m_results.suffix());
321 if((++m_position != m_end) && (*m_position == '{'))
323 ForwardIter base = ++m_position;
324 while((m_position != m_end) && (*m_position != '}')) ++m_position;
325 if(m_position != m_end)
327 // Named sub-expression:
328 put(get_named_sub(base, m_position));
337 put((this->m_results)[this->m_results.size() > 1 ? this->m_results.size() - 1 : 1]);
344 // see if we have a number:
346 std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end);
347 //len = (std::min)(static_cast<std::ptrdiff_t>(2), len);
348 int v = this->toi(m_position, m_position + len, 10);
349 if((v < 0) || (have_brace && ((m_position == m_end) || (*m_position != '}'))))
351 // Look for a Perl-5.10 verb:
352 if(!handle_perl_verb(have_brace))
354 // leave the $ as is, and carry on:
355 m_position = --save_position;
361 // otherwise output sub v:
362 put(this->m_results[v]);
369 template <class OutputIterator, class Results, class traits, class ForwardIter>
370 bool basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::handle_perl_verb(bool have_brace)
373 // We may have a capitalised string containing a Perl action:
375 static const char_type MATCH[] = { 'M', 'A', 'T', 'C', 'H' };
376 static const char_type PREMATCH[] = { 'P', 'R', 'E', 'M', 'A', 'T', 'C', 'H' };
377 static const char_type POSTMATCH[] = { 'P', 'O', 'S', 'T', 'M', 'A', 'T', 'C', 'H' };
378 static const char_type LAST_PAREN_MATCH[] = { 'L', 'A', 'S', 'T', '_', 'P', 'A', 'R', 'E', 'N', '_', 'M', 'A', 'T', 'C', 'H' };
379 static const char_type LAST_SUBMATCH_RESULT[] = { 'L', 'A', 'S', 'T', '_', 'S', 'U', 'B', 'M', 'A', 'T', 'C', 'H', '_', 'R', 'E', 'S', 'U', 'L', 'T' };
380 static const char_type LAST_SUBMATCH_RESULT_ALT[] = { '^', 'N' };
382 if(m_position == m_end)
384 if(have_brace && (*m_position == '^'))
387 int max_len = m_end - m_position;
389 if((max_len >= 5) && std::equal(m_position, m_position + 5, MATCH))
394 if((m_position != m_end) && (*m_position == '}'))
402 put(this->m_results[0]);
405 if((max_len >= 8) && std::equal(m_position, m_position + 8, PREMATCH))
410 if((m_position != m_end) && (*m_position == '}'))
418 put(this->m_results.prefix());
421 if((max_len >= 9) && std::equal(m_position, m_position + 9, POSTMATCH))
426 if((m_position != m_end) && (*m_position == '}'))
434 put(this->m_results.suffix());
437 if((max_len >= 16) && std::equal(m_position, m_position + 16, LAST_PAREN_MATCH))
442 if((m_position != m_end) && (*m_position == '}'))
450 put((this->m_results)[this->m_results.size() > 1 ? this->m_results.size() - 1 : 1]);
453 if((max_len >= 20) && std::equal(m_position, m_position + 20, LAST_SUBMATCH_RESULT))
458 if((m_position != m_end) && (*m_position == '}'))
466 put(this->m_results.get_last_closed_paren());
469 if((max_len >= 2) && std::equal(m_position, m_position + 2, LAST_SUBMATCH_RESULT_ALT))
474 if((m_position != m_end) && (*m_position == '}'))
482 put(this->m_results.get_last_closed_paren());
488 template <class OutputIterator, class Results, class traits, class ForwardIter>
489 void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format_escape()
491 // skip the escape and check for trailing escape:
492 if(++m_position == m_end)
494 put(static_cast<char_type>('\\'));
497 // now switch on the escape type:
501 put(static_cast<char_type>('\a'));
505 put(static_cast<char_type>('\f'));
509 put(static_cast<char_type>('\n'));
513 put(static_cast<char_type>('\r'));
517 put(static_cast<char_type>('\t'));
521 put(static_cast<char_type>('\v'));
525 if(++m_position == m_end)
527 put(static_cast<char_type>('x'));
530 // maybe have \x{ddd}
531 if(*m_position == static_cast<char_type>('{'))
534 int val = this->toi(m_position, m_end, 16);
537 // invalid value treat everything as literals:
538 put(static_cast<char_type>('x'));
539 put(static_cast<char_type>('{'));
542 if((m_position == m_end) || (*m_position != static_cast<char_type>('}')))
545 while(*m_position != static_cast<char_type>('\\'))
552 put(static_cast<char_type>(val));
557 std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end);
558 len = (std::min)(static_cast<std::ptrdiff_t>(2), len);
559 int val = this->toi(m_position, m_position + len, 16);
566 put(static_cast<char_type>(val));
570 if(++m_position == m_end)
576 put(static_cast<char_type>(*m_position++ % 32));
579 put(static_cast<char_type>(27));
583 // see if we have a perl specific escape:
584 if((m_flags & boost::regex_constants::format_sed) == 0)
586 bool breakout = false;
591 m_restore_state = m_state;
592 m_state = output_next_lower;
597 m_state = output_lower;
602 m_restore_state = m_state;
603 m_state = output_next_upper;
608 m_state = output_upper;
613 m_state = output_copy;
620 // see if we have a \n sed style backreference:
621 std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end);
622 len = (std::min)(static_cast<std::ptrdiff_t>(1), len);
623 int v = this->toi(m_position, m_position+len, 10);
624 if((v > 0) || ((v == 0) && (m_flags & ::boost::regex_constants::format_sed)))
631 // octal ecape sequence:
633 len = ::boost::re_detail::distance(m_position, m_end);
634 len = (std::min)(static_cast<std::ptrdiff_t>(4), len);
635 v = this->toi(m_position, m_position + len, 8);
636 BOOST_ASSERT(v >= 0);
637 put(static_cast<char_type>(v));
640 // Otherwise output the character "as is":
646 template <class OutputIterator, class Results, class traits, class ForwardIter>
647 void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format_conditional()
649 if(m_position == m_end)
651 // oops trailing '?':
652 put(static_cast<char_type>('?'));
656 if(*m_position == '{')
658 ForwardIter base = m_position;
660 v = this->toi(m_position, m_end, 10);
663 // Try a named subexpression:
664 while((m_position != m_end) && (*m_position != '}'))
666 v = this->get_named_sub_index(base + 1, m_position);
668 if((v < 0) || (*m_position != '}'))
671 // oops trailing '?':
672 put(static_cast<char_type>('?'));
675 // Skip trailing '}':
680 std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end);
681 len = (std::min)(static_cast<std::ptrdiff_t>(2), len);
682 v = this->toi(m_position, m_position + len, 10);
686 // oops not a number:
687 put(static_cast<char_type>('?'));
691 // output varies depending upon whether sub-expression v matched or not:
692 if(m_results[v].matched)
694 m_have_conditional = true;
696 m_have_conditional = false;
697 if((m_position != m_end) && (*m_position == static_cast<char_type>(':')))
701 // save output state, then turn it off:
702 output_state saved_state = m_state;
703 m_state = output_none;
704 // format the rest of this scope:
705 format_until_scope_end();
706 // restore output state:
707 m_state = saved_state;
712 // save output state, then turn it off:
713 output_state saved_state = m_state;
714 m_state = output_none;
715 // format until ':' or ')':
716 m_have_conditional = true;
718 m_have_conditional = false;
720 m_state = saved_state;
721 if((m_position != m_end) && (*m_position == static_cast<char_type>(':')))
725 // format the rest of this scope:
726 format_until_scope_end();
731 template <class OutputIterator, class Results, class traits, class ForwardIter>
732 void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format_until_scope_end()
737 if((m_position == m_end) || (*m_position == static_cast<char_type>(')')))
740 }while(m_position != m_end);
743 template <class OutputIterator, class Results, class traits, class ForwardIter>
744 void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::put(char_type c)
746 // write a single character to output
747 // according to which case translation mode we are in:
748 switch(this->m_state)
752 case output_next_lower:
753 c = m_traits.tolower(c);
754 this->m_state = m_restore_state;
756 case output_next_upper:
757 c = m_traits.toupper(c);
758 this->m_state = m_restore_state;
761 c = m_traits.tolower(c);
764 c = m_traits.toupper(c);
773 template <class OutputIterator, class Results, class traits, class ForwardIter>
774 void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::put(const sub_match_type& sub)
776 typedef typename sub_match_type::iterator iterator_type;
777 iterator_type i = sub.first;
778 while(i != sub.second)
786 class string_out_iterator
787 #ifndef BOOST_NO_STD_ITERATOR
788 : public std::iterator<std::output_iterator_tag, typename S::value_type>
793 string_out_iterator(S& s) : out(&s) {}
794 string_out_iterator& operator++() { return *this; }
795 string_out_iterator& operator++(int) { return *this; }
796 string_out_iterator& operator*() { return *this; }
797 string_out_iterator& operator=(typename S::value_type v)
803 #ifdef BOOST_NO_STD_ITERATOR
804 typedef std::ptrdiff_t difference_type;
805 typedef typename S::value_type value_type;
806 typedef value_type* pointer;
807 typedef value_type& reference;
808 typedef std::output_iterator_tag iterator_category;
812 template <class OutputIterator, class Iterator, class Alloc, class ForwardIter, class traits>
813 OutputIterator regex_format_imp(OutputIterator out,
814 const match_results<Iterator, Alloc>& m,
815 ForwardIter p1, ForwardIter p2,
816 match_flag_type flags,
820 if(flags & regex_constants::format_literal)
822 return re_detail::copy(p1, p2, out);
825 re_detail::basic_regex_formatter<
827 match_results<Iterator, Alloc>,
828 traits, ForwardIter> f(out, m, t);
829 return f.format(p1, p2, flags);
832 #ifndef BOOST_NO_SFINAE
834 BOOST_MPL_HAS_XXX_TRAIT_DEF(const_iterator)
836 struct any_type { any_type(...); };
837 typedef char no_type;
838 typedef char (&unary_type)[2];
839 typedef char (&binary_type)[3];
840 typedef char (&ternary_type)[4];
842 no_type check_is_formatter(unary_type, binary_type, ternary_type);
844 unary_type check_is_formatter(T const &, binary_type, ternary_type);
846 binary_type check_is_formatter(unary_type, T const &, ternary_type);
847 template<typename T, typename U>
848 binary_type check_is_formatter(T const &, U const &, ternary_type);
850 ternary_type check_is_formatter(unary_type, binary_type, T const &);
851 template<typename T, typename U>
852 ternary_type check_is_formatter(T const &, binary_type, U const &);
853 template<typename T, typename U>
854 ternary_type check_is_formatter(unary_type, T const &, U const &);
855 template<typename T, typename U, typename V>
856 ternary_type check_is_formatter(T const &, U const &, V const &);
858 struct unary_binary_ternary
860 typedef unary_type (*unary_fun)(any_type);
861 typedef binary_type (*binary_fun)(any_type, any_type);
862 typedef ternary_type (*ternary_fun)(any_type, any_type, any_type);
863 operator unary_fun();
864 operator binary_fun();
865 operator ternary_fun();
868 template<typename Formatter, bool IsFunction = boost::is_function<Formatter>::value>
869 struct formatter_wrapper
871 , unary_binary_ternary
873 formatter_wrapper(){}
876 template<typename Formatter>
877 struct formatter_wrapper<Formatter, true>
878 : unary_binary_ternary
880 operator Formatter *();
883 template<typename Formatter>
884 struct formatter_wrapper<Formatter *, false>
885 : unary_binary_ternary
887 operator Formatter *();
890 template <class F, class M, class O>
891 struct format_traits_imp
895 // F must be a pointer, a function, or a class with a function call operator:
897 BOOST_STATIC_ASSERT((::boost::is_pointer<F>::value || ::boost::is_function<F>::value || ::boost::is_class<F>::value));
898 static formatter_wrapper<F> f;
901 static boost::regex_constants::match_flag_type flags;
903 BOOST_STATIC_CONSTANT(int, value = sizeof(check_is_formatter(f(m), f(m, out), f(m, out, flags))));
906 template <class F, class M, class O>
911 // Type is mpl::int_<N> where N is one of:
913 // 0 : F is a pointer to a presumably null-terminated string.
914 // 1 : F is a character-container such as a std::string.
915 // 2 : F is a Unary Functor.
916 // 3 : F is a Binary Functor.
917 // 4 : F is a Ternary Functor.
919 typedef typename boost::mpl::if_<
920 boost::mpl::and_<boost::is_pointer<F>, boost::mpl::not_<boost::is_function<typename boost::remove_pointer<F>::type> > >,
922 typename boost::mpl::if_<
923 has_const_iterator<F>,
925 boost::mpl::int_<format_traits_imp<F, M, O>::value>
929 // This static assertion will fail if the functor passed does not accept
930 // the same type of arguments passed.
932 BOOST_STATIC_ASSERT( boost::is_class<F>::value && !has_const_iterator<F>::value ? (type::value > 1) : true);
935 #else // BOOST_NO_SFINAE
937 template <class F, class M, class O>
942 // Type is mpl::int_<N> where N is one of:
944 // 0 : F is a pointer to a presumably null-terminated string.
945 // 1 : F is a character-container such as a std::string.
947 // Other options such as F being a Functor are not supported without
950 typedef typename boost::mpl::if_<
951 boost::is_pointer<F>,
957 #endif // BOOST_NO_SFINAE
959 template <class Base, class Match>
960 struct format_functor3
962 format_functor3(Base b) : func(b) {}
963 template <class OutputIter>
964 OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f)
966 return func(m, i, f);
968 template <class OutputIter, class Traits>
969 OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f, const Traits&)
971 return (*this)(m, i, f);
975 format_functor3(const format_functor3&);
976 format_functor3& operator=(const format_functor3&);
979 template <class Base, class Match>
980 struct format_functor2
982 format_functor2(Base b) : func(b) {}
983 template <class OutputIter>
984 OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type /*f*/)
988 template <class OutputIter, class Traits>
989 OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f, const Traits&)
991 return (*this)(m, i, f);
995 format_functor2(const format_functor2&);
996 format_functor2& operator=(const format_functor2&);
999 template <class Base, class Match>
1000 struct format_functor1
1002 format_functor1(Base b) : func(b) {}
1004 template <class S, class OutputIter>
1005 OutputIter do_format_string(const S& s, OutputIter i)
1007 return re_detail::copy(s.begin(), s.end(), i);
1009 template <class S, class OutputIter>
1010 inline OutputIter do_format_string(const S* s, OutputIter i)
1020 template <class OutputIter>
1021 OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type /*f*/)
1023 return do_format_string(func(m), i);
1025 template <class OutputIter, class Traits>
1026 OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f, const Traits&)
1028 return (*this)(m, i, f);
1032 format_functor1(const format_functor1&);
1033 format_functor1& operator=(const format_functor1&);
1036 template <class charT, class Match, class Traits>
1037 struct format_functor_c_string
1039 format_functor_c_string(const charT* ps) : func(ps) {}
1041 template <class OutputIter>
1042 OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f, const Traits& t = Traits())
1044 typedef typename Match::char_type char_type;
1045 const charT* end = func;
1047 return regex_format_imp(i, m, func, end, f, t);
1051 format_functor_c_string(const format_functor_c_string&);
1052 format_functor_c_string& operator=(const format_functor_c_string&);
1055 template <class Container, class Match, class Traits>
1056 struct format_functor_container
1058 format_functor_container(const Container& c) : func(c) {}
1060 template <class OutputIter>
1061 OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f, const Traits& t = Traits())
1063 typedef typename Match::char_type char_type;
1064 return re_detail::regex_format_imp(i, m, func.begin(), func.end(), f, t);
1067 const Container& func;
1068 format_functor_container(const format_functor_container&);
1069 format_functor_container& operator=(const format_functor_container&);
1072 template <class Func, class Match, class OutputIterator, class Traits = re_detail::trivial_format_traits<typename Match::char_type> >
1073 struct compute_functor_type
1075 typedef typename format_traits<Func, Match, OutputIterator>::type tag;
1076 typedef typename boost::remove_cv< typename boost::remove_pointer<Func>::type>::type maybe_char_type;
1078 typedef typename mpl::if_<
1079 ::boost::is_same<tag, mpl::int_<0> >, format_functor_c_string<maybe_char_type, Match, Traits>,
1081 ::boost::is_same<tag, mpl::int_<1> >, format_functor_container<Func, Match, Traits>,
1083 ::boost::is_same<tag, mpl::int_<2> >, format_functor1<Func, Match>,
1085 ::boost::is_same<tag, mpl::int_<3> >, format_functor2<Func, Match>,
1086 format_functor3<Func, Match>
1093 } // namespace re_detail
1095 template <class OutputIterator, class Iterator, class Allocator, class Functor>
1096 inline OutputIterator regex_format(OutputIterator out,
1097 const match_results<Iterator, Allocator>& m,
1099 match_flag_type flags = format_all
1102 return m.format(out, fmt, flags);
1105 template <class Iterator, class Allocator, class Functor>
1106 inline std::basic_string<typename match_results<Iterator, Allocator>::char_type> regex_format(const match_results<Iterator, Allocator>& m,
1108 match_flag_type flags = format_all)
1110 return m.format(fmt, flags);
1114 #pragma warning(push)
1115 #pragma warning(disable: 4103)
1117 #ifdef BOOST_HAS_ABI_HEADERS
1118 # include BOOST_ABI_SUFFIX
1121 #pragma warning(pop)
1124 } // namespace boost
1126 #endif // BOOST_REGEX_FORMAT_HPP