Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / algorithm / string / detail / trim.hpp @ 2486

History | View | Annotate | Download (3.1 kB)

1 2486 sjacqu01
//  Boost string_algo library trim.hpp header file  ---------------------------//
2 2486 sjacqu01
3 2486 sjacqu01
//  Copyright Pavol Droba 2002-2003.
4 2486 sjacqu01
//
5 2486 sjacqu01
// Distributed under the Boost Software License, Version 1.0.
6 2486 sjacqu01
//    (See accompanying file LICENSE_1_0.txt or copy at
7 2486 sjacqu01
//          http://www.boost.org/LICENSE_1_0.txt)
8 2486 sjacqu01
9 2486 sjacqu01
//  See http://www.boost.org/ for updates, documentation, and revision history.
10 2486 sjacqu01
11 2486 sjacqu01
#ifndef BOOST_STRING_TRIM_DETAIL_HPP
12 2486 sjacqu01
#define BOOST_STRING_TRIM_DETAIL_HPP
13 2486 sjacqu01
14 2486 sjacqu01
#include <boost/algorithm/string/config.hpp>
15 2486 sjacqu01
#include <boost/detail/iterator.hpp>
16 2486 sjacqu01
17 2486 sjacqu01
namespace boost {
18 2486 sjacqu01
    namespace algorithm {
19 2486 sjacqu01
        namespace detail {
20 2486 sjacqu01
21 2486 sjacqu01
//  trim iterator helper -----------------------------------------------//
22 2486 sjacqu01
23 2486 sjacqu01
            template< typename ForwardIteratorT, typename PredicateT >
24 2486 sjacqu01
            inline ForwardIteratorT trim_end_iter_select(
25 2486 sjacqu01
                ForwardIteratorT InBegin,
26 2486 sjacqu01
                ForwardIteratorT InEnd,
27 2486 sjacqu01
                PredicateT IsSpace,
28 2486 sjacqu01
                std::forward_iterator_tag )
29 2486 sjacqu01
            {
30 2486 sjacqu01
                ForwardIteratorT TrimIt=InBegin;
31 2486 sjacqu01
32 2486 sjacqu01
                for( ForwardIteratorT It=InBegin; It!=InEnd; ++It )
33 2486 sjacqu01
                {
34 2486 sjacqu01
                    if ( !IsSpace(*It) )
35 2486 sjacqu01
                    {
36 2486 sjacqu01
                        TrimIt=It;
37 2486 sjacqu01
                        ++TrimIt;
38 2486 sjacqu01
                    }
39 2486 sjacqu01
                }
40 2486 sjacqu01
41 2486 sjacqu01
                return TrimIt;
42 2486 sjacqu01
            }
43 2486 sjacqu01
44 2486 sjacqu01
            template< typename ForwardIteratorT, typename PredicateT >
45 2486 sjacqu01
            inline ForwardIteratorT trim_end_iter_select(
46 2486 sjacqu01
                ForwardIteratorT InBegin,
47 2486 sjacqu01
                ForwardIteratorT InEnd,
48 2486 sjacqu01
                PredicateT IsSpace,
49 2486 sjacqu01
                std::bidirectional_iterator_tag )
50 2486 sjacqu01
            {
51 2486 sjacqu01
                for( ForwardIteratorT It=InEnd; It!=InBegin;  )
52 2486 sjacqu01
                {
53 2486 sjacqu01
                    if ( !IsSpace(*(--It)) )
54 2486 sjacqu01
                        return ++It;
55 2486 sjacqu01
                }
56 2486 sjacqu01
57 2486 sjacqu01
                return InBegin;
58 2486 sjacqu01
            }
59 2486 sjacqu01
   // Search for first non matching character from the beginning of the sequence
60 2486 sjacqu01
            template< typename ForwardIteratorT, typename PredicateT >
61 2486 sjacqu01
            inline ForwardIteratorT trim_begin(
62 2486 sjacqu01
                ForwardIteratorT InBegin,
63 2486 sjacqu01
                ForwardIteratorT InEnd,
64 2486 sjacqu01
                PredicateT IsSpace )
65 2486 sjacqu01
            {
66 2486 sjacqu01
                ForwardIteratorT It=InBegin;
67 2486 sjacqu01
                for(; It!=InEnd; ++It )
68 2486 sjacqu01
                {
69 2486 sjacqu01
                    if (!IsSpace(*It))
70 2486 sjacqu01
                        return It;
71 2486 sjacqu01
                }
72 2486 sjacqu01
73 2486 sjacqu01
                return It;
74 2486 sjacqu01
            }
75 2486 sjacqu01
76 2486 sjacqu01
            // Search for first non matching character from the end of the sequence
77 2486 sjacqu01
            template< typename ForwardIteratorT, typename PredicateT >
78 2486 sjacqu01
            inline ForwardIteratorT trim_end(
79 2486 sjacqu01
                ForwardIteratorT InBegin,
80 2486 sjacqu01
                ForwardIteratorT InEnd,
81 2486 sjacqu01
                PredicateT IsSpace )
82 2486 sjacqu01
            {
83 2486 sjacqu01
                typedef BOOST_STRING_TYPENAME boost::detail::
84 2486 sjacqu01
                    iterator_traits<ForwardIteratorT>::iterator_category category;
85 2486 sjacqu01
86 2486 sjacqu01
                return ::boost::algorithm::detail::trim_end_iter_select( InBegin, InEnd, IsSpace, category() );
87 2486 sjacqu01
            }
88 2486 sjacqu01
89 2486 sjacqu01
90 2486 sjacqu01
        } // namespace detail
91 2486 sjacqu01
    } // namespace algorithm
92 2486 sjacqu01
} // namespace boost
93 2486 sjacqu01
94 2486 sjacqu01
95 2486 sjacqu01
#endif  // BOOST_STRING_TRIM_DETAIL_HPP