1 | // Boost string_algo library util.hpp header file ---------------------------//
|
---|
2 |
|
---|
3 | // Copyright Pavol Droba 2002-2003. Use, modification and
|
---|
4 | // distribution is subject to the Boost Software License, Version
|
---|
5 | // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
---|
6 | // http://www.boost.org/LICENSE_1_0.txt)
|
---|
7 |
|
---|
8 | // See http://www.boost.org for updates, documentation, and revision history.
|
---|
9 |
|
---|
10 | #ifndef BOOST_STRING_UTIL_DETAIL_HPP
|
---|
11 | #define BOOST_STRING_UTIL_DETAIL_HPP
|
---|
12 |
|
---|
13 | #include <boost/algorithm/string/config.hpp>
|
---|
14 | #include <functional>
|
---|
15 | #include <boost/range/iterator_range.hpp>
|
---|
16 |
|
---|
17 | namespace boost {
|
---|
18 | namespace algorithm {
|
---|
19 | namespace detail {
|
---|
20 |
|
---|
21 | // empty container -----------------------------------------------//
|
---|
22 |
|
---|
23 | // empty_container
|
---|
24 | /*
|
---|
25 | This class represents always empty container,
|
---|
26 | containing elements of type CharT.
|
---|
27 |
|
---|
28 | It is supposed to be used in a const version only
|
---|
29 | */
|
---|
30 | template< typename CharT >
|
---|
31 | struct empty_container
|
---|
32 | {
|
---|
33 | typedef empty_container<CharT> type;
|
---|
34 | typedef CharT value_type;
|
---|
35 | typedef std::size_t size_type;
|
---|
36 | typedef std::ptrdiff_t difference_type;
|
---|
37 | typedef const value_type& reference;
|
---|
38 | typedef const value_type& const_reference;
|
---|
39 | typedef const value_type* iterator;
|
---|
40 | typedef const value_type* const_iterator;
|
---|
41 |
|
---|
42 |
|
---|
43 | // Operations
|
---|
44 | const_iterator begin() const
|
---|
45 | {
|
---|
46 | return reinterpret_cast<const_iterator>(0);
|
---|
47 | }
|
---|
48 |
|
---|
49 | const_iterator end() const
|
---|
50 | {
|
---|
51 | return reinterpret_cast<const_iterator>(0);
|
---|
52 | }
|
---|
53 |
|
---|
54 | bool empty() const
|
---|
55 | {
|
---|
56 | return false;
|
---|
57 | }
|
---|
58 |
|
---|
59 | size_type size() const
|
---|
60 | {
|
---|
61 | return 0;
|
---|
62 | }
|
---|
63 | };
|
---|
64 |
|
---|
65 | // bounded copy algorithm -----------------------------------------------//
|
---|
66 |
|
---|
67 | // Bounded version of the std::copy algorithm
|
---|
68 | template<typename InputIteratorT, typename OutputIteratorT>
|
---|
69 | inline OutputIteratorT bounded_copy(
|
---|
70 | InputIteratorT First,
|
---|
71 | InputIteratorT Last,
|
---|
72 | OutputIteratorT DestFirst,
|
---|
73 | OutputIteratorT DestLast )
|
---|
74 | {
|
---|
75 | InputIteratorT InputIt=First;
|
---|
76 | OutputIteratorT OutputIt=DestFirst;
|
---|
77 | for(; InputIt!=Last && OutputIt!=DestLast; InputIt++, OutputIt++ )
|
---|
78 | {
|
---|
79 | *OutputIt=*InputIt;
|
---|
80 | }
|
---|
81 |
|
---|
82 | return OutputIt;
|
---|
83 | }
|
---|
84 |
|
---|
85 | // iterator range utilities -----------------------------------------//
|
---|
86 |
|
---|
87 | // copy range functor
|
---|
88 | template<
|
---|
89 | typename SeqT,
|
---|
90 | typename IteratorT=BOOST_STRING_TYPENAME SeqT::const_iterator >
|
---|
91 | struct copy_iterator_rangeF :
|
---|
92 | public std::unary_function< iterator_range<IteratorT>, SeqT >
|
---|
93 | {
|
---|
94 | SeqT operator()( const iterator_range<IteratorT>& Range ) const
|
---|
95 | {
|
---|
96 | return copy_range<SeqT>(Range);
|
---|
97 | }
|
---|
98 | };
|
---|
99 |
|
---|
100 | } // namespace detail
|
---|
101 | } // namespace algorithm
|
---|
102 | } // namespace boost
|
---|
103 |
|
---|
104 |
|
---|
105 | #endif // BOOST_STRING_UTIL_DETAIL_HPP
|
---|