File indexing completed on 2025-01-18 09:28:24
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_STRING_TRIM_DETAIL_HPP
0012 #define BOOST_STRING_TRIM_DETAIL_HPP
0013
0014 #include <boost/algorithm/string/config.hpp>
0015 #include <iterator>
0016
0017 namespace boost {
0018 namespace algorithm {
0019 namespace detail {
0020
0021
0022
0023 template< typename ForwardIteratorT, typename PredicateT >
0024 inline ForwardIteratorT trim_end_iter_select(
0025 ForwardIteratorT InBegin,
0026 ForwardIteratorT InEnd,
0027 PredicateT IsSpace,
0028 std::forward_iterator_tag )
0029 {
0030 ForwardIteratorT TrimIt=InBegin;
0031
0032 for( ForwardIteratorT It=InBegin; It!=InEnd; ++It )
0033 {
0034 if ( !IsSpace(*It) )
0035 {
0036 TrimIt=It;
0037 ++TrimIt;
0038 }
0039 }
0040
0041 return TrimIt;
0042 }
0043
0044 template< typename ForwardIteratorT, typename PredicateT >
0045 inline ForwardIteratorT trim_end_iter_select(
0046 ForwardIteratorT InBegin,
0047 ForwardIteratorT InEnd,
0048 PredicateT IsSpace,
0049 std::bidirectional_iterator_tag )
0050 {
0051 for( ForwardIteratorT It=InEnd; It!=InBegin; )
0052 {
0053 if ( !IsSpace(*(--It)) )
0054 return ++It;
0055 }
0056
0057 return InBegin;
0058 }
0059
0060 template< typename ForwardIteratorT, typename PredicateT >
0061 inline ForwardIteratorT trim_begin(
0062 ForwardIteratorT InBegin,
0063 ForwardIteratorT InEnd,
0064 PredicateT IsSpace )
0065 {
0066 ForwardIteratorT It=InBegin;
0067 for(; It!=InEnd; ++It )
0068 {
0069 if (!IsSpace(*It))
0070 return It;
0071 }
0072
0073 return It;
0074 }
0075
0076
0077 template< typename ForwardIteratorT, typename PredicateT >
0078 inline ForwardIteratorT trim_end(
0079 ForwardIteratorT InBegin,
0080 ForwardIteratorT InEnd,
0081 PredicateT IsSpace )
0082 {
0083 typedef BOOST_STRING_TYPENAME
0084 std::iterator_traits<ForwardIteratorT>::iterator_category category;
0085
0086 return ::boost::algorithm::detail::trim_end_iter_select( InBegin, InEnd, IsSpace, category() );
0087 }
0088
0089
0090 }
0091 }
0092 }
0093
0094
0095 #endif