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>
37 #include <boost/ref.hpp>
43 #pragma warning(disable: 4103)
45 #ifdef BOOST_HAS_ABI_HEADERS
46 # include BOOST_ABI_PREFIX
53 // Forward declaration:
55 template <class BidiIterator, class Allocator = BOOST_DEDUCED_TYPENAME std::vector<sub_match<BidiIterator> >::allocator_type >
61 // struct trivial_format_traits:
62 // defines minimum localisation support for formatting
63 // in the case that the actual regex traits is unavailable.
65 template <class charT>
66 struct trivial_format_traits
68 typedef charT char_type;
70 static std::ptrdiff_t length(const charT* p)
72 return global_length(p);
74 static charT tolower(charT c)
76 return ::boost::re_detail::global_lower(c);
78 static charT toupper(charT c)
80 return ::boost::re_detail::global_upper(c);
82 static int value(const charT c, int radix)
84 int result = global_value(c);
85 return result >= radix ? -1 : result;
87 int toi(const charT*& p1, const charT* p2, int radix)const
89 return global_toi(p1, p2, radix, *this);
93 template <class OutputIterator, class Results, class traits, class ForwardIter>
94 class basic_regex_formatter
97 typedef typename traits::char_type char_type;
98 basic_regex_formatter(OutputIterator o, const Results& r, const traits& t)
99 : m_traits(t), m_results(r), m_out(o), m_state(output_copy), m_restore_state(output_copy), m_have_conditional(false) {}
100 OutputIterator format(ForwardIter p1, ForwardIter p2, match_flag_type f);
101 OutputIterator format(ForwardIter p1, match_flag_type f)
103 return format(p1, p1 + m_traits.length(p1), f);
106 typedef typename Results::value_type sub_match_type;
117 void put(char_type c);
118 void put(const sub_match_type& sub);
121 void format_escape();
122 void format_conditional();
123 void format_until_scope_end();
124 bool handle_perl_verb(bool have_brace);
126 inline typename Results::value_type const& get_named_sub(ForwardIter i, ForwardIter j, const mpl::false_&)
128 std::vector<char_type> v(i, j);
129 return (i != j) ? this->m_results.named_subexpression(&v[0], &v[0] + v.size())
130 : this->m_results.named_subexpression(static_cast<const char_type*>(0), static_cast<const char_type*>(0));
132 inline typename Results::value_type const& get_named_sub(ForwardIter i, ForwardIter j, const mpl::true_&)
134 return this->m_results.named_subexpression(i, j);
136 inline typename Results::value_type const& get_named_sub(ForwardIter i, ForwardIter j)
138 typedef typename boost::is_convertible<ForwardIter, const char_type*>::type tag_type;
139 return get_named_sub(i, j, tag_type());
141 inline int get_named_sub_index(ForwardIter i, ForwardIter j, const mpl::false_&)
143 std::vector<char_type> v(i, j);
144 return (i != j) ? this->m_results.named_subexpression_index(&v[0], &v[0] + v.size())
145 : this->m_results.named_subexpression_index(static_cast<const char_type*>(0), static_cast<const char_type*>(0));
147 inline int get_named_sub_index(ForwardIter i, ForwardIter j, const mpl::true_&)
149 return this->m_results.named_subexpression_index(i, j);
151 inline int get_named_sub_index(ForwardIter i, ForwardIter j)
153 typedef typename boost::is_convertible<ForwardIter, const char_type*>::type tag_type;
154 return get_named_sub_index(i, j, tag_type());
156 inline int toi(ForwardIter& i, ForwardIter j, int base, const boost::mpl::false_&)
160 std::vector<char_type> v(i, j);
161 const char_type* start = &v[0];
162 const char_type* pos = start;
163 int r = m_traits.toi(pos, &v[0] + v.size(), base);
164 std::advance(i, pos - start);
169 inline int toi(ForwardIter& i, ForwardIter j, int base, const boost::mpl::true_&)
171 return m_traits.toi(i, j, base);
173 inline int toi(ForwardIter& i, ForwardIter j, int base)
175 typedef typename boost::is_convertible<ForwardIter, const char_type*&>::type tag_type;
176 return toi(i, j, base, tag_type());
179 const traits& m_traits; // the traits class for localised formatting operations
180 const Results& m_results; // the match_results being used.
181 OutputIterator m_out; // where to send output.
182 ForwardIter m_position; // format string, current position
183 ForwardIter m_end; // format string end
184 match_flag_type m_flags; // format flags to use
185 output_state m_state; // what to do with the next character
186 output_state m_restore_state; // what state to restore to.
187 bool m_have_conditional; // we are parsing a conditional
189 basic_regex_formatter(const basic_regex_formatter&);
190 basic_regex_formatter& operator=(const basic_regex_formatter&);
193 template <class OutputIterator, class Results, class traits, class ForwardIter>
194 OutputIterator basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format(ForwardIter p1, ForwardIter p2, match_flag_type f)
203 template <class OutputIterator, class Results, class traits, class ForwardIter>
204 void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format_all()
207 while(m_position != m_end)
212 if(m_flags & ::boost::regex_constants::format_sed)
224 if(m_flags & boost::regex_constants::format_all)
227 bool have_conditional = m_have_conditional;
228 m_have_conditional = false;
229 format_until_scope_end();
230 m_have_conditional = have_conditional;
231 if(m_position == m_end)
233 BOOST_ASSERT(*m_position == static_cast<char_type>(')'));
234 ++m_position; // skip the closing ')'
241 if(m_flags & boost::regex_constants::format_all)
249 if((m_flags & boost::regex_constants::format_all) && m_have_conditional)
257 if(m_flags & boost::regex_constants::format_all)
260 format_conditional();
267 if((m_flags & format_sed) == 0)
272 // fall through, not a special character:
281 template <class OutputIterator, class Results, class traits, class ForwardIter>
282 void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format_perl()
285 // On entry *m_position points to a '$' character
286 // output the information that goes with it:
288 BOOST_ASSERT(*m_position == '$');
290 // see if this is a trailing '$':
292 if(++m_position == m_end)
300 // OK find out what kind it is:
302 bool have_brace = false;
303 ForwardIter save_position = m_position;
308 put(this->m_results[0]);
312 put(this->m_results.prefix());
316 put(this->m_results.suffix());
322 if((++m_position != m_end) && (*m_position == '{'))
324 ForwardIter base = ++m_position;
325 while((m_position != m_end) && (*m_position != '}')) ++m_position;
326 if(m_position != m_end)
328 // Named sub-expression:
329 put(get_named_sub(base, m_position));
338 put((this->m_results)[this->m_results.size() > 1 ? static_cast<int>(this->m_results.size() - 1) : 1]);
345 // see if we have a number:
347 std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end);
348 //len = (std::min)(static_cast<std::ptrdiff_t>(2), len);
349 int v = this->toi(m_position, m_position + len, 10);
350 if((v < 0) || (have_brace && ((m_position == m_end) || (*m_position != '}'))))
352 // Look for a Perl-5.10 verb:
353 if(!handle_perl_verb(have_brace))
355 // leave the $ as is, and carry on:
356 m_position = --save_position;
362 // otherwise output sub v:
363 put(this->m_results[v]);
370 template <class OutputIterator, class Results, class traits, class ForwardIter>
371 bool basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::handle_perl_verb(bool have_brace)
374 // We may have a capitalised string containing a Perl action:
376 static const char_type MATCH[] = { 'M', 'A', 'T', 'C', 'H' };
377 static const char_type PREMATCH[] = { 'P', 'R', 'E', 'M', 'A', 'T', 'C', 'H' };
378 static const char_type POSTMATCH[] = { 'P', 'O', 'S', 'T', 'M', 'A', 'T', 'C', 'H' };
379 static const char_type LAST_PAREN_MATCH[] = { 'L', 'A', 'S', 'T', '_', 'P', 'A', 'R', 'E', 'N', '_', 'M', 'A', 'T', 'C', 'H' };
380 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' };
381 static const char_type LAST_SUBMATCH_RESULT_ALT[] = { '^', 'N' };
383 if(m_position == m_end)
385 if(have_brace && (*m_position == '^'))
388 std::ptrdiff_t max_len = m_end - m_position;
390 if((max_len >= 5) && std::equal(m_position, m_position + 5, MATCH))
395 if((m_position != m_end) && (*m_position == '}'))
403 put(this->m_results[0]);
406 if((max_len >= 8) && std::equal(m_position, m_position + 8, PREMATCH))
411 if((m_position != m_end) && (*m_position == '}'))
419 put(this->m_results.prefix());
422 if((max_len >= 9) && std::equal(m_position, m_position + 9, POSTMATCH))
427 if((m_position != m_end) && (*m_position == '}'))
435 put(this->m_results.suffix());
438 if((max_len >= 16) && std::equal(m_position, m_position + 16, LAST_PAREN_MATCH))
443 if((m_position != m_end) && (*m_position == '}'))
451 put((this->m_results)[this->m_results.size() > 1 ? static_cast<int>(this->m_results.size() - 1) : 1]);
454 if((max_len >= 20) && std::equal(m_position, m_position + 20, LAST_SUBMATCH_RESULT))
459 if((m_position != m_end) && (*m_position == '}'))
467 put(this->m_results.get_last_closed_paren());
470 if((max_len >= 2) && std::equal(m_position, m_position + 2, LAST_SUBMATCH_RESULT_ALT))
475 if((m_position != m_end) && (*m_position == '}'))
483 put(this->m_results.get_last_closed_paren());
489 template <class OutputIterator, class Results, class traits, class ForwardIter>
490 void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format_escape()
492 // skip the escape and check for trailing escape:
493 if(++m_position == m_end)
495 put(static_cast<char_type>('\\'));
498 // now switch on the escape type:
502 put(static_cast<char_type>('\a'));
506 put(static_cast<char_type>('\f'));
510 put(static_cast<char_type>('\n'));
514 put(static_cast<char_type>('\r'));
518 put(static_cast<char_type>('\t'));
522 put(static_cast<char_type>('\v'));
526 if(++m_position == m_end)
528 put(static_cast<char_type>('x'));
531 // maybe have \x{ddd}
532 if(*m_position == static_cast<char_type>('{'))
535 int val = this->toi(m_position, m_end, 16);
538 // invalid value treat everything as literals:
539 put(static_cast<char_type>('x'));
540 put(static_cast<char_type>('{'));
543 if((m_position == m_end) || (*m_position != static_cast<char_type>('}')))
546 while(*m_position != static_cast<char_type>('\\'))
553 put(static_cast<char_type>(val));
558 std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end);
559 len = (std::min)(static_cast<std::ptrdiff_t>(2), len);
560 int val = this->toi(m_position, m_position + len, 16);
567 put(static_cast<char_type>(val));
571 if(++m_position == m_end)
577 put(static_cast<char_type>(*m_position++ % 32));
580 put(static_cast<char_type>(27));
584 // see if we have a perl specific escape:
585 if((m_flags & boost::regex_constants::format_sed) == 0)
587 bool breakout = false;
592 m_restore_state = m_state;
593 m_state = output_next_lower;
598 m_state = output_lower;
603 m_restore_state = m_state;
604 m_state = output_next_upper;
609 m_state = output_upper;
614 m_state = output_copy;
621 // see if we have a \n sed style backreference:
622 std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end);
623 len = (std::min)(static_cast<std::ptrdiff_t>(1), len);
624 int v = this->toi(m_position, m_position+len, 10);
625 if((v > 0) || ((v == 0) && (m_flags & ::boost::regex_constants::format_sed)))
632 // octal ecape sequence:
634 len = ::boost::re_detail::distance(m_position, m_end);
635 len = (std::min)(static_cast<std::ptrdiff_t>(4), len);
636 v = this->toi(m_position, m_position + len, 8);
637 BOOST_ASSERT(v >= 0);
638 put(static_cast<char_type>(v));
641 // Otherwise output the character "as is":
647 template <class OutputIterator, class Results, class traits, class ForwardIter>
648 void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format_conditional()
650 if(m_position == m_end)
652 // oops trailing '?':
653 put(static_cast<char_type>('?'));
657 if(*m_position == '{')
659 ForwardIter base = m_position;
661 v = this->toi(m_position, m_end, 10);
664 // Try a named subexpression:
665 while((m_position != m_end) && (*m_position != '}'))
667 v = this->get_named_sub_index(base + 1, m_position);
669 if((v < 0) || (*m_position != '}'))
672 // oops trailing '?':
673 put(static_cast<char_type>('?'));
676 // Skip trailing '}':
681 std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end);
682 len = (std::min)(static_cast<std::ptrdiff_t>(2), len);
683 v = this->toi(m_position, m_position + len, 10);
687 // oops not a number:
688 put(static_cast<char_type>('?'));
692 // output varies depending upon whether sub-expression v matched or not:
693 if(m_results[v].matched)
695 m_have_conditional = true;
697 m_have_conditional = false;
698 if((m_position != m_end) && (*m_position == static_cast<char_type>(':')))
702 // save output state, then turn it off:
703 output_state saved_state = m_state;
704 m_state = output_none;
705 // format the rest of this scope:
706 format_until_scope_end();
707 // restore output state:
708 m_state = saved_state;
713 // save output state, then turn it off:
714 output_state saved_state = m_state;
715 m_state = output_none;
716 // format until ':' or ')':
717 m_have_conditional = true;
719 m_have_conditional = false;
721 m_state = saved_state;
722 if((m_position != m_end) && (*m_position == static_cast<char_type>(':')))
726 // format the rest of this scope:
727 format_until_scope_end();
732 template <class OutputIterator, class Results, class traits, class ForwardIter>
733 void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format_until_scope_end()
738 if((m_position == m_end) || (*m_position == static_cast<char_type>(')')))
741 }while(m_position != m_end);
744 template <class OutputIterator, class Results, class traits, class ForwardIter>
745 void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::put(char_type c)
747 // write a single character to output
748 // according to which case translation mode we are in:
749 switch(this->m_state)
753 case output_next_lower:
754 c = m_traits.tolower(c);
755 this->m_state = m_restore_state;
757 case output_next_upper:
758 c = m_traits.toupper(c);
759 this->m_state = m_restore_state;
762 c = m_traits.tolower(c);
765 c = m_traits.toupper(c);
774 template <class OutputIterator, class Results, class traits, class ForwardIter>
775 void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::put(const sub_match_type& sub)
777 typedef typename sub_match_type::iterator iterator_type;
778 iterator_type i = sub.first;
779 while(i != sub.second)
787 class string_out_iterator
788 #ifndef BOOST_NO_STD_ITERATOR
789 : public std::iterator<std::output_iterator_tag, typename S::value_type>
794 string_out_iterator(S& s) : out(&s) {}
795 string_out_iterator& operator++() { return *this; }
796 string_out_iterator& operator++(int) { return *this; }
797 string_out_iterator& operator*() { return *this; }
798 string_out_iterator& operator=(typename S::value_type v)
804 #ifdef BOOST_NO_STD_ITERATOR
805 typedef std::ptrdiff_t difference_type;
806 typedef typename S::value_type value_type;
807 typedef value_type* pointer;
808 typedef value_type& reference;
809 typedef std::output_iterator_tag iterator_category;
813 template <class OutputIterator, class Iterator, class Alloc, class ForwardIter, class traits>
814 OutputIterator regex_format_imp(OutputIterator out,
815 const match_results<Iterator, Alloc>& m,
816 ForwardIter p1, ForwardIter p2,
817 match_flag_type flags,
821 if(flags & regex_constants::format_literal)
823 return re_detail::copy(p1, p2, out);
826 re_detail::basic_regex_formatter<
828 match_results<Iterator, Alloc>,
829 traits, ForwardIter> f(out, m, t);
830 return f.format(p1, p2, flags);
833 #ifndef BOOST_NO_SFINAE
835 BOOST_MPL_HAS_XXX_TRAIT_DEF(const_iterator)
837 struct any_type { any_type(...); };
838 typedef char no_type;
839 typedef char (&unary_type)[2];
840 typedef char (&binary_type)[3];
841 typedef char (&ternary_type)[4];
843 no_type check_is_formatter(unary_type, binary_type, ternary_type);
845 unary_type check_is_formatter(T const &, binary_type, ternary_type);
847 binary_type check_is_formatter(unary_type, T const &, ternary_type);
848 template<typename T, typename U>
849 binary_type check_is_formatter(T const &, U const &, ternary_type);
851 ternary_type check_is_formatter(unary_type, binary_type, T const &);
852 template<typename T, typename U>
853 ternary_type check_is_formatter(T const &, binary_type, U const &);
854 template<typename T, typename U>
855 ternary_type check_is_formatter(unary_type, T const &, U const &);
856 template<typename T, typename U, typename V>
857 ternary_type check_is_formatter(T const &, U const &, V const &);
859 struct unary_binary_ternary
861 typedef unary_type (*unary_fun)(any_type);
862 typedef binary_type (*binary_fun)(any_type, any_type);
863 typedef ternary_type (*ternary_fun)(any_type, any_type, any_type);
864 operator unary_fun();
865 operator binary_fun();
866 operator ternary_fun();
869 template<typename Formatter, bool IsFunction = boost::is_function<Formatter>::value>
870 struct formatter_wrapper
872 , unary_binary_ternary
874 formatter_wrapper(){}
877 template<typename Formatter>
878 struct formatter_wrapper<Formatter, true>
879 : unary_binary_ternary
881 operator Formatter *();
884 template<typename Formatter>
885 struct formatter_wrapper<Formatter *, false>
886 : unary_binary_ternary
888 operator Formatter *();
891 template <class F, class M, class O>
892 struct format_traits_imp
896 // F must be a pointer, a function, or a class with a function call operator:
898 BOOST_STATIC_ASSERT((::boost::is_pointer<F>::value || ::boost::is_function<F>::value || ::boost::is_class<F>::value));
899 static formatter_wrapper<typename unwrap_reference<F>::type> f;
902 static boost::regex_constants::match_flag_type flags;
904 BOOST_STATIC_CONSTANT(int, value = sizeof(check_is_formatter(f(m), f(m, out), f(m, out, flags))));
907 template <class F, class M, class O>
912 // Type is mpl::int_<N> where N is one of:
914 // 0 : F is a pointer to a presumably null-terminated string.
915 // 1 : F is a character-container such as a std::string.
916 // 2 : F is a Unary Functor.
917 // 3 : F is a Binary Functor.
918 // 4 : F is a Ternary Functor.
920 typedef typename boost::mpl::if_<
921 boost::mpl::and_<boost::is_pointer<F>, boost::mpl::not_<boost::is_function<typename boost::remove_pointer<F>::type> > >,
923 typename boost::mpl::if_<
924 has_const_iterator<F>,
926 boost::mpl::int_<format_traits_imp<F, M, O>::value>
930 // This static assertion will fail if the functor passed does not accept
931 // the same type of arguments passed.
933 BOOST_STATIC_ASSERT( boost::is_class<F>::value && !has_const_iterator<F>::value ? (type::value > 1) : true);
936 #else // BOOST_NO_SFINAE
938 template <class F, class M, class O>
943 // Type is mpl::int_<N> where N is one of:
945 // 0 : F is a pointer to a presumably null-terminated string.
946 // 1 : F is a character-container such as a std::string.
948 // Other options such as F being a Functor are not supported without
951 typedef typename boost::mpl::if_<
952 boost::is_pointer<F>,
958 #endif // BOOST_NO_SFINAE
960 template <class Base, class Match>
961 struct format_functor3
963 format_functor3(Base b) : func(b) {}
964 template <class OutputIter>
965 OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f)
967 return boost::unwrap_ref(func)(m, i, f);
969 template <class OutputIter, class Traits>
970 OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f, const Traits&)
972 return (*this)(m, i, f);
976 format_functor3(const format_functor3&);
977 format_functor3& operator=(const format_functor3&);
980 template <class Base, class Match>
981 struct format_functor2
983 format_functor2(Base b) : func(b) {}
984 template <class OutputIter>
985 OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type /*f*/)
987 return boost::unwrap_ref(func)(m, i);
989 template <class OutputIter, class Traits>
990 OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f, const Traits&)
992 return (*this)(m, i, f);
996 format_functor2(const format_functor2&);
997 format_functor2& operator=(const format_functor2&);
1000 template <class Base, class Match>
1001 struct format_functor1
1003 format_functor1(Base b) : func(b) {}
1005 template <class S, class OutputIter>
1006 OutputIter do_format_string(const S& s, OutputIter i)
1008 return re_detail::copy(s.begin(), s.end(), i);
1010 template <class S, class OutputIter>
1011 inline OutputIter do_format_string(const S* s, OutputIter i)
1021 template <class OutputIter>
1022 OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type /*f*/)
1024 return do_format_string(boost::unwrap_ref(func)(m), i);
1026 template <class OutputIter, class Traits>
1027 OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f, const Traits&)
1029 return (*this)(m, i, f);
1033 format_functor1(const format_functor1&);
1034 format_functor1& operator=(const format_functor1&);
1037 template <class charT, class Match, class Traits>
1038 struct format_functor_c_string
1040 format_functor_c_string(const charT* ps) : func(ps) {}
1042 template <class OutputIter>
1043 OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f, const Traits& t = Traits())
1045 typedef typename Match::char_type char_type;
1046 const charT* end = func;
1048 return regex_format_imp(i, m, func, end, f, t);
1052 format_functor_c_string(const format_functor_c_string&);
1053 format_functor_c_string& operator=(const format_functor_c_string&);
1056 template <class Container, class Match, class Traits>
1057 struct format_functor_container
1059 format_functor_container(const Container& c) : func(c) {}
1061 template <class OutputIter>
1062 OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f, const Traits& t = Traits())
1064 typedef typename Match::char_type char_type;
1065 return re_detail::regex_format_imp(i, m, func.begin(), func.end(), f, t);
1068 const Container& func;
1069 format_functor_container(const format_functor_container&);
1070 format_functor_container& operator=(const format_functor_container&);
1073 template <class Func, class Match, class OutputIterator, class Traits = re_detail::trivial_format_traits<typename Match::char_type> >
1074 struct compute_functor_type
1076 typedef typename format_traits<Func, Match, OutputIterator>::type tag;
1077 typedef typename boost::remove_cv< typename boost::remove_pointer<Func>::type>::type maybe_char_type;
1079 typedef typename mpl::if_<
1080 ::boost::is_same<tag, mpl::int_<0> >, format_functor_c_string<maybe_char_type, Match, Traits>,
1082 ::boost::is_same<tag, mpl::int_<1> >, format_functor_container<Func, Match, Traits>,
1084 ::boost::is_same<tag, mpl::int_<2> >, format_functor1<Func, Match>,
1086 ::boost::is_same<tag, mpl::int_<3> >, format_functor2<Func, Match>,
1087 format_functor3<Func, Match>
1094 } // namespace re_detail
1096 template <class OutputIterator, class Iterator, class Allocator, class Functor>
1097 inline OutputIterator regex_format(OutputIterator out,
1098 const match_results<Iterator, Allocator>& m,
1100 match_flag_type flags = format_all
1103 return m.format(out, fmt, flags);
1106 template <class Iterator, class Allocator, class Functor>
1107 inline std::basic_string<typename match_results<Iterator, Allocator>::char_type> regex_format(const match_results<Iterator, Allocator>& m,
1109 match_flag_type flags = format_all)
1111 return m.format(fmt, flags);
1115 #pragma warning(push)
1116 #pragma warning(disable: 4103)
1118 #ifdef BOOST_HAS_ABI_HEADERS
1119 # include BOOST_ABI_SUFFIX
1122 #pragma warning(pop)
1125 } // namespace boost
1127 #endif // BOOST_REGEX_FORMAT_HPP