123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- #ifndef BOOST_STRING_JOIN_HPP
- #define BOOST_STRING_JOIN_HPP
- #include <boost/algorithm/string/config.hpp>
- #include <boost/algorithm/string/detail/sequence.hpp>
- #include <boost/range/value_type.hpp>
- #include <boost/range/as_literal.hpp>
- namespace boost {
- namespace algorithm {
-
-
- template< typename SequenceSequenceT, typename Range1T>
- inline typename range_value<SequenceSequenceT>::type
- join(
- const SequenceSequenceT& Input,
- const Range1T& Separator)
- {
-
- typedef typename range_value<SequenceSequenceT>::type ResultT;
- typedef typename range_const_iterator<SequenceSequenceT>::type InputIteratorT;
-
- InputIteratorT itBegin=::boost::begin(Input);
- InputIteratorT itEnd=::boost::end(Input);
-
- ResultT Result;
-
-
- if(itBegin!=itEnd)
- {
- detail::insert(Result, ::boost::end(Result), *itBegin);
- ++itBegin;
- }
- for(;itBegin!=itEnd; ++itBegin)
- {
-
- detail::insert(Result, ::boost::end(Result), as_literal(Separator));
-
- detail::insert(Result, ::boost::end(Result), *itBegin);
- }
- return Result;
- }
-
-
- template< typename SequenceSequenceT, typename Range1T, typename PredicateT>
- inline typename range_value<SequenceSequenceT>::type
- join_if(
- const SequenceSequenceT& Input,
- const Range1T& Separator,
- PredicateT Pred)
- {
-
- typedef typename range_value<SequenceSequenceT>::type ResultT;
- typedef typename range_const_iterator<SequenceSequenceT>::type InputIteratorT;
-
- InputIteratorT itBegin=::boost::begin(Input);
- InputIteratorT itEnd=::boost::end(Input);
-
- ResultT Result;
-
- while(itBegin!=itEnd && !Pred(*itBegin)) ++itBegin;
-
- if(itBegin!=itEnd)
- {
- detail::insert(Result, ::boost::end(Result), *itBegin);
- ++itBegin;
- }
- for(;itBegin!=itEnd; ++itBegin)
- {
- if(Pred(*itBegin))
- {
-
- detail::insert(Result, ::boost::end(Result), as_literal(Separator));
-
- detail::insert(Result, ::boost::end(Result), *itBegin);
- }
- }
- return Result;
- }
- }
-
- using algorithm::join;
- using algorithm::join_if;
- }
- #endif
|