From 134a106ae93a7a90016cefa5e2b0ac3b74a3075e Mon Sep 17 00:00:00 2001 From: Pavol Droba Date: Mon, 27 Feb 2006 11:58:43 +0000 Subject: [PATCH] regex variant of join_if renamed to join_if_regex for compilers that do not support template ordering. [SVN r33136] --- include/boost/algorithm/string/regex.hpp | 72 ++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/include/boost/algorithm/string/regex.hpp b/include/boost/algorithm/string/regex.hpp index 7096d67..d882843 100644 --- a/include/boost/algorithm/string/regex.hpp +++ b/include/boost/algorithm/string/regex.hpp @@ -476,6 +476,8 @@ namespace boost { // join_if ------------------------------------------------------------------// +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + //! Conditional join algorithm /*! This algorithm joins all strings in a 'list' into one long string. @@ -542,6 +544,76 @@ namespace boost { return Result; } +#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING + + //! Conditional join algorithm + /*! + This algorithm joins all strings in a 'list' into one long string. + Segments are concatenated by given separator. Only segments that + match the given regular expression will be added to the result + + This is a specialization of join_if algorithm. + + \param Input A container that holds the input strings. It must be a container-of-containers. + \param Separator A string that will separate the joined segments. + \param Rx A regular expression + \param Flags Regex options + \return Concatenated string. + + \note This function provides the strong exception-safety guarantee + */ + template< + typename SequenceSequenceT, + typename Range1T, + typename CharT, + typename RegexTraitsT > + inline typename range_value::type + join_if_regex( + const SequenceSequenceT& Input, + Range1T& Separator, + const basic_regex& Rx, + match_flag_type Flags=match_default ) + { + // Define working types + typedef typename range_value::type ResultT; + typedef typename range_const_iterator::type InputIteratorT; + + // Parse input + InputIteratorT itBegin=begin(Input); + InputIteratorT itEnd=end(Input); + + // Construct container to hold the result + ResultT Result; + + + // Roll to the first element that will be added + while( + itBegin!=itEnd && + !regex_match(begin(*itBegin), end(*itBegin), Rx, Flags)) ++itBegin; + + // Add this element + if(itBegin!=itEnd) + { + detail::insert(Result, end(Result), *itBegin); + ++itBegin; + } + + for(;itBegin!=itEnd; ++itBegin) + { + if(regex_match(begin(*itBegin), end(*itBegin), Rx, Flags)) + { + // Add separator + detail::insert(Result, end(Result), Separator); + // Add element + detail::insert(Result, end(Result), *itBegin); + } + } + + return Result; + } + + +#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING } // namespace algorithm