forked from boostorg/algorithm
Compare commits
61 Commits
svn-branch
...
boost-1.33
Author | SHA1 | Date | |
---|---|---|---|
915efd8afd | |||
5af41051f0 | |||
6c5f2a8d33 | |||
924368a775 | |||
344225bce1 | |||
a4137bbae6 | |||
04a40de48d | |||
5ecf446070 | |||
e909726c60 | |||
9878f92a41 | |||
d72eec3093 | |||
bc09128c6e | |||
0f707ed9c9 | |||
77307c2823 | |||
e00fd7f159 | |||
5419d39b2e | |||
7ad6c08c68 | |||
b6c5c86d9c | |||
0f4aa23e9c | |||
b0a2a9d3e0 | |||
8fc117aa7e | |||
0f827f89cf | |||
2074344846 | |||
3b889db8d1 | |||
1489b70457 | |||
c475f8559d | |||
d3d4ffe0e6 | |||
2b5de80031 | |||
aea6f39c11 | |||
54092d7934 | |||
747597c7ef | |||
72b4390091 | |||
77ae41a18a | |||
5d1448f3ac | |||
0a0facd7c7 | |||
053cc53eea | |||
54ac5bebd3 | |||
3542f868a0 | |||
4d346d43ad | |||
56862b0bcc | |||
108365abe7 | |||
fa09dddc75 | |||
6fb58192d7 | |||
792b4eae88 | |||
a23ae6316f | |||
5063e96367 | |||
5221839b71 | |||
ba00033cbf | |||
047a42934d | |||
747b4e17cc | |||
4c0efd3d1a | |||
67f7273ab3 | |||
ce6a647dd0 | |||
246794db2a | |||
325fa64dc3 | |||
33122fefa7 | |||
4b3118ed2b | |||
85e0e920bf | |||
483bc9e231 | |||
643c793f3b | |||
825468bc42 |
@ -26,6 +26,7 @@
|
||||
*/
|
||||
|
||||
#include <boost/tuple/tuple.hpp> // for using pairs with boost::cref
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
|
@ -64,52 +64,52 @@ namespace boost {
|
||||
// if only one element
|
||||
ForwardIter second = first; ++second;
|
||||
if (second == last)
|
||||
return std::make_pair(min_result, max_result);
|
||||
return std::make_pair(min_result, max_result);
|
||||
|
||||
// treat first pair separately (only one comparison for first two elements)
|
||||
ForwardIter potential_min_result = last;
|
||||
if (comp(first, second))
|
||||
max_result = second;
|
||||
max_result = second;
|
||||
else {
|
||||
min_result = second;
|
||||
potential_min_result = first;
|
||||
min_result = second;
|
||||
potential_min_result = first;
|
||||
}
|
||||
|
||||
// then each element by pairs, with at most 3 comparisons per pair
|
||||
first = ++second; if (first != last) ++second;
|
||||
while (second != last) {
|
||||
if (comp(first, second)) {
|
||||
if (comp(first, min_result)) {
|
||||
min_result = first;
|
||||
potential_min_result = last;
|
||||
}
|
||||
if (comp(max_result, second))
|
||||
max_result = second;
|
||||
} else {
|
||||
if (comp(second, min_result)) {
|
||||
min_result = second;
|
||||
potential_min_result = first;
|
||||
}
|
||||
if (comp(max_result, first))
|
||||
max_result = first;
|
||||
}
|
||||
first = ++second;
|
||||
if (first != last) ++second;
|
||||
if (comp(first, second)) {
|
||||
if (comp(first, min_result)) {
|
||||
min_result = first;
|
||||
potential_min_result = last;
|
||||
}
|
||||
if (comp(max_result, second))
|
||||
max_result = second;
|
||||
} else {
|
||||
if (comp(second, min_result)) {
|
||||
min_result = second;
|
||||
potential_min_result = first;
|
||||
}
|
||||
if (comp(max_result, first))
|
||||
max_result = first;
|
||||
}
|
||||
first = ++second;
|
||||
if (first != last) ++second;
|
||||
}
|
||||
|
||||
// if odd number of elements, treat last element
|
||||
if (first != last) { // odd number of elements
|
||||
if (comp(first, min_result))
|
||||
min_result = first, potential_min_result = last;
|
||||
else if (comp(max_result, first))
|
||||
max_result = first;
|
||||
if (comp(first, min_result))
|
||||
min_result = first, potential_min_result = last;
|
||||
else if (comp(max_result, first))
|
||||
max_result = first;
|
||||
}
|
||||
|
||||
// resolve min_result being incorrect with one extra comparison
|
||||
// (in which case potential_min_result is necessarily the correct result)
|
||||
if (potential_min_result != last
|
||||
&& !comp(min_result, potential_min_result))
|
||||
min_result = potential_min_result;
|
||||
&& !comp(min_result, potential_min_result))
|
||||
min_result = potential_min_result;
|
||||
|
||||
return std::make_pair(min_result,max_result);
|
||||
}
|
||||
@ -352,23 +352,23 @@ namespace boost {
|
||||
while (second != last) {
|
||||
if (!comp(second, first)) {
|
||||
if (comp(first, min_result))
|
||||
min_result = first;
|
||||
min_result = first;
|
||||
if (!comp(second, max_result))
|
||||
max_result = second;
|
||||
max_result = second;
|
||||
} else {
|
||||
if (comp(second, min_result))
|
||||
min_result = second;
|
||||
min_result = second;
|
||||
if (!comp(first, max_result))
|
||||
max_result = first;
|
||||
max_result = first;
|
||||
}
|
||||
first = ++second; if (first != last) ++second;
|
||||
}
|
||||
|
||||
if (first != last) {
|
||||
if (comp(first, min_result))
|
||||
min_result = first;
|
||||
min_result = first;
|
||||
else if (!comp(first, max_result))
|
||||
max_result = first;
|
||||
max_result = first;
|
||||
}
|
||||
|
||||
return std::make_pair(min_result, max_result);
|
||||
@ -448,15 +448,15 @@ namespace boost {
|
||||
min_result = first;
|
||||
if (!comp(second, max_result)) {
|
||||
max_result = second;
|
||||
potential_max_result = last;
|
||||
}
|
||||
potential_max_result = last;
|
||||
}
|
||||
} else {
|
||||
if (!comp(min_result, second))
|
||||
min_result = second;
|
||||
if (!comp(first, max_result)) {
|
||||
max_result = first;
|
||||
potential_max_result = second;
|
||||
}
|
||||
potential_max_result = second;
|
||||
}
|
||||
}
|
||||
first = ++second;
|
||||
if (first != last) ++second;
|
||||
@ -467,7 +467,7 @@ namespace boost {
|
||||
min_result = first;
|
||||
if (!comp(first, max_result)) {
|
||||
max_result = first;
|
||||
potential_max_result = last;
|
||||
potential_max_result = last;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
// Boost string_algo library string_algo.hpp header file ---------------------------//
|
||||
|
||||
// (C) Copyright Pavol Droba 2002-2003. Permission to copy, use, modify, sell and
|
||||
// distribute this software is granted provided this copyright notice appears
|
||||
// in all copies. This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
// Copyright Pavol Droba 2002-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
@ -15,7 +15,6 @@
|
||||
*/
|
||||
|
||||
#include <boost/algorithm/string/std_containers_traits.hpp>
|
||||
#include <boost/algorithm/string/iterator_range.hpp>
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
#include <boost/algorithm/string/case_conv.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
|
@ -14,7 +14,11 @@
|
||||
#include <algorithm>
|
||||
#include <locale>
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
|
||||
#include <boost/algorithm/string/detail/case_conv.hpp>
|
||||
|
||||
/*! \file
|
||||
@ -35,7 +39,7 @@ namespace boost {
|
||||
It is returned as a sequence or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input collection
|
||||
\param Input An input range
|
||||
\param Loc A locale used for conversion
|
||||
\return
|
||||
An output iterator pointing just after the last inserted character or
|
||||
@ -44,19 +48,19 @@ namespace boost {
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
|
||||
*/
|
||||
template<typename OutputIteratorT, typename CollectionT>
|
||||
template<typename OutputIteratorT, typename RangeT>
|
||||
inline OutputIteratorT
|
||||
to_lower_copy(
|
||||
OutputIteratorT Output,
|
||||
const CollectionT& Input,
|
||||
const RangeT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return std::transform(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
Output,
|
||||
detail::to_lowerF<
|
||||
typename value_type_of<CollectionT>::type >(Loc));
|
||||
::boost::algorithm::detail::to_lowerF<
|
||||
typename range_value<RangeT>::type >(Loc));
|
||||
}
|
||||
|
||||
//! Convert to lower case
|
||||
@ -71,12 +75,12 @@ namespace boost {
|
||||
return SequenceT(
|
||||
make_transform_iterator(
|
||||
begin(Input),
|
||||
detail::to_lowerF<
|
||||
typename value_type_of<SequenceT>::type >(Loc)),
|
||||
::boost::algorithm::detail::to_lowerF<
|
||||
typename range_value<SequenceT>::type >(Loc)),
|
||||
make_transform_iterator(
|
||||
end(Input),
|
||||
detail::to_lowerF<
|
||||
typename value_type_of<SequenceT>::type >(Loc)));
|
||||
::boost::algorithm::detail::to_lowerF<
|
||||
typename range_value<SequenceT>::type >(Loc)));
|
||||
}
|
||||
|
||||
//! Convert to lower case
|
||||
@ -84,20 +88,20 @@ namespace boost {
|
||||
Each element of the input sequence is converted to lower
|
||||
case. The input sequence is modified in-place.
|
||||
|
||||
\param Input A collection
|
||||
\param Input A range
|
||||
\param Loc a locale used for conversion
|
||||
*/
|
||||
template<typename MutableCollectionT>
|
||||
template<typename WritableRangeT>
|
||||
inline void to_lower(
|
||||
MutableCollectionT& Input,
|
||||
WritableRangeT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
std::transform(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
begin(Input),
|
||||
detail::to_lowerF<
|
||||
typename value_type_of<MutableCollectionT>::type >(Loc));
|
||||
::boost::algorithm::detail::to_lowerF<
|
||||
typename range_value<WritableRangeT>::type >(Loc));
|
||||
}
|
||||
|
||||
// to_upper -----------------------------------------------//
|
||||
@ -109,7 +113,7 @@ namespace boost {
|
||||
It is returned as a sequence or copied to the output iterator
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input collection
|
||||
\param Input An input range
|
||||
\param Loc A locale used for conversion
|
||||
\return
|
||||
An output iterator pointing just after the last inserted character or
|
||||
@ -117,19 +121,19 @@ namespace boost {
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename OutputIteratorT, typename CollectionT>
|
||||
template<typename OutputIteratorT, typename RangeT>
|
||||
inline OutputIteratorT
|
||||
to_upper_copy(
|
||||
OutputIteratorT Output,
|
||||
const CollectionT& Input,
|
||||
const RangeT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return std::transform(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
Output,
|
||||
detail::to_upperF<
|
||||
typename value_type_of<CollectionT>::type >(Loc));
|
||||
::boost::algorithm::detail::to_upperF<
|
||||
typename range_value<RangeT>::type >(Loc));
|
||||
}
|
||||
|
||||
//! Convert to upper case
|
||||
@ -144,12 +148,12 @@ namespace boost {
|
||||
return SequenceT(
|
||||
make_transform_iterator(
|
||||
begin(Input),
|
||||
detail::to_upperF<
|
||||
typename value_type_of<SequenceT>::type >(Loc)),
|
||||
::boost::algorithm::detail::to_upperF<
|
||||
typename range_value<SequenceT>::type >(Loc)),
|
||||
make_transform_iterator(
|
||||
end(Input),
|
||||
detail::to_upperF<
|
||||
typename value_type_of<SequenceT>::type >(Loc)));
|
||||
::boost::algorithm::detail::to_upperF<
|
||||
typename range_value<SequenceT>::type >(Loc)));
|
||||
|
||||
}
|
||||
|
||||
@ -158,20 +162,20 @@ namespace boost {
|
||||
Each element of the input sequence is converted to upper
|
||||
case. The input sequence is modified in-place.
|
||||
|
||||
\param Input An input collection
|
||||
\param Input An input range
|
||||
\param Loc a locale used for conversion
|
||||
*/
|
||||
template<typename MutableCollectionT>
|
||||
template<typename WritableRangeT>
|
||||
inline void to_upper(
|
||||
MutableCollectionT& Input,
|
||||
WritableRangeT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
std::transform(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
begin(Input),
|
||||
detail::to_upperF<
|
||||
typename value_type_of<MutableCollectionT>::type >(Loc));
|
||||
::boost::algorithm::detail::to_upperF<
|
||||
typename range_value<WritableRangeT>::type >(Loc));
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <locale>
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <boost/algorithm/string/detail/classification.hpp>
|
||||
#include <boost/algorithm/string/predicate_facade.hpp>
|
||||
|
||||
@ -193,13 +194,13 @@ namespace boost {
|
||||
\param Set A set of characters to be recognized
|
||||
\return An instance of the \c is_any_of predicate
|
||||
*/
|
||||
template<typename ContainerT>
|
||||
template<typename RangeT>
|
||||
inline detail::is_any_ofF<
|
||||
BOOST_STRING_TYPENAME value_type_of<ContainerT>::type>
|
||||
is_any_of( const ContainerT& Set )
|
||||
BOOST_STRING_TYPENAME range_value<RangeT>::type>
|
||||
is_any_of( const RangeT& Set )
|
||||
{
|
||||
return detail::is_any_ofF<
|
||||
BOOST_STRING_TYPENAME value_type_of<ContainerT>::type>(Set);
|
||||
BOOST_STRING_TYPENAME range_value<RangeT>::type>(Set);
|
||||
}
|
||||
|
||||
//! is_from_range predicate
|
||||
@ -235,9 +236,12 @@ namespace boost {
|
||||
const predicate_facade<Pred1T>& Pred1,
|
||||
const predicate_facade<Pred2T>& Pred2 )
|
||||
{
|
||||
// Doing the static_cast with the pointer instead of the reference
|
||||
// is a workaround for some compilers which have problems with
|
||||
// static_cast's of template references, i.e. CW8. /grafik/
|
||||
return detail::pred_andF<Pred1T,Pred2T>(
|
||||
static_cast<const Pred1T&>(Pred1),
|
||||
static_cast<const Pred2T&>(Pred2) );
|
||||
*static_cast<const Pred1T*>(&Pred1),
|
||||
*static_cast<const Pred2T*>(&Pred2) );
|
||||
}
|
||||
|
||||
//! predicate 'or' composition predicate
|
||||
@ -256,9 +260,12 @@ namespace boost {
|
||||
const predicate_facade<Pred1T>& Pred1,
|
||||
const predicate_facade<Pred2T>& Pred2 )
|
||||
{
|
||||
// Doing the static_cast with the pointer instead of the reference
|
||||
// is a workaround for some compilers which have problems with
|
||||
// static_cast's of template references, i.e. CW8. /grafik/
|
||||
return detail::pred_orF<Pred1T,Pred2T>(
|
||||
static_cast<const Pred1T&>(Pred1),
|
||||
static_cast<const Pred2T&>(Pred2));
|
||||
*static_cast<const Pred1T*>(&Pred1),
|
||||
*static_cast<const Pred2T*>(&Pred2));
|
||||
}
|
||||
|
||||
//! predicate negation operator
|
||||
@ -273,7 +280,10 @@ namespace boost {
|
||||
inline detail::pred_notF<PredT>
|
||||
operator!( const predicate_facade<PredT>& Pred )
|
||||
{
|
||||
return detail::pred_notF<PredT>(static_cast<const PredT&>(Pred));
|
||||
// Doing the static_cast with the pointer instead of the reference
|
||||
// is a workaround for some compilers which have problems with
|
||||
// static_cast's of template references, i.e. CW8. /grafik/
|
||||
return detail::pred_notF<PredT>(*static_cast<const PredT*>(&Pred));
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
@ -1,268 +0,0 @@
|
||||
// Boost string_algo library collection_traits.hpp header file -------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// (C) Copyright Thorsten Ottosen 2002-2003. Permission to copy, use, modify,
|
||||
// sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
|
||||
// (C) Copyright Jeremy Siek 2001. Permission to copy, use, modify,
|
||||
// sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
|
||||
// Original idea of container traits was proposed by Jeremy Siek and
|
||||
// Thorsten Ottosen. This implementation is lightweighted version
|
||||
// of container_traits adapter for usage with string_algo library
|
||||
|
||||
#ifndef BOOST_STRING_COLLECTION_TRAITS_HPP
|
||||
#define BOOST_STRING_COLLECTION_TRAITS_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
#include <boost/mpl/apply_if.hpp>
|
||||
|
||||
// Implementation
|
||||
#include <boost/algorithm/string/detail/collection_traits.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines collection_traits class and related free-standing functions.
|
||||
This facility is used to unify the access to different types of collections.
|
||||
It allows the algorithms in the library to work with STL collections, c-style
|
||||
array, null-terminated c-strings (and more) using the same interface.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// collection_traits template class -----------------------------------------//
|
||||
|
||||
//! collection_traits class
|
||||
/*!
|
||||
Collection traits provide uniform access to different types of
|
||||
collections. This functionality allows to write generic algorithms
|
||||
which work with several different kinds of collections.
|
||||
|
||||
Currently following collection types are supported:
|
||||
- containers with STL compatible container interface ( see ContainerConcept )
|
||||
( i.e. \c std::vector<>, \c std::list<>, \c std::string<> ... )
|
||||
- c-style array
|
||||
( \c char[10], \c int[15] ... )
|
||||
- null-terminated c-strings
|
||||
( \c char*, \c wchar_T* )
|
||||
- std::pair of iterators
|
||||
( i.e \c std::pair<vector<int>::iterator,vector<int>::iterator> )
|
||||
|
||||
Collection traits provide an external collection interface operations.
|
||||
All are accessible using free-standing functions.
|
||||
|
||||
The following operations are supported:
|
||||
- \c size()
|
||||
- \c empty()
|
||||
- \c begin()
|
||||
- \c end()
|
||||
|
||||
Container traits have somewhat limited functionality on compilers not
|
||||
supporting partial template specialization and partial template ordering.
|
||||
*/
|
||||
template< typename T >
|
||||
struct collection_traits
|
||||
{
|
||||
private:
|
||||
typedef BOOST_STRING_TYPENAME ::boost::mpl::apply_if<
|
||||
::boost::algorithm::detail::is_pair<T>,
|
||||
detail::pair_container_traits_selector<T>,
|
||||
BOOST_STRING_TYPENAME ::boost::mpl::apply_if<
|
||||
::boost::is_array<T>,
|
||||
detail::array_container_traits_selector<T>,
|
||||
BOOST_STRING_TYPENAME ::boost::mpl::apply_if<
|
||||
::boost::is_pointer<T>,
|
||||
detail::pointer_container_traits_selector<T>,
|
||||
detail::default_container_traits_selector<T>
|
||||
>
|
||||
>
|
||||
>::type container_helper_type;
|
||||
public:
|
||||
//! Function type
|
||||
typedef container_helper_type function_type;
|
||||
//! Value type
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
container_helper_type::value_type value_type;
|
||||
//! Size type
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
container_helper_type::size_type size_type;
|
||||
//! Iterator type
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
container_helper_type::iterator iterator;
|
||||
//! Const iterator type
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
container_helper_type::const_iterator const_iterator;
|
||||
//! Result iterator type ( iterator of const_iterator, depending on the constness of the container )
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
container_helper_type::result_iterator result_iterator;
|
||||
//! Difference type
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
container_helper_type::difference_type difference_type;
|
||||
|
||||
}; // 'collection_traits'
|
||||
|
||||
// collection_traits metafunctions -----------------------------------------//
|
||||
|
||||
//! Container value_type trait
|
||||
/*!
|
||||
Extract the type of elements contained in a container
|
||||
*/
|
||||
template< typename C >
|
||||
struct value_type_of
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME collection_traits<C>::value_type type;
|
||||
};
|
||||
|
||||
//! Container difference trait
|
||||
/*!
|
||||
Extract the container's difference type
|
||||
*/
|
||||
template< typename C >
|
||||
struct difference_type_of
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME collection_traits<C>::difference_type type;
|
||||
};
|
||||
|
||||
//! Container iterator trait
|
||||
/*!
|
||||
Extract the container's iterator type
|
||||
*/
|
||||
template< typename C >
|
||||
struct iterator_of
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME collection_traits<C>::iterator type;
|
||||
};
|
||||
|
||||
//! Container const_iterator trait
|
||||
/*!
|
||||
Extract the container's const_iterator type
|
||||
*/
|
||||
template< typename C >
|
||||
struct const_iterator_of
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME collection_traits<C>::const_iterator type;
|
||||
};
|
||||
|
||||
|
||||
//! Container result_iterator
|
||||
/*!
|
||||
Extract the container's result_iterator type. This type maps to \c C::iterator
|
||||
for mutable container and \c C::const_iterator for const containers.
|
||||
*/
|
||||
template< typename C >
|
||||
struct result_iterator_of
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME collection_traits<C>::result_iterator type;
|
||||
};
|
||||
|
||||
// collection_traits related functions -----------------------------------------//
|
||||
|
||||
//! Free-standing size() function
|
||||
/*!
|
||||
Get the size of the container. Uses collection_traits.
|
||||
*/
|
||||
template< typename C >
|
||||
inline BOOST_STRING_TYPENAME collection_traits<C>::size_type
|
||||
size( const C& c )
|
||||
{
|
||||
return collection_traits<C>::function_type::size( c );
|
||||
}
|
||||
|
||||
//! Free-standing empty() function
|
||||
/*!
|
||||
Check whether the container is empty. Uses container traits.
|
||||
*/
|
||||
template< typename C >
|
||||
inline bool empty( const C& c )
|
||||
{
|
||||
return collection_traits<C>::function_type::empty( c );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
//! Free-standing begin() function
|
||||
/*!
|
||||
Get the begin iterator of the container. Uses collection_traits.
|
||||
*/
|
||||
template< typename C >
|
||||
inline BOOST_STRING_TYPENAME collection_traits<C>::iterator
|
||||
begin( C& c )
|
||||
{
|
||||
return collection_traits<C>::function_type::begin( c );
|
||||
}
|
||||
|
||||
//! Free-standing begin() function
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template< typename C >
|
||||
inline BOOST_STRING_TYPENAME collection_traits<C>::const_iterator
|
||||
begin( const C& c )
|
||||
{
|
||||
return collection_traits<C>::function_type::begin( c );
|
||||
}
|
||||
|
||||
//! Free-standing end() function
|
||||
/*!
|
||||
Get the begin iterator of the container. Uses collection_traits.
|
||||
*/
|
||||
template< typename C >
|
||||
inline BOOST_STRING_TYPENAME collection_traits<C>::iterator
|
||||
end( C& c )
|
||||
{
|
||||
return collection_traits<C>::function_type::end( c );
|
||||
}
|
||||
|
||||
//! Free-standing end() function
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template< typename C >
|
||||
inline BOOST_STRING_TYPENAME collection_traits<C>::const_iterator
|
||||
end( const C& c )
|
||||
{
|
||||
return collection_traits<C>::function_type::end( c );
|
||||
}
|
||||
|
||||
#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
//! Free-standing begin() function
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template< typename C >
|
||||
inline BOOST_STRING_TYPENAME collection_traits<C>::result_iterator
|
||||
begin( C& c )
|
||||
{
|
||||
return collection_traits<C>::function_type::begin( c );
|
||||
}
|
||||
|
||||
//! Free-standing end() function
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template< typename C >
|
||||
inline BOOST_STRING_TYPENAME collection_traits<C>::result_iterator
|
||||
end( C& c )
|
||||
{
|
||||
return collection_traits<C>::function_type::end( c );
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_STRING_COLLECTION_TRAITS_HPP
|
@ -14,7 +14,7 @@
|
||||
#include <locale>
|
||||
|
||||
/*! \file
|
||||
Defines element comparison predicates. Many algorithms in this library can
|
||||
Defines element comparison predicates. Many algorithms in this library can
|
||||
take an additional argument with a predicate used to compare elements.
|
||||
This makes it possible, for instance, to have case insensitive versions
|
||||
of the algorithms.
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
|
||||
// is_equal functor -----------------------------------------------//
|
||||
|
||||
//! is_equal functor
|
||||
@ -54,24 +54,28 @@ namespace boost {
|
||||
/*!
|
||||
\param Loc locales used for comparison
|
||||
*/
|
||||
is_iequal( const std::locale& Loc=std::locale() ) :
|
||||
is_iequal( const std::locale& Loc=std::locale() ) :
|
||||
m_Loc( Loc ) {}
|
||||
|
||||
//! Function operator
|
||||
//! Function operator
|
||||
/*!
|
||||
Compare two operands. Case is ignored.
|
||||
*/
|
||||
template< typename T1, typename T2 >
|
||||
bool operator ()( const T1& Arg1, const T2& Arg2 ) const
|
||||
{
|
||||
return std::toupper(Arg1,m_Loc)==std::toupper(Arg2,m_Loc);
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
return std::toupper(Arg1)==std::toupper(Arg2);
|
||||
#else
|
||||
return std::toupper(Arg1,m_Loc)==std::toupper(Arg2,m_Loc);
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
std::locale m_Loc;
|
||||
};
|
||||
|
||||
} // namespace algorithm
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names to the boost namespace
|
||||
using algorithm::is_equal;
|
||||
|
@ -11,8 +11,9 @@
|
||||
#define BOOST_STRING_CONCEPT_HPP
|
||||
|
||||
#include <boost/concept_check.hpp>
|
||||
#include <boost/algorithm/string/iterator_range.hpp>
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines concepts used in string_algo library
|
||||
|
@ -17,11 +17,7 @@
|
||||
# error "macro already defined!"
|
||||
#endif
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#define BOOST_STRING_TYPENAME
|
||||
#else
|
||||
#define BOOST_STRING_TYPENAME BOOST_DEDUCED_TYPENAME
|
||||
#endif
|
||||
|
||||
// Metrowerks workaround
|
||||
#if BOOST_WORKAROUND(__MWERKS__, <= 0x3003) // 8.x
|
||||
|
@ -20,7 +20,7 @@ namespace boost {
|
||||
|
||||
// case conversion functors -----------------------------------------------//
|
||||
|
||||
// a tolower functor
|
||||
// a tolower functor
|
||||
template<typename CharT>
|
||||
struct to_lowerF : public std::unary_function<CharT, CharT>
|
||||
{
|
||||
@ -30,13 +30,17 @@ namespace boost {
|
||||
// Operation
|
||||
CharT operator ()( CharT Ch ) const
|
||||
{
|
||||
return std::tolower( Ch, m_Loc );
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
return std::tolower( Ch);
|
||||
#else
|
||||
return std::tolower( Ch, m_Loc );
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
const std::locale& m_Loc;
|
||||
};
|
||||
|
||||
// a toupper functor
|
||||
// a toupper functor
|
||||
template<typename CharT>
|
||||
struct to_upperF : public std::unary_function<CharT, CharT>
|
||||
{
|
||||
@ -46,7 +50,11 @@ namespace boost {
|
||||
// Operation
|
||||
CharT operator ()( CharT Ch ) const
|
||||
{
|
||||
return std::toupper( Ch, m_Loc );
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
return std::toupper( Ch);
|
||||
#else
|
||||
return std::toupper( Ch, m_Loc );
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
const std::locale& m_Loc;
|
||||
|
@ -15,16 +15,19 @@
|
||||
#include <functional>
|
||||
#include <locale>
|
||||
#include <set>
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
#include <boost/algorithm/string/predicate_facade.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
|
||||
// classification functors -----------------------------------------------//
|
||||
|
||||
|
||||
// is_classified functor
|
||||
struct is_classifiedF :
|
||||
public predicate_facade<is_classifiedF>
|
||||
@ -32,7 +35,7 @@ namespace boost {
|
||||
// Boost.Lambda support
|
||||
template <class Args> struct sig { typedef bool type; };
|
||||
|
||||
// Constructor from a locale
|
||||
// Constructor from a locale
|
||||
is_classifiedF(std::ctype_base::mask Type, std::locale const & Loc = std::locale()) :
|
||||
m_Type(Type), m_Locale(Loc) {}
|
||||
|
||||
@ -43,13 +46,21 @@ namespace boost {
|
||||
return std::use_facet< std::ctype<CharT> >(m_Locale).is( m_Type, Ch );
|
||||
}
|
||||
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
template<>
|
||||
bool operator()( char const Ch ) const
|
||||
{
|
||||
return std::use_facet< std::ctype<char> >(m_Locale).is( m_Type, Ch );
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
const std::ctype_base::mask m_Type;
|
||||
const std::locale m_Locale;
|
||||
};
|
||||
|
||||
// is_any_of functor
|
||||
/*
|
||||
// is_any_of functor
|
||||
/*
|
||||
returns true if the value is from the specified set
|
||||
*/
|
||||
template<typename CharT>
|
||||
@ -59,26 +70,26 @@ namespace boost {
|
||||
// Boost.Lambda support
|
||||
template <class Args> struct sig { typedef bool type; };
|
||||
|
||||
// Constructor
|
||||
template< typename SeqT >
|
||||
is_any_ofF( const SeqT& Seq ) :
|
||||
m_Set( begin(Seq), end(Seq) ) {}
|
||||
|
||||
// Constructor
|
||||
template<typename RangeT>
|
||||
is_any_ofF( const RangeT& Range ) :
|
||||
m_Set( begin(Range), end(Range) ) {}
|
||||
|
||||
// Operation
|
||||
template<typename Char2T>
|
||||
bool operator()( Char2T Ch ) const
|
||||
{
|
||||
return m_Set.find(Ch)!=m_Set.end();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
// set cannot operate on const value-type
|
||||
typedef typename remove_const<CharT>::type set_value_type;
|
||||
std::set<set_value_type> m_Set;
|
||||
std::set<set_value_type> m_Set;
|
||||
};
|
||||
|
||||
// is_from_range functor
|
||||
/*
|
||||
// is_from_range functor
|
||||
/*
|
||||
returns true if the value is from the specified range.
|
||||
(i.e. x>=From && x>=To)
|
||||
*/
|
||||
@ -89,16 +100,16 @@ namespace boost {
|
||||
// Boost.Lambda support
|
||||
template <class Args> struct sig { typedef bool type; };
|
||||
|
||||
// Constructor
|
||||
// Constructor
|
||||
is_from_rangeF( CharT From, CharT To ) : m_From(From), m_To(To) {}
|
||||
|
||||
|
||||
// Operation
|
||||
template<typename Char2T>
|
||||
bool operator()( Char2T Ch ) const
|
||||
{
|
||||
return ( m_From <= Ch ) && ( Ch <= m_To );
|
||||
return ( m_From <= Ch ) && ( Ch <= m_To );
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
CharT m_From;
|
||||
CharT m_To;
|
||||
@ -120,11 +131,11 @@ namespace boost {
|
||||
|
||||
// Operation
|
||||
template<typename CharT>
|
||||
bool operator()( CharT Ch ) const
|
||||
bool operator()( CharT Ch ) const
|
||||
{
|
||||
return m_Pred1(Ch) && m_Pred2(Ch);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
Pred1T m_Pred1;
|
||||
Pred2T m_Pred2;
|
||||
@ -145,11 +156,11 @@ namespace boost {
|
||||
|
||||
// Operation
|
||||
template<typename CharT>
|
||||
bool operator()( CharT Ch ) const
|
||||
bool operator()( CharT Ch ) const
|
||||
{
|
||||
return m_Pred1(Ch) || m_Pred2(Ch);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
Pred1T m_Pred1;
|
||||
Pred2T m_Pred2;
|
||||
@ -169,11 +180,11 @@ namespace boost {
|
||||
|
||||
// Operation
|
||||
template<typename CharT>
|
||||
bool operator()( CharT Ch ) const
|
||||
bool operator()( CharT Ch ) const
|
||||
{
|
||||
return !m_Pred(Ch);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
PredT m_Pred;
|
||||
};
|
||||
|
@ -1,621 +0,0 @@
|
||||
// Boost string_algo library collection_traits.hpp header file -----------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_DETAIL_COLLECTION_TRAITS_HPP
|
||||
#define BOOST_STRING_DETAIL_COLLECTION_TRAITS_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/type_traits/remove_pointer.hpp>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#include <boost/mpl/apply_if.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
#include <boost/mpl/fold.hpp>
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/algorithm/string/yes_no_type.hpp>
|
||||
|
||||
// Container traits implementation ---------------------------------------------------------
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// Default collection traits -----------------------------------------------------------------
|
||||
|
||||
// Default collection helper
|
||||
/*
|
||||
Wraps std::container compliant containers
|
||||
*/
|
||||
template< typename ContainerT >
|
||||
struct default_container_traits
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME ContainerT::value_type value_type;
|
||||
typedef BOOST_STRING_TYPENAME ContainerT::iterator iterator;
|
||||
typedef BOOST_STRING_TYPENAME ContainerT::const_iterator const_iterator;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::mpl::if_< ::boost::is_const<ContainerT>,
|
||||
const_iterator,
|
||||
iterator
|
||||
>::type result_iterator;
|
||||
typedef BOOST_STRING_TYPENAME ContainerT::difference_type difference_type;
|
||||
typedef BOOST_STRING_TYPENAME ContainerT::size_type size_type;
|
||||
|
||||
// static operations
|
||||
template< typename C >
|
||||
static size_type size( const C& c )
|
||||
{
|
||||
return c.size();
|
||||
}
|
||||
|
||||
template< typename C >
|
||||
static bool empty( const C& c )
|
||||
{
|
||||
return c.empty();
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< typename C >
|
||||
static iterator begin( C& c )
|
||||
{
|
||||
return c.begin();
|
||||
}
|
||||
|
||||
template< typename C >
|
||||
static const_iterator begin( const C& c )
|
||||
{
|
||||
return c.begin();
|
||||
}
|
||||
|
||||
template< typename C >
|
||||
static iterator end( C& c )
|
||||
{
|
||||
return c.end();
|
||||
}
|
||||
|
||||
template< typename C >
|
||||
static const_iterator end( const C& c )
|
||||
{
|
||||
return c.end();
|
||||
}
|
||||
|
||||
#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< typename C >
|
||||
static result_iterator begin( C& c )
|
||||
{
|
||||
return c.begin();
|
||||
}
|
||||
|
||||
template< typename C >
|
||||
static result_iterator end( C& c )
|
||||
{
|
||||
return c.end();
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct default_container_traits_selector
|
||||
{
|
||||
typedef default_container_traits<T> type;
|
||||
};
|
||||
|
||||
// Pair container traits ---------------------------------------------------------------------
|
||||
|
||||
// pair selector
|
||||
template< typename T, typename U >
|
||||
yes_type is_pair_impl( const std::pair<T,U>* );
|
||||
no_type is_pair_impl( ... );
|
||||
|
||||
template<typename T> struct is_pair
|
||||
{
|
||||
private:
|
||||
static T* t;
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT( bool, value=
|
||||
sizeof(is_pair_impl(t))==sizeof(yes_type) );
|
||||
};
|
||||
|
||||
// pair helper
|
||||
template< typename PairT >
|
||||
struct pair_container_traits
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME PairT::first_type element_type;
|
||||
|
||||
typedef BOOST_STRING_TYPENAME ::boost::detail::
|
||||
iterator_traits<element_type>::value_type value_type;
|
||||
typedef std::size_t size_type;
|
||||
typedef BOOST_STRING_TYPENAME ::boost::detail::
|
||||
iterator_traits<element_type>::difference_type difference_type;
|
||||
|
||||
typedef element_type iterator;
|
||||
typedef element_type const_iterator;
|
||||
typedef element_type result_iterator;
|
||||
|
||||
// static operations
|
||||
template< typename P >
|
||||
static size_type size( const P& p )
|
||||
{
|
||||
difference_type diff = std::distance( p.first, p.second );
|
||||
if ( diff < 0 )
|
||||
return 0;
|
||||
else
|
||||
return diff;
|
||||
}
|
||||
|
||||
template< typename P >
|
||||
static bool empty( const P& p )
|
||||
{
|
||||
return p.first==p.second;
|
||||
}
|
||||
|
||||
template< typename P >
|
||||
static const_iterator begin( const P& p )
|
||||
{
|
||||
return p.first;
|
||||
}
|
||||
|
||||
template< typename P >
|
||||
static const_iterator end( const P& p )
|
||||
{
|
||||
return p.second;
|
||||
}
|
||||
}; // 'pair_container_helper'
|
||||
|
||||
template<typename T>
|
||||
struct pair_container_traits_selector
|
||||
{
|
||||
typedef pair_container_traits<T> type;
|
||||
};
|
||||
|
||||
// Array container traits ---------------------------------------------------------------
|
||||
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
// array traits ( partial specialization )
|
||||
template< typename T >
|
||||
struct array_traits;
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
struct array_traits<T[sz]>
|
||||
{
|
||||
// typedef
|
||||
typedef T* iterator;
|
||||
typedef const T* const_iterator;
|
||||
typedef T value_type;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
// size of the array ( static );
|
||||
BOOST_STATIC_CONSTANT( size_type, array_size = sz );
|
||||
};
|
||||
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
// array traits ( no partial specialization )
|
||||
/*
|
||||
without parial specialization we are able to
|
||||
provide support only for a limited number of
|
||||
types. Currently the primitive numeric types
|
||||
are supported
|
||||
*/
|
||||
template< typename T, typename BaseT >
|
||||
struct array_traits_impl
|
||||
{
|
||||
typedef BaseT value_type;
|
||||
typedef BaseT* iterator;
|
||||
typedef const BaseT* const_iterator;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
// size of the array
|
||||
BOOST_STATIC_CONSTANT( size_type, array_size = sizeof(T)/sizeof(BaseT) );
|
||||
};
|
||||
|
||||
template< typename T, typename BaseT >
|
||||
struct array_traits_impl_selector
|
||||
{
|
||||
typedef array_traits_impl<T,BaseT> type;
|
||||
};
|
||||
|
||||
struct array_traits_void
|
||||
{
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template< typename T, typename BaseT >
|
||||
struct array_traits_cv_selector
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::mpl::apply_if<
|
||||
::boost::is_convertible<T,BaseT*>,
|
||||
array_traits_impl_selector<T,BaseT>,
|
||||
::boost::mpl::apply_if<
|
||||
::boost::is_convertible<T,const BaseT*>,
|
||||
array_traits_impl_selector<T, const BaseT>,
|
||||
::boost::mpl::apply_if<
|
||||
::boost::is_convertible<T, volatile BaseT*>,
|
||||
array_traits_impl_selector<T, volatile BaseT>,
|
||||
array_traits_impl_selector<T, const volatile BaseT>
|
||||
>
|
||||
>
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
struct array_traits_select
|
||||
{
|
||||
template< typename T1, typename T2 >
|
||||
struct apply
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::mpl::apply_if<
|
||||
::boost::is_convertible<T,const volatile T2*>,
|
||||
array_traits_cv_selector<T,T2>,
|
||||
::boost::mpl::identity<T1> >::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
struct array_traits_selector
|
||||
{
|
||||
private:
|
||||
// supported array base types
|
||||
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::mpl::vector10<
|
||||
wchar_t,
|
||||
#else // BOOST_NO_INTRINSIC_WCHAR_T
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::mpl::vector9<
|
||||
#endif // BOOST_NO_INTRINSIC_WCHAR_T
|
||||
char,
|
||||
signed char,
|
||||
unsigned char,
|
||||
signed short,
|
||||
unsigned short,
|
||||
signed int,
|
||||
unsigned int,
|
||||
signed long,
|
||||
unsigned long
|
||||
>::type array_base_types;
|
||||
|
||||
public:
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::mpl::fold<
|
||||
array_base_types,
|
||||
::boost::algorithm::detail::array_traits_void,
|
||||
::boost::algorithm::detail::array_traits_select<T> >::type type;
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
struct array_traits
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
array_traits_selector<T>::type traits_type;
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
traits_type::value_type value_type;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
traits_type::iterator iterator;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
traits_type::const_iterator const_iterator;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
traits_type::size_type size_type;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
traits_type::difference_type difference_type;
|
||||
|
||||
BOOST_STATIC_CONSTANT( size_type, array_size = traits_type::array_size );
|
||||
};
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
// array lenght resolving
|
||||
/*
|
||||
Lenght of string contained in a static array could
|
||||
be different from the size of the array.
|
||||
For string processing we need the lenght without
|
||||
terminating 0.
|
||||
|
||||
Therefore, the lenght is calulated for char and wchar_t
|
||||
using char_traits, rather then simply returning
|
||||
the array size.
|
||||
*/
|
||||
template< typename T >
|
||||
struct array_length_selector
|
||||
{
|
||||
template< typename TraitsT >
|
||||
struct array_length
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
TraitsT::size_type size_type;
|
||||
|
||||
BOOST_STATIC_CONSTANT(
|
||||
size_type,
|
||||
array_size=TraitsT::array_size );
|
||||
|
||||
template< typename A >
|
||||
static size_type length( const A& )
|
||||
{
|
||||
return array_size;
|
||||
}
|
||||
|
||||
template< typename A >
|
||||
static bool empty( const A& )
|
||||
{
|
||||
return array_size==0;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// specialization for char
|
||||
template<>
|
||||
struct array_length_selector<char>
|
||||
{
|
||||
template< typename TraitsT >
|
||||
struct array_length
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
TraitsT::size_type size_type;
|
||||
|
||||
template< typename A >
|
||||
static size_type length( const A& a )
|
||||
{
|
||||
if ( a==0 )
|
||||
return 0;
|
||||
else
|
||||
return std::char_traits<char>::length(a);
|
||||
}
|
||||
|
||||
template< typename A >
|
||||
static bool empty( const A& a )
|
||||
{
|
||||
return a==0 || a[0]==0;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// specialization for wchar_t
|
||||
template<>
|
||||
struct array_length_selector<wchar_t>
|
||||
{
|
||||
template< typename TraitsT >
|
||||
struct array_length
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
TraitsT::size_type size_type;
|
||||
|
||||
template< typename A >
|
||||
static size_type length( const A& a )
|
||||
{
|
||||
if ( a==0 )
|
||||
return 0;
|
||||
else
|
||||
return std::char_traits<wchar_t>::length(a);
|
||||
}
|
||||
|
||||
template< typename A >
|
||||
static bool empty( const A& a )
|
||||
{
|
||||
return a==0 || a[0]==0;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
struct array_container_traits
|
||||
{
|
||||
private:
|
||||
// resolve array traits
|
||||
typedef array_traits<T> traits_type;
|
||||
|
||||
public:
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
traits_type::value_type value_type;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
traits_type::iterator iterator;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
traits_type::const_iterator const_iterator;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
traits_type::size_type size_type;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
traits_type::difference_type difference_type;
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::mpl::if_< ::boost::is_const<T>,
|
||||
const_iterator,
|
||||
iterator
|
||||
>::type result_iterator;
|
||||
|
||||
private:
|
||||
// resolve array size
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::remove_cv<value_type>::type char_type;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
array_length_selector<char_type>::
|
||||
BOOST_NESTED_TEMPLATE array_length<traits_type> array_length_type;
|
||||
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT( size_type, array_size = traits_type::array_size );
|
||||
|
||||
// static operations
|
||||
template< typename A >
|
||||
static size_type size( const A& a )
|
||||
{
|
||||
return array_length_type::length(a);
|
||||
}
|
||||
|
||||
template< typename A >
|
||||
static bool empty( const A& a )
|
||||
{
|
||||
return array_length_type::empty(a);
|
||||
}
|
||||
|
||||
|
||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< typename A >
|
||||
static iterator begin( A& a )
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
template< typename A >
|
||||
static const_iterator begin( const A& a )
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
template< typename A >
|
||||
static iterator end( A& a )
|
||||
{
|
||||
return a+array_length_type::length(a);
|
||||
}
|
||||
|
||||
template< typename A >
|
||||
static const_iterator end( const A& a )
|
||||
{
|
||||
return a+array_length_type::length(a);
|
||||
}
|
||||
|
||||
#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< typename A >
|
||||
static result_iterator begin( A& a )
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
template< typename A >
|
||||
static result_iterator end( A& a )
|
||||
{
|
||||
return a+array_length_type::length(a);
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct array_container_traits_selector
|
||||
{
|
||||
typedef array_container_traits<T> type;
|
||||
};
|
||||
|
||||
// Pointer container traits ---------------------------------------------------------------
|
||||
|
||||
template<typename T>
|
||||
struct pointer_container_traits
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::remove_pointer<T>::type value_type;
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::remove_cv<value_type>::type char_type;
|
||||
typedef ::std::char_traits<char_type> char_traits;
|
||||
|
||||
typedef value_type* iterator;
|
||||
typedef const value_type* const_iterator;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef std::size_t size_type;
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::mpl::if_< ::boost::is_const<T>,
|
||||
const_iterator,
|
||||
iterator
|
||||
>::type result_iterator;
|
||||
|
||||
// static operations
|
||||
template< typename P >
|
||||
static size_type size( const P& p )
|
||||
{
|
||||
if ( p==0 )
|
||||
return 0;
|
||||
else
|
||||
return char_traits::length(p);
|
||||
}
|
||||
|
||||
template< typename P >
|
||||
static bool empty( const P& p )
|
||||
{
|
||||
return p==0 || p[0]==0;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< typename P >
|
||||
static iterator begin( P& p )
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
template< typename P >
|
||||
static const_iterator begin( const P& p )
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
template< typename P >
|
||||
static iterator end( P& p )
|
||||
{
|
||||
if ( p==0 )
|
||||
return p;
|
||||
else
|
||||
return p+char_traits::length(p);
|
||||
}
|
||||
|
||||
template< typename P >
|
||||
static const_iterator end( const P& p )
|
||||
{
|
||||
if ( p==0 )
|
||||
return p;
|
||||
else
|
||||
return p+char_traits::length(p);
|
||||
}
|
||||
|
||||
#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< typename P >
|
||||
static result_iterator begin( P& p )
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
template< typename P >
|
||||
static result_iterator end( P& p )
|
||||
{
|
||||
if ( p==0 )
|
||||
return p;
|
||||
else
|
||||
return p+char_traits::length(p);
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct pointer_container_traits_selector
|
||||
{
|
||||
typedef pointer_container_traits<T> type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_DETAIL_COLLECTION_HPP
|
@ -11,7 +11,9 @@
|
||||
#define BOOST_STRING_FIND_FORMAT_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/algorithm/string/iterator_range.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/algorithm/string/detail/find_format_store.hpp>
|
||||
#include <boost/algorithm/string/detail/replace_storage.hpp>
|
||||
|
||||
@ -60,7 +62,7 @@ namespace boost {
|
||||
{
|
||||
typedef find_format_store<
|
||||
BOOST_STRING_TYPENAME
|
||||
const_iterator_of<InputT>::type,
|
||||
range_const_iterator<InputT>::type,
|
||||
FormatterT,
|
||||
FormatResultT > store_type;
|
||||
|
||||
@ -121,7 +123,7 @@ namespace boost {
|
||||
{
|
||||
typedef find_format_store<
|
||||
BOOST_STRING_TYPENAME
|
||||
const_iterator_of<InputT>::type,
|
||||
range_const_iterator<InputT>::type,
|
||||
FormatterT,
|
||||
FormatResultT > store_type;
|
||||
|
||||
@ -174,14 +176,14 @@ namespace boost {
|
||||
typename FormatResultT >
|
||||
inline void find_format_impl2(
|
||||
InputT& Input,
|
||||
FinderT Finder,
|
||||
FinderT,
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult,
|
||||
const FormatResultT& FormatResult)
|
||||
{
|
||||
typedef find_format_store<
|
||||
BOOST_STRING_TYPENAME
|
||||
iterator_of<InputT>::type,
|
||||
range_iterator<InputT>::type,
|
||||
FormatterT,
|
||||
FormatResultT > store_type;
|
||||
|
||||
|
@ -11,7 +11,9 @@
|
||||
#define BOOST_STRING_FIND_FORMAT_ALL_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/algorithm/string/iterator_range.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <boost/algorithm/string/detail/find_format_store.hpp>
|
||||
#include <boost/algorithm/string/detail/replace_storage.hpp>
|
||||
|
||||
@ -59,7 +61,7 @@ namespace boost {
|
||||
const FormatResultT& FormatResult )
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
const_iterator_of<InputT>::type input_iterator_type;
|
||||
range_const_iterator<InputT>::type input_iterator_type;
|
||||
|
||||
typedef find_format_store<
|
||||
input_iterator_type,
|
||||
@ -72,7 +74,7 @@ namespace boost {
|
||||
// Initialize last match
|
||||
input_iterator_type LastMatch=begin(Input);
|
||||
|
||||
// Iterate throug all matches
|
||||
// Iterate through all matches
|
||||
while( M )
|
||||
{
|
||||
// Copy the beginning of the sequence
|
||||
@ -126,7 +128,7 @@ namespace boost {
|
||||
const FormatResultT& FormatResult)
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
const_iterator_of<InputT>::type input_iterator_type;
|
||||
range_const_iterator<InputT>::type input_iterator_type;
|
||||
|
||||
typedef find_format_store<
|
||||
input_iterator_type,
|
||||
@ -142,7 +144,7 @@ namespace boost {
|
||||
// Output temporary
|
||||
InputT Output;
|
||||
|
||||
// Iterate throug all matches
|
||||
// Iterate through all matches
|
||||
while( M )
|
||||
{
|
||||
// Copy the beginning of the sequence
|
||||
@ -196,7 +198,7 @@ namespace boost {
|
||||
FormatResultT FormatResult)
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
iterator_of<InputT>::type input_iterator_type;
|
||||
range_iterator<InputT>::type input_iterator_type;
|
||||
typedef find_format_store<
|
||||
input_iterator_type,
|
||||
FormatterT,
|
||||
@ -207,7 +209,7 @@ namespace boost {
|
||||
|
||||
// Instantiate replacement storage
|
||||
std::deque<
|
||||
BOOST_STRING_TYPENAME value_type_of<InputT>::type> Storage;
|
||||
BOOST_STRING_TYPENAME range_value<InputT>::type> Storage;
|
||||
|
||||
// Initialize replacement iterators
|
||||
input_iterator_type InsertIt=begin(Input);
|
||||
|
@ -11,8 +11,7 @@
|
||||
#define BOOST_STRING_FIND_FORMAT_STORE_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
#include <boost/algorithm/string/iterator_range.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
@ -36,7 +35,7 @@ namespace boost {
|
||||
public:
|
||||
// Construction
|
||||
find_format_store(
|
||||
const base_type FindResult,
|
||||
const base_type& FindResult,
|
||||
const format_result_type& FormatResult,
|
||||
const formatter_type& Formatter ) :
|
||||
base_type(FindResult),
|
||||
|
@ -11,7 +11,7 @@
|
||||
#define BOOST_STRING_FIND_ITERATOR_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/algorithm/string/iterator_range.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/iterator/iterator_facade.hpp>
|
||||
#include <boost/iterator/iterator_categories.hpp>
|
||||
#include <boost/function.hpp>
|
||||
|
@ -13,8 +13,11 @@
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/algorithm/string/constants.hpp>
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
#include <boost/algorithm/string/iterator_range.hpp>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/empty.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
@ -25,7 +28,7 @@ namespace boost {
|
||||
|
||||
// find a subsequence in the sequence ( functor )
|
||||
/*
|
||||
Returns a pair <begin,end> marking the subsequence in the sequence.
|
||||
Returns a pair <begin,end> marking the subsequence in the sequence.
|
||||
If the find fails, functor returns <End,End>
|
||||
*/
|
||||
template<typename SearchIteratorT,typename PredicateT>
|
||||
@ -35,9 +38,9 @@ namespace boost {
|
||||
|
||||
// Construction
|
||||
template< typename SearchT >
|
||||
first_finderF( const SearchT& Search, PredicateT Comp ) :
|
||||
first_finderF( const SearchT& Search, PredicateT Comp ) :
|
||||
m_Search(begin(Search), end(Search)), m_Comp(Comp) {}
|
||||
first_finderF(
|
||||
first_finderF(
|
||||
search_iterator_type SearchBegin,
|
||||
search_iterator_type SearchEnd,
|
||||
PredicateT Comp ) :
|
||||
@ -46,8 +49,8 @@ namespace boost {
|
||||
// Operation
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
operator()(
|
||||
ForwardIteratorT Begin,
|
||||
operator()(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End ) const
|
||||
{
|
||||
typedef iterator_range<ForwardIteratorT> result_type;
|
||||
@ -58,8 +61,8 @@ namespace boost {
|
||||
OuterIt!=End;
|
||||
++OuterIt)
|
||||
{
|
||||
// Sanity check
|
||||
if( empty(m_Search) )
|
||||
// Sanity check
|
||||
if( boost::empty(m_Search) )
|
||||
return result_type( End, End );
|
||||
|
||||
input_iterator_type InnerIt=OuterIt;
|
||||
@ -68,7 +71,7 @@ namespace boost {
|
||||
InnerIt!=End && SubstrIt!=m_Search.end();
|
||||
++InnerIt,++SubstrIt)
|
||||
{
|
||||
if( !( m_Comp(*InnerIt,*SubstrIt) ) )
|
||||
if( !( m_Comp(*InnerIt,*SubstrIt) ) )
|
||||
break;
|
||||
}
|
||||
|
||||
@ -89,7 +92,7 @@ namespace boost {
|
||||
|
||||
// find the last match a subsequnce in the sequence ( functor )
|
||||
/*
|
||||
Returns a pair <begin,end> marking the subsequence in the sequence.
|
||||
Returns a pair <begin,end> marking the subsequence in the sequence.
|
||||
If the find fails, returns <End,End>
|
||||
*/
|
||||
template<typename SearchIteratorT, typename PredicateT>
|
||||
@ -102,9 +105,9 @@ namespace boost {
|
||||
|
||||
// Construction
|
||||
template< typename SearchT >
|
||||
last_finderF( const SearchT& Search, PredicateT Comp ) :
|
||||
last_finderF( const SearchT& Search, PredicateT Comp ) :
|
||||
m_Search(begin(Search), end(Search)), m_Comp(Comp) {}
|
||||
last_finderF(
|
||||
last_finderF(
|
||||
search_iterator_type SearchBegin,
|
||||
search_iterator_type SearchEnd,
|
||||
PredicateT Comp ) :
|
||||
@ -113,34 +116,34 @@ namespace boost {
|
||||
// Operation
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
operator()(
|
||||
ForwardIteratorT Begin,
|
||||
operator()(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End ) const
|
||||
{
|
||||
typedef iterator_range<ForwardIteratorT> result_type;
|
||||
|
||||
if( empty(m_Search) )
|
||||
if( boost::empty(m_Search) )
|
||||
return result_type( End, End );
|
||||
|
||||
typedef BOOST_STRING_TYPENAME boost::detail::
|
||||
iterator_traits<ForwardIteratorT>::iterator_category category;
|
||||
|
||||
return findit( Begin, End, category() );
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
// forward iterator
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
findit(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End,
|
||||
findit(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End,
|
||||
std::forward_iterator_tag ) const
|
||||
{
|
||||
typedef ForwardIteratorT input_iterator_type;
|
||||
typedef iterator_range<ForwardIteratorT> result_type;
|
||||
|
||||
first_finder_type first_finder(
|
||||
first_finder_type first_finder(
|
||||
m_Search.begin(), m_Search.end(), m_Comp );
|
||||
|
||||
result_type M=first_finder( Begin, End );
|
||||
@ -158,9 +161,9 @@ namespace boost {
|
||||
// bidirectional iterator
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
findit(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End,
|
||||
findit(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End,
|
||||
std::bidirectional_iterator_tag ) const
|
||||
{
|
||||
typedef iterator_range<ForwardIteratorT> result_type;
|
||||
@ -178,7 +181,7 @@ namespace boost {
|
||||
InnerIt!=End && SubstrIt!=m_Search.end();
|
||||
++InnerIt,++SubstrIt)
|
||||
{
|
||||
if( !( m_Comp(*InnerIt,*SubstrIt) ) )
|
||||
if( !( m_Comp(*InnerIt,*SubstrIt) ) )
|
||||
break;
|
||||
}
|
||||
|
||||
@ -194,12 +197,12 @@ namespace boost {
|
||||
iterator_range<search_iterator_type> m_Search;
|
||||
PredicateT m_Comp;
|
||||
};
|
||||
|
||||
|
||||
// find n-th functor -----------------------------------------------//
|
||||
|
||||
// find the n-th match of a subsequnce in the sequence ( functor )
|
||||
/*
|
||||
Returns a pair <begin,end> marking the subsequence in the sequence.
|
||||
Returns a pair <begin,end> marking the subsequence in the sequence.
|
||||
If the find fails, returns <End,End>
|
||||
*/
|
||||
template<typename SearchIteratorT, typename PredicateT>
|
||||
@ -212,50 +215,50 @@ namespace boost {
|
||||
|
||||
// Construction
|
||||
template< typename SearchT >
|
||||
nth_finderF(
|
||||
const SearchT& Search,
|
||||
nth_finderF(
|
||||
const SearchT& Search,
|
||||
unsigned int Nth,
|
||||
PredicateT Comp) :
|
||||
m_Search(begin(Search), end(Search)),
|
||||
PredicateT Comp) :
|
||||
m_Search(begin(Search), end(Search)),
|
||||
m_Nth(Nth),
|
||||
m_Comp(Comp) {}
|
||||
nth_finderF(
|
||||
nth_finderF(
|
||||
search_iterator_type SearchBegin,
|
||||
search_iterator_type SearchEnd,
|
||||
unsigned int Nth,
|
||||
PredicateT Comp) :
|
||||
m_Search(SearchBegin, SearchEnd),
|
||||
m_Search(SearchBegin, SearchEnd),
|
||||
m_Nth(Nth),
|
||||
m_Comp(Comp) {}
|
||||
|
||||
// Operation
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
operator()(
|
||||
ForwardIteratorT Begin,
|
||||
operator()(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End ) const
|
||||
{
|
||||
typedef ForwardIteratorT input_iterator_type;
|
||||
typedef iterator_range<ForwardIteratorT> result_type;
|
||||
|
||||
// Sanity check
|
||||
if( empty(m_Search) )
|
||||
// Sanity check
|
||||
if( boost::empty(m_Search) )
|
||||
return result_type( End, End );
|
||||
|
||||
// Instantiate find funtor
|
||||
first_finder_type first_finder(
|
||||
// Instantiate find funtor
|
||||
first_finder_type first_finder(
|
||||
m_Search.begin(), m_Search.end(), m_Comp );
|
||||
|
||||
result_type M( Begin, Begin );
|
||||
|
||||
for( unsigned int n=0; n<=m_Nth; ++n )
|
||||
{
|
||||
// find next match
|
||||
// find next match
|
||||
M=first_finder( end(M), End );
|
||||
|
||||
if ( !M )
|
||||
{
|
||||
// Subsequence not found, return
|
||||
// Subsequence not found, return
|
||||
return M;
|
||||
}
|
||||
}
|
||||
@ -273,8 +276,8 @@ namespace boost {
|
||||
|
||||
// find a head in the sequence ( functor )
|
||||
/*
|
||||
This functor find a head of the specified range. For
|
||||
a specified N, the head is a subsequence of N starting
|
||||
This functor find a head of the specified range. For
|
||||
a specified N, the head is a subsequence of N starting
|
||||
elements of the range.
|
||||
*/
|
||||
struct head_finderF
|
||||
@ -285,8 +288,8 @@ namespace boost {
|
||||
// Operation
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
operator()(
|
||||
ForwardIteratorT Begin,
|
||||
operator()(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End ) const
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME boost::detail::
|
||||
@ -299,7 +302,7 @@ namespace boost {
|
||||
// Find operation implementation
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
findit(
|
||||
findit(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End,
|
||||
std::forward_iterator_tag ) const
|
||||
@ -309,15 +312,15 @@ namespace boost {
|
||||
|
||||
input_iterator_type It=Begin;
|
||||
for(
|
||||
unsigned int Index=0;
|
||||
unsigned int Index=0;
|
||||
Index<m_N && It!=End; ++Index,++It ) {};
|
||||
|
||||
|
||||
return result_type( Begin, It );
|
||||
}
|
||||
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
findit(
|
||||
findit(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End,
|
||||
std::random_access_iterator_tag ) const
|
||||
@ -339,8 +342,8 @@ namespace boost {
|
||||
|
||||
// find a tail in the sequence ( functor )
|
||||
/*
|
||||
This functor find a tail of the specified range. For
|
||||
a specified N, the head is a subsequence of N starting
|
||||
This functor find a tail of the specified range. For
|
||||
a specified N, the head is a subsequence of N starting
|
||||
elements of the range.
|
||||
*/
|
||||
struct tail_finderF
|
||||
@ -351,8 +354,8 @@ namespace boost {
|
||||
// Operation
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
operator()(
|
||||
ForwardIteratorT Begin,
|
||||
operator()(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End ) const
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME boost::detail::
|
||||
@ -365,7 +368,7 @@ namespace boost {
|
||||
// Find operation implementation
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
findit(
|
||||
findit(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End,
|
||||
std::forward_iterator_tag ) const
|
||||
@ -373,10 +376,10 @@ namespace boost {
|
||||
typedef ForwardIteratorT input_iterator_type;
|
||||
typedef iterator_range<ForwardIteratorT> result_type;
|
||||
|
||||
unsigned int Index=0;
|
||||
unsigned int Index=0;
|
||||
input_iterator_type It=Begin;
|
||||
input_iterator_type It2=Begin;
|
||||
|
||||
|
||||
// Advance It2 by N incremets
|
||||
for( Index=0; Index<m_N && It2!=End; ++Index,++It2 ) {};
|
||||
|
||||
@ -388,7 +391,7 @@ namespace boost {
|
||||
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
findit(
|
||||
findit(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End,
|
||||
std::bidirectional_iterator_tag ) const
|
||||
@ -398,15 +401,15 @@ namespace boost {
|
||||
|
||||
input_iterator_type It=End;
|
||||
for(
|
||||
unsigned int Index=0;
|
||||
unsigned int Index=0;
|
||||
Index<m_N && It!=Begin; ++Index,--It ) {};
|
||||
|
||||
|
||||
return result_type( It, End );
|
||||
}
|
||||
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
findit(
|
||||
findit(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End,
|
||||
std::random_access_iterator_tag ) const
|
||||
@ -414,7 +417,7 @@ namespace boost {
|
||||
typedef ForwardIteratorT input_iterator_type;
|
||||
typedef iterator_range<ForwardIteratorT> result_type;
|
||||
|
||||
if ( (End<=Begin) || ( static_cast<unsigned int>(End-Begin) < m_N ) )
|
||||
if ( (End<=Begin) || ( static_cast<unsigned int>(End-Begin) < m_N ) )
|
||||
return result_type( Begin, End );
|
||||
|
||||
return result_type( End-m_N, End );
|
||||
@ -434,29 +437,29 @@ namespace boost {
|
||||
with an exception that it return range instead of a single
|
||||
iterator.
|
||||
|
||||
If bCompress is set to true, adjacent matching tokens are
|
||||
If bCompress is set to true, adjacent matching tokens are
|
||||
concatenated into one match.
|
||||
*/
|
||||
template< typename PredicateT >
|
||||
struct token_finderF
|
||||
{
|
||||
// Construction
|
||||
token_finderF(
|
||||
PredicateT Pred,
|
||||
token_compress_mode_type eCompress=token_compress_off ) :
|
||||
token_finderF(
|
||||
PredicateT Pred,
|
||||
token_compress_mode_type eCompress=token_compress_off ) :
|
||||
m_Pred(Pred), m_eCompress(eCompress) {}
|
||||
|
||||
// Operation
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
operator()(
|
||||
ForwardIteratorT Begin,
|
||||
operator()(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End ) const
|
||||
{
|
||||
typedef iterator_range<ForwardIteratorT> result_type;
|
||||
|
||||
ForwardIteratorT It=std::find_if( Begin, End, m_Pred );
|
||||
|
||||
|
||||
if( It==End )
|
||||
{
|
||||
return result_type( End, End );
|
||||
@ -468,11 +471,11 @@ namespace boost {
|
||||
if( m_eCompress==token_compress_on )
|
||||
{
|
||||
// Find first non-matching character
|
||||
while( m_Pred(*It2) && It2!=End ) ++It2;
|
||||
while( It2!=End && m_Pred(*It2) ) ++It2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Advance by one possition
|
||||
// Advance by one possition
|
||||
++It2;
|
||||
}
|
||||
|
||||
@ -499,21 +502,27 @@ namespace boost {
|
||||
typedef iterator_range<input_iterator_type> result_type;
|
||||
|
||||
// Construction
|
||||
range_finderF(
|
||||
input_iterator_type Begin,
|
||||
range_finderF(
|
||||
input_iterator_type Begin,
|
||||
input_iterator_type End ) : m_Range(Begin, End) {}
|
||||
|
||||
range_finderF(const iterator_range<input_iterator_type>& Range) :
|
||||
range_finderF(const iterator_range<input_iterator_type>& Range) :
|
||||
m_Range(Range) {}
|
||||
|
||||
// Operation
|
||||
template< typename ForwardIterator2T >
|
||||
iterator_range<ForwardIterator2T>
|
||||
operator()(
|
||||
ForwardIterator2T,
|
||||
iterator_range<ForwardIterator2T>
|
||||
operator()(
|
||||
ForwardIterator2T,
|
||||
ForwardIterator2T ) const
|
||||
{
|
||||
#if BOOST_WORKAROUND( __MWERKS__, <= 0x3003 )
|
||||
return iterator_range<const ForwardIterator2T>(this->m_Range);
|
||||
#elif BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
return iterator_range<ForwardIterator2T>(m_Range.begin(), m_Range.end());
|
||||
#else
|
||||
return m_Range;
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -12,8 +12,10 @@
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/algorithm/string/iterator_range.hpp>
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
@ -29,7 +31,6 @@ namespace boost {
|
||||
typedef regex_search_result<IteratorT> type;
|
||||
typedef iterator_range<IteratorT> base_type;
|
||||
typedef BOOST_STRING_TYPENAME base_type::value_type value_type;
|
||||
typedef BOOST_STRING_TYPENAME base_type::reference reference;
|
||||
typedef BOOST_STRING_TYPENAME base_type::difference_type difference_type;
|
||||
typedef BOOST_STRING_TYPENAME base_type::const_iterator const_iterator;
|
||||
typedef BOOST_STRING_TYPENAME base_type::iterator iterator;
|
||||
|
@ -10,8 +10,12 @@
|
||||
#ifndef BOOST_STRING_FORMATTER_DETAIL_HPP
|
||||
#define BOOST_STRING_FORMATTER_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
#include <boost/algorithm/string/iterator_range.hpp>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
|
||||
#include <boost/algorithm/string/detail/util.hpp>
|
||||
|
||||
// generic replace functors -----------------------------------------------//
|
||||
@ -23,22 +27,30 @@ namespace boost {
|
||||
// const format functor ----------------------------------------------------//
|
||||
|
||||
// constant format functor
|
||||
template<typename CollectionT>
|
||||
template<typename RangeT>
|
||||
struct const_formatF
|
||||
{
|
||||
private:
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
const_iterator_of<CollectionT>::type format_iterator;
|
||||
range_const_iterator<RangeT>::type format_iterator;
|
||||
typedef iterator_range<format_iterator> result_type;
|
||||
|
||||
public:
|
||||
// Construction
|
||||
const_formatF(const CollectionT& Format) :
|
||||
const_formatF(const RangeT& Format) :
|
||||
m_Format(begin(Format), end(Format)) {}
|
||||
|
||||
// Operation
|
||||
template<typename Collection2T>
|
||||
const result_type& operator()(const Collection2T&) const
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
template<typename Range2T>
|
||||
result_type& operator()(const Range2T&)
|
||||
{
|
||||
return m_Format;
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename Range2T>
|
||||
const result_type& operator()(const Range2T&) const
|
||||
{
|
||||
return m_Format;
|
||||
}
|
||||
@ -50,14 +62,14 @@ namespace boost {
|
||||
// identity format functor ----------------------------------------------------//
|
||||
|
||||
// identity format functor
|
||||
template<typename CollectionT>
|
||||
template<typename RangeT>
|
||||
struct identity_formatF
|
||||
{
|
||||
// Operation
|
||||
template< typename Collection2T >
|
||||
const CollectionT& operator()(const Collection2T& Replace) const
|
||||
template< typename Range2T >
|
||||
const RangeT& operator()(const Range2T& Replace) const
|
||||
{
|
||||
return CollectionT(begin(Replace), end(Replace));
|
||||
return RangeT(begin(Replace), end(Replace));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -13,9 +13,7 @@
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <algorithm>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
#include <boost/algorithm/string/sequence_traits.hpp>
|
||||
#include <boost/algorithm/string/iterator_range.hpp>
|
||||
#include <boost/algorithm/string/detail/sequence.hpp>
|
||||
|
||||
namespace boost {
|
||||
@ -123,6 +121,7 @@ namespace boost {
|
||||
ForwardIteratorT InsertIt,
|
||||
ForwardIteratorT SegmentBegin,
|
||||
ForwardIteratorT SegmentEnd )
|
||||
|
||||
{
|
||||
// Call replace to do the job
|
||||
replace( Input, InsertIt, SegmentBegin, Storage );
|
||||
|
@ -13,7 +13,9 @@
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/logical.hpp>
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
#include <boost/algorithm/string/sequence_traits.hpp>
|
||||
|
||||
namespace boost {
|
||||
@ -110,7 +112,14 @@ namespace boost {
|
||||
BOOST_STRING_TYPENAME InputT::iterator At=Input.erase( From, To );
|
||||
if ( Begin!=End )
|
||||
{
|
||||
Input.insert( At, Begin, End );
|
||||
if(!Input.empty())
|
||||
{
|
||||
Input.insert( At, Begin, End );
|
||||
}
|
||||
else
|
||||
{
|
||||
Input.insert( Input.begin(), Begin, End );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -172,7 +181,14 @@ namespace boost {
|
||||
BOOST_STRING_TYPENAME InputT::iterator To,
|
||||
const InsertT& Insert )
|
||||
{
|
||||
replace( Input, From, To, begin(Insert), end(Insert) );
|
||||
if(From!=To)
|
||||
{
|
||||
replace( Input, From, To, begin(Insert), end(Insert) );
|
||||
}
|
||||
else
|
||||
{
|
||||
insert( Input, From, begin(Insert), end(Insert) );
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <functional>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
@ -22,7 +23,7 @@ namespace boost {
|
||||
// empty_container
|
||||
/*
|
||||
This class represents always empty container,
|
||||
containing elemets of type CharT.
|
||||
containing elements of type CharT.
|
||||
|
||||
It is supposed to be used in a const version only
|
||||
*/
|
||||
@ -92,7 +93,7 @@ namespace boost {
|
||||
{
|
||||
SeqT operator()( const iterator_range<IteratorT>& Range ) const
|
||||
{
|
||||
return copy_iterator_range<SeqT>(Range);
|
||||
return copy_range<SeqT>(Range);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -11,8 +11,13 @@
|
||||
#define BOOST_STRING_ERASE_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
#include <boost/algorithm/string/iterator_range.hpp>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
|
||||
#include <boost/algorithm/string/find_format.hpp>
|
||||
#include <boost/algorithm/string/finder.hpp>
|
||||
#include <boost/algorithm/string/formatter.hpp>
|
||||
@ -40,13 +45,13 @@ namespace boost {
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename OutputIteratorT, typename CollectionT>
|
||||
template<typename OutputIteratorT, typename RangeT>
|
||||
inline OutputIteratorT erase_range_copy(
|
||||
OutputIteratorT Output,
|
||||
const CollectionT& Input,
|
||||
const RangeT& Input,
|
||||
const iterator_range<
|
||||
BOOST_STRING_TYPENAME
|
||||
const_iterator_of<CollectionT>::type>& SearchRange )
|
||||
range_const_iterator<RangeT>::type>& SearchRange )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
@ -64,7 +69,7 @@ namespace boost {
|
||||
const SequenceT& Input,
|
||||
const iterator_range<
|
||||
BOOST_STRING_TYPENAME
|
||||
const_iterator_of<SequenceT>::type>& SearchRange )
|
||||
range_const_iterator<SequenceT>::type>& SearchRange )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
@ -85,7 +90,7 @@ namespace boost {
|
||||
SequenceT& Input,
|
||||
const iterator_range<
|
||||
BOOST_STRING_TYPENAME
|
||||
iterator_of<SequenceT>::type>& SearchRange )
|
||||
range_iterator<SequenceT>::type>& SearchRange )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
@ -97,7 +102,7 @@ namespace boost {
|
||||
|
||||
//! Erase first algorithm
|
||||
/*!
|
||||
Remove the first occurence of the substring from the input.
|
||||
Remove the first occurrence of the substring from the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
@ -111,12 +116,12 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Collection1T,
|
||||
typename Collection2T>
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT erase_first_copy(
|
||||
OutputIteratorT Output,
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Search )
|
||||
const Range1T& Input,
|
||||
const Range2T& Search )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
@ -129,10 +134,10 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT erase_first_copy(
|
||||
const SequenceT& Input,
|
||||
const CollectionT& Search )
|
||||
const RangeT& Search )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
@ -142,16 +147,16 @@ namespace boost {
|
||||
|
||||
//! Erase first algorithm
|
||||
/*!
|
||||
Remove the first occurence of the substring from the input.
|
||||
Remove the first occurrence of the substring from the input.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for.
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void erase_first(
|
||||
SequenceT& Input,
|
||||
const CollectionT& Search )
|
||||
const RangeT& Search )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
@ -163,7 +168,7 @@ namespace boost {
|
||||
|
||||
//! Erase first algorithm ( case insensitive )
|
||||
/*!
|
||||
Remove the first occurence of the substring from the input.
|
||||
Remove the first occurrence of the substring from the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
Searching is case insensitive.
|
||||
@ -179,12 +184,12 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Collection1T,
|
||||
typename Collection2T>
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT ierase_first_copy(
|
||||
OutputIteratorT Output,
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Search,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
@ -198,10 +203,10 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT ierase_first_copy(
|
||||
const SequenceT& Input,
|
||||
const CollectionT& Search,
|
||||
const RangeT& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
@ -212,17 +217,17 @@ namespace boost {
|
||||
|
||||
//! Erase first algorithm ( case insensitive )
|
||||
/*!
|
||||
Remove the first occurence of the substring from the input.
|
||||
Remove the first occurrence of the substring from the input.
|
||||
The input sequence is modified in-place. Searching is case insensitive.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void ierase_first(
|
||||
SequenceT& Input,
|
||||
const CollectionT& Search,
|
||||
const RangeT& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
find_format(
|
||||
@ -235,7 +240,7 @@ namespace boost {
|
||||
|
||||
//! Erase last algorithm
|
||||
/*!
|
||||
Remove the last occurence of the substring from the input.
|
||||
Remove the last occurrence of the substring from the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
@ -249,12 +254,12 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Collection1T,
|
||||
typename Collection2T>
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT erase_last_copy(
|
||||
OutputIteratorT Output,
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Search )
|
||||
const Range1T& Input,
|
||||
const Range2T& Search )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
@ -267,10 +272,10 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT erase_last_copy(
|
||||
const SequenceT& Input,
|
||||
const CollectionT& Search )
|
||||
const RangeT& Search )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
@ -280,16 +285,16 @@ namespace boost {
|
||||
|
||||
//! Erase last algorithm
|
||||
/*!
|
||||
Remove the last occurence of the substring from the input.
|
||||
Remove the last occurrence of the substring from the input.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void erase_last(
|
||||
SequenceT& Input,
|
||||
const CollectionT& Search )
|
||||
const RangeT& Search )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
@ -301,7 +306,7 @@ namespace boost {
|
||||
|
||||
//! Erase last algorithm ( case insensitive )
|
||||
/*!
|
||||
Remove the last occurence of the substring from the input.
|
||||
Remove the last occurrence of the substring from the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
Searching is case insensitive.
|
||||
@ -317,12 +322,12 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Collection1T,
|
||||
typename Collection2T>
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT ierase_last_copy(
|
||||
OutputIteratorT Output,
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Search,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
@ -336,10 +341,10 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT ierase_last_copy(
|
||||
const SequenceT& Input,
|
||||
const CollectionT& Search,
|
||||
const RangeT& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
@ -350,17 +355,17 @@ namespace boost {
|
||||
|
||||
//! Erase last algorithm ( case insensitive )
|
||||
/*!
|
||||
Remove the last occurence of the substring from the input.
|
||||
Remove the last occurrence of the substring from the input.
|
||||
The input sequence is modified in-place. Searching is case insensitive.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void ierase_last(
|
||||
SequenceT& Input,
|
||||
const CollectionT& Search,
|
||||
const RangeT& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
find_format(
|
||||
@ -373,7 +378,7 @@ namespace boost {
|
||||
|
||||
//! Erase nth algorithm
|
||||
/*!
|
||||
Remove the Nth occurence of the substring in the input.
|
||||
Remove the Nth occurrence of the substring in the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
@ -389,12 +394,12 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Collection1T,
|
||||
typename Collection2T>
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT erase_nth_copy(
|
||||
OutputIteratorT Output,
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Search,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
unsigned int Nth )
|
||||
{
|
||||
return find_format_copy(
|
||||
@ -408,10 +413,10 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT erase_nth_copy(
|
||||
const SequenceT& Input,
|
||||
const CollectionT& Search,
|
||||
const RangeT& Search,
|
||||
unsigned int Nth )
|
||||
{
|
||||
return find_format_copy(
|
||||
@ -422,17 +427,17 @@ namespace boost {
|
||||
|
||||
//! Erase nth algorithm
|
||||
/*!
|
||||
Remove the Nth occurence of the substring in the input.
|
||||
Remove the Nth occurrence of the substring in the input.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for.
|
||||
\param Nth An index of the match to be replaced. The index is 0-based.
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void erase_nth(
|
||||
SequenceT& Input,
|
||||
const CollectionT& Search,
|
||||
const RangeT& Search,
|
||||
unsigned int Nth )
|
||||
{
|
||||
find_format(
|
||||
@ -445,7 +450,7 @@ namespace boost {
|
||||
|
||||
//! Erase nth algorithm ( case insensitive )
|
||||
/*!
|
||||
Remove the Nth occurence of the substring in the input.
|
||||
Remove the Nth occurrence of the substring in the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
Searching is case insensitive.
|
||||
@ -462,12 +467,12 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Collection1T,
|
||||
typename Collection2T>
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT ierase_nth_copy(
|
||||
OutputIteratorT Output,
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Search,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
unsigned int Nth,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
@ -482,10 +487,10 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT ierase_nth_copy(
|
||||
const SequenceT& Input,
|
||||
const CollectionT& Search,
|
||||
const RangeT& Search,
|
||||
unsigned int Nth,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
@ -497,7 +502,7 @@ namespace boost {
|
||||
|
||||
//! Erase nth algorithm
|
||||
/*!
|
||||
Remove the Nth occurence of the substring in the input.
|
||||
Remove the Nth occurrence of the substring in the input.
|
||||
The input sequence is modified in-place. Searching is case insensitive.
|
||||
|
||||
\param Input An input string
|
||||
@ -505,10 +510,10 @@ namespace boost {
|
||||
\param Nth An index of the match to be replaced. The index is 0-based.
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void ierase_nth(
|
||||
SequenceT& Input,
|
||||
const CollectionT& Search,
|
||||
const RangeT& Search,
|
||||
unsigned int Nth,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
@ -538,12 +543,12 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Collection1T,
|
||||
typename Collection2T>
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT erase_all_copy(
|
||||
OutputIteratorT Output,
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Search )
|
||||
const Range1T& Input,
|
||||
const Range2T& Search )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
Output,
|
||||
@ -556,10 +561,10 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT erase_all_copy(
|
||||
const SequenceT& Input,
|
||||
const CollectionT& Search )
|
||||
const RangeT& Search )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
Input,
|
||||
@ -575,10 +580,10 @@ namespace boost {
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for.
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void erase_all(
|
||||
SequenceT& Input,
|
||||
const CollectionT& Search )
|
||||
const RangeT& Search )
|
||||
{
|
||||
find_format_all(
|
||||
Input,
|
||||
@ -606,12 +611,12 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Collection1T,
|
||||
typename Collection2T>
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT ierase_all_copy(
|
||||
OutputIteratorT Output,
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Search,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
@ -625,10 +630,10 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT ierase_all_copy(
|
||||
const SequenceT& Input,
|
||||
const CollectionT& Search,
|
||||
const RangeT& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
@ -646,10 +651,10 @@ namespace boost {
|
||||
\param Search A substring to be searched for.
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void ierase_all(
|
||||
SequenceT& Input,
|
||||
const CollectionT& Search,
|
||||
const RangeT& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
find_format_all(
|
||||
@ -662,7 +667,7 @@ namespace boost {
|
||||
|
||||
//! Erase head algorithm
|
||||
/*!
|
||||
Remove the head from the input. The head is a prefix of a seqence of given size.
|
||||
Remove the head from the input. The head is a prefix of a sequence of given size.
|
||||
If the sequence is shorter then required, the whole string is
|
||||
considered to be the head. The result is a modified copy of the input.
|
||||
It is returned as a sequence or copied to the output iterator.
|
||||
@ -678,10 +683,10 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename CollectionT>
|
||||
typename RangeT>
|
||||
inline OutputIteratorT erase_head_copy(
|
||||
OutputIteratorT Output,
|
||||
const CollectionT& Input,
|
||||
const RangeT& Input,
|
||||
unsigned int N )
|
||||
{
|
||||
return find_format_copy(
|
||||
@ -708,7 +713,7 @@ namespace boost {
|
||||
|
||||
//! Erase head algorithm
|
||||
/*!
|
||||
Remove the head from the input. The head is a prefix of a seqence of given size.
|
||||
Remove the head from the input. The head is a prefix of a sequence of given size.
|
||||
If the sequence is shorter then required, the whole string is
|
||||
considered to be the head. The input sequence is modified in-place.
|
||||
|
||||
@ -730,7 +735,7 @@ namespace boost {
|
||||
|
||||
//! Erase tail algorithm
|
||||
/*!
|
||||
Remove the tail from the input. The tail is a suffix of a seqence of given size.
|
||||
Remove the tail from the input. The tail is a suffix of a sequence of given size.
|
||||
If the sequence is shorter then required, the whole string is
|
||||
considered to be the tail.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
@ -746,10 +751,10 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename CollectionT>
|
||||
typename RangeT>
|
||||
inline OutputIteratorT erase_tail_copy(
|
||||
OutputIteratorT Output,
|
||||
const CollectionT& Input,
|
||||
const RangeT& Input,
|
||||
unsigned int N )
|
||||
{
|
||||
return find_format_copy(
|
||||
@ -776,7 +781,7 @@ namespace boost {
|
||||
|
||||
//! Erase tail algorithm
|
||||
/*!
|
||||
Remove the tail from the input. The tail is a suffix of a seqence of given size.
|
||||
Remove the tail from the input. The tail is a suffix of a sequence of given size.
|
||||
If the sequence is shorter then required, the whole string is
|
||||
considered to be the tail. The input sequence is modified in-place.
|
||||
|
||||
|
@ -11,8 +11,14 @@
|
||||
#define BOOST_STRING_FIND_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
#include <boost/algorithm/string/iterator_range.hpp>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/range/result_iterator.hpp>
|
||||
|
||||
#include <boost/algorithm/string/finder.hpp>
|
||||
#include <boost/algorithm/string/compare.hpp>
|
||||
#include <boost/algorithm/string/constants.hpp>
|
||||
@ -36,15 +42,15 @@ namespace boost {
|
||||
\param Finder Finder object used for searching.
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c CollectionT::iterator or
|
||||
\c CollectionT::const_iterator, depending on the constness of
|
||||
Returned iterator is either \c RangeT::iterator or
|
||||
\c RangeT::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
*/
|
||||
template<typename CollectionT, typename FinderT>
|
||||
template<typename RangeT, typename FinderT>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME result_iterator_of<CollectionT>::type>
|
||||
BOOST_STRING_TYPENAME range_result_iterator<RangeT>::type>
|
||||
find(
|
||||
CollectionT& Input,
|
||||
RangeT& Input,
|
||||
FinderT Finder)
|
||||
{
|
||||
return Finder(begin(Input),end(Input));
|
||||
@ -60,18 +66,18 @@ namespace boost {
|
||||
\param Search A substring to be searched for.
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c CollectionT::iterator or
|
||||
\c CollectionT::const_iterator, depending on the constness of
|
||||
Returned iterator is either \c RangeT::iterator or
|
||||
\c RangeT::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Collection1T, typename Collection2T>
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME result_iterator_of<Collection1T>::type>
|
||||
BOOST_STRING_TYPENAME range_result_iterator<Range1T>::type>
|
||||
find_first(
|
||||
Collection1T& Input,
|
||||
const Collection2T& Search)
|
||||
Range1T& Input,
|
||||
const Range2T& Search)
|
||||
{
|
||||
return first_finder(Search)(
|
||||
begin(Input),end(Input));
|
||||
@ -87,18 +93,18 @@ namespace boost {
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c Collection1T::iterator or
|
||||
\c Collection1T::const_iterator, depending on the constness of
|
||||
Returned iterator is either \c Range1T::iterator or
|
||||
\c Range1T::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Collection1T, typename Collection2T>
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME result_iterator_of<Collection1T>::type>
|
||||
BOOST_STRING_TYPENAME range_result_iterator<Range1T>::type>
|
||||
ifind_first(
|
||||
Collection1T& Input,
|
||||
const Collection2T& Search,
|
||||
Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return first_finder(Search,is_iequal(Loc))(
|
||||
@ -115,18 +121,18 @@ namespace boost {
|
||||
\param Search A substring to be searched for.
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c Collection1T::iterator or
|
||||
\c Collection1T::const_iterator, depending on the constness of
|
||||
Returned iterator is either \c Range1T::iterator or
|
||||
\c Range1T::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Collection1T, typename Collection2T>
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME result_iterator_of<Collection1T>::type>
|
||||
BOOST_STRING_TYPENAME range_result_iterator<Range1T>::type>
|
||||
find_last(
|
||||
Collection1T& Input,
|
||||
const Collection2T& Search)
|
||||
Range1T& Input,
|
||||
const Range2T& Search)
|
||||
{
|
||||
return last_finder(Search)(
|
||||
begin(Input),end(Input));
|
||||
@ -142,18 +148,18 @@ namespace boost {
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c Collection1T::iterator or
|
||||
\c Collection1T::const_iterator, depending on the constness of
|
||||
Returned iterator is either \c Range1T::iterator or
|
||||
\c Range1T::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Collection1T, typename Collection2T>
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME result_iterator_of<Collection1T>::type>
|
||||
BOOST_STRING_TYPENAME range_result_iterator<Range1T>::type>
|
||||
ifind_last(
|
||||
Collection1T& Input,
|
||||
const Collection2T& Search,
|
||||
Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return last_finder(Search, is_iequal(Loc))(
|
||||
@ -172,16 +178,16 @@ namespace boost {
|
||||
\param Nth An index (zero-indexed) of the match to be found.
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c Collection1T::iterator or
|
||||
\c Collection1T::const_iterator, depending on the constness of
|
||||
Returned iterator is either \c Range1T::iterator or
|
||||
\c Range1T::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
*/
|
||||
template<typename Collection1T, typename Collection2T>
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME result_iterator_of<Collection1T>::type>
|
||||
BOOST_STRING_TYPENAME range_result_iterator<Range1T>::type>
|
||||
find_nth(
|
||||
Collection1T& Input,
|
||||
const Collection2T& Search,
|
||||
Range1T& Input,
|
||||
const Range2T& Search,
|
||||
unsigned int Nth)
|
||||
{
|
||||
return nth_finder(Search,Nth)(
|
||||
@ -199,19 +205,19 @@ namespace boost {
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c Collection1T::iterator or
|
||||
\c Collection1T::const_iterator, depending on the constness of
|
||||
Returned iterator is either \c Range1T::iterator or
|
||||
\c Range1T::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Collection1T, typename Collection2T>
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME result_iterator_of<Collection1T>::type>
|
||||
BOOST_STRING_TYPENAME range_result_iterator<Range1T>::type>
|
||||
ifind_nth(
|
||||
Collection1T& Input,
|
||||
const Collection2T& Search,
|
||||
Range1T& Input,
|
||||
const Range2T& Search,
|
||||
unsigned int Nth,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
@ -231,17 +237,17 @@ namespace boost {
|
||||
\param N Length of the head
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c Collection1T::iterator or
|
||||
\c Collection1T::const_iterator, depending on the constness of
|
||||
Returned iterator is either \c Range1T::iterator or
|
||||
\c Range1T::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename CollectionT>
|
||||
template<typename RangeT>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME result_iterator_of<CollectionT>::type>
|
||||
BOOST_STRING_TYPENAME range_result_iterator<RangeT>::type>
|
||||
find_head(
|
||||
CollectionT& Input,
|
||||
RangeT& Input,
|
||||
unsigned int N)
|
||||
{
|
||||
return head_finder(N)(
|
||||
@ -260,18 +266,18 @@ namespace boost {
|
||||
\param N Length of the tail
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c CollectionT::iterator or
|
||||
\c CollectionT::const_iterator, depending on the constness of
|
||||
Returned iterator is either \c RangeT::iterator or
|
||||
\c RangeT::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename CollectionT>
|
||||
template<typename RangeT>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME result_iterator_of<CollectionT>::type>
|
||||
BOOST_STRING_TYPENAME range_result_iterator<RangeT>::type>
|
||||
find_tail(
|
||||
CollectionT& Input,
|
||||
RangeT& Input,
|
||||
unsigned int N)
|
||||
{
|
||||
return tail_finder(N)(
|
||||
@ -291,17 +297,17 @@ namespace boost {
|
||||
\param eCompress Enable/Disable compressing of adjacent tokens
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c CollectionT::iterator or
|
||||
\c CollectionT::const_iterator, depending on the constness of
|
||||
Returned iterator is either \c RangeT::iterator or
|
||||
\c RangeT::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename CollectionT, typename PredicateT>
|
||||
template<typename RangeT, typename PredicateT>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME result_iterator_of<CollectionT>::type>
|
||||
BOOST_STRING_TYPENAME range_result_iterator<RangeT>::type>
|
||||
find_token(
|
||||
CollectionT& Input,
|
||||
RangeT& Input,
|
||||
PredicateT Pred,
|
||||
token_compress_mode_type eCompress=token_compress_off)
|
||||
{
|
||||
|
@ -12,8 +12,11 @@
|
||||
|
||||
#include <deque>
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
#include <boost/algorithm/string/iterator_range.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
|
||||
#include <boost/algorithm/string/concept.hpp>
|
||||
#include <boost/algorithm/string/detail/find_format.hpp>
|
||||
#include <boost/algorithm/string/detail/find_format_all.hpp>
|
||||
@ -47,23 +50,23 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename CollectionT,
|
||||
typename RangeT,
|
||||
typename FinderT,
|
||||
typename FormatterT>
|
||||
inline OutputIteratorT find_format_copy(
|
||||
OutputIteratorT Output,
|
||||
const CollectionT& Input,
|
||||
const RangeT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter )
|
||||
{
|
||||
// Concept check
|
||||
function_requires<
|
||||
FinderConcept<FinderT,
|
||||
BOOST_STRING_TYPENAME const_iterator_of<CollectionT>::type> >();
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >();
|
||||
function_requires<
|
||||
FormatterConcept<
|
||||
FormatterT,
|
||||
FinderT,BOOST_STRING_TYPENAME const_iterator_of<CollectionT>::type> >();
|
||||
FinderT,BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >();
|
||||
|
||||
return detail::find_format_copy_impl(
|
||||
Output,
|
||||
@ -89,11 +92,11 @@ namespace boost {
|
||||
// Concept check
|
||||
function_requires<
|
||||
FinderConcept<FinderT,
|
||||
BOOST_STRING_TYPENAME const_iterator_of<SequenceT>::type> >();
|
||||
BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> >();
|
||||
function_requires<
|
||||
FormatterConcept<
|
||||
FormatterT,
|
||||
FinderT,BOOST_STRING_TYPENAME const_iterator_of<SequenceT>::type> >();
|
||||
FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> >();
|
||||
|
||||
return detail::find_format_copy_impl(
|
||||
Input,
|
||||
@ -123,11 +126,11 @@ namespace boost {
|
||||
// Concept check
|
||||
function_requires<
|
||||
FinderConcept<FinderT,
|
||||
BOOST_STRING_TYPENAME const_iterator_of<SequenceT>::type> >();
|
||||
BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> >();
|
||||
function_requires<
|
||||
FormatterConcept<
|
||||
FormatterT,
|
||||
FinderT,BOOST_STRING_TYPENAME const_iterator_of<SequenceT>::type> >();
|
||||
FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> >();
|
||||
|
||||
detail::find_format_impl(
|
||||
Input,
|
||||
@ -158,23 +161,23 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename CollectionT,
|
||||
typename RangeT,
|
||||
typename FinderT,
|
||||
typename FormatterT>
|
||||
inline OutputIteratorT find_format_all_copy(
|
||||
OutputIteratorT Output,
|
||||
const CollectionT& Input,
|
||||
const RangeT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter)
|
||||
{
|
||||
// Concept check
|
||||
function_requires<
|
||||
FinderConcept<FinderT,
|
||||
BOOST_STRING_TYPENAME const_iterator_of<CollectionT>::type> >();
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >();
|
||||
function_requires<
|
||||
FormatterConcept<
|
||||
FormatterT,
|
||||
FinderT,BOOST_STRING_TYPENAME const_iterator_of<CollectionT>::type> >();
|
||||
FinderT,BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >();
|
||||
|
||||
return detail::find_format_all_copy_impl(
|
||||
Output,
|
||||
@ -200,11 +203,11 @@ namespace boost {
|
||||
// Concept check
|
||||
function_requires<
|
||||
FinderConcept<FinderT,
|
||||
BOOST_STRING_TYPENAME const_iterator_of<SequenceT>::type> >();
|
||||
BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> >();
|
||||
function_requires<
|
||||
FormatterConcept<
|
||||
FormatterT,
|
||||
FinderT,BOOST_STRING_TYPENAME const_iterator_of<SequenceT>::type> >();
|
||||
FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> >();
|
||||
|
||||
return detail::find_format_all_copy_impl(
|
||||
Input,
|
||||
@ -235,11 +238,11 @@ namespace boost {
|
||||
// Concept check
|
||||
function_requires<
|
||||
FinderConcept<FinderT,
|
||||
BOOST_STRING_TYPENAME const_iterator_of<SequenceT>::type> >();
|
||||
BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> >();
|
||||
function_requires<
|
||||
FormatterConcept<
|
||||
FormatterT,
|
||||
FinderT,BOOST_STRING_TYPENAME const_iterator_of<SequenceT>::type> >();
|
||||
FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> >();
|
||||
|
||||
detail::find_format_all_impl(
|
||||
Input,
|
||||
|
@ -9,14 +9,17 @@
|
||||
#ifndef BOOST_STRING_FIND_ITERATOR_HPP
|
||||
#define BOOST_STRING_FIND_ITERATOR_HPP
|
||||
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
#include <boost/algorithm/string/iterator_range.hpp>
|
||||
#include <boost/algorithm/string/detail/find_iterator.hpp>
|
||||
#include <boost/iterator/iterator_facade.hpp>
|
||||
#include <boost/iterator/iterator_categories.hpp>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/result_iterator.hpp>
|
||||
|
||||
#include <boost/algorithm/string/detail/find_iterator.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines find iterator classes. Find iterator repeatly applies a Finder
|
||||
to the specified input string to search for matches. Dereferencing
|
||||
@ -105,11 +108,11 @@ namespace boost {
|
||||
//! Constructor
|
||||
/*!
|
||||
Construct new find_iterator for a given finder
|
||||
and a collection.
|
||||
and a range.
|
||||
*/
|
||||
template<typename FinderT, typename CollectionT>
|
||||
template<typename FinderT, typename RangeT>
|
||||
find_iterator(
|
||||
CollectionT& Col,
|
||||
RangeT& Col,
|
||||
FinderT Finder ) :
|
||||
detail::find_iterator_base<IteratorT>(Finder,0),
|
||||
m_Match(begin(Col),begin(Col)),
|
||||
@ -136,7 +139,10 @@ namespace boost {
|
||||
// comparison
|
||||
bool equal( const find_iterator& Other ) const
|
||||
{
|
||||
return eof() || Other.eof() ? eof() == Other.eof() :
|
||||
bool bEof=eof();
|
||||
bool bOtherEof=Other.eof();
|
||||
|
||||
return bEof || bOtherEof ? bEof==bOtherEof :
|
||||
(
|
||||
m_Match==Other.m_Match &&
|
||||
m_End==Other.m_End
|
||||
@ -172,14 +178,14 @@ namespace boost {
|
||||
/*!
|
||||
* Construct a find iterator to iterate through the specified string
|
||||
*/
|
||||
template<typename CollectionT, typename FinderT>
|
||||
template<typename RangeT, typename FinderT>
|
||||
inline find_iterator<
|
||||
BOOST_STRING_TYPENAME result_iterator_of<CollectionT>::type>
|
||||
BOOST_STRING_TYPENAME range_result_iterator<RangeT>::type>
|
||||
make_find_iterator(
|
||||
CollectionT& Collection,
|
||||
RangeT& Collection,
|
||||
FinderT Finder)
|
||||
{
|
||||
return find_iterator<BOOST_STRING_TYPENAME result_iterator_of<CollectionT>::type>(
|
||||
return find_iterator<BOOST_STRING_TYPENAME range_result_iterator<RangeT>::type>(
|
||||
begin(Collection), end(Collection), Finder);
|
||||
}
|
||||
|
||||
@ -240,7 +246,9 @@ namespace boost {
|
||||
base_type(Other),
|
||||
m_Match(Other.m_Match),
|
||||
m_Next(Other.m_Next),
|
||||
m_End(Other.m_End) {}
|
||||
m_End(Other.m_End),
|
||||
m_bEof(false)
|
||||
{}
|
||||
|
||||
//! Constructor
|
||||
/*!
|
||||
@ -255,7 +263,8 @@ namespace boost {
|
||||
detail::find_iterator_base<IteratorT>(Finder,0),
|
||||
m_Match(Begin,Begin),
|
||||
m_Next(Begin),
|
||||
m_End(End)
|
||||
m_End(End),
|
||||
m_bEof(false)
|
||||
{
|
||||
increment();
|
||||
}
|
||||
@ -264,14 +273,15 @@ namespace boost {
|
||||
Construct new split_iterator for a given finder
|
||||
and a collection.
|
||||
*/
|
||||
template<typename FinderT, typename CollectionT>
|
||||
template<typename FinderT, typename RangeT>
|
||||
split_iterator(
|
||||
CollectionT& Col,
|
||||
RangeT& Col,
|
||||
FinderT Finder ) :
|
||||
detail::find_iterator_base<IteratorT>(Finder,0),
|
||||
m_Match(begin(Col),begin(Col)),
|
||||
m_Next(begin(Col)),
|
||||
m_End(end(Col))
|
||||
m_End(end(Col)),
|
||||
m_bEof(false)
|
||||
{
|
||||
increment();
|
||||
}
|
||||
@ -290,6 +300,16 @@ namespace boost {
|
||||
void increment()
|
||||
{
|
||||
match_type FindMatch=this->do_find( m_Next, m_End );
|
||||
|
||||
if(FindMatch.begin()==m_End && FindMatch.end()==m_End)
|
||||
{
|
||||
if(m_Match.end()==m_End)
|
||||
{
|
||||
// Mark iterator as eof
|
||||
m_bEof=true;
|
||||
}
|
||||
}
|
||||
|
||||
m_Match=match_type( m_Next, FindMatch.begin() );
|
||||
m_Next=FindMatch.end();
|
||||
}
|
||||
@ -297,11 +317,14 @@ namespace boost {
|
||||
// comparison
|
||||
bool equal( const split_iterator& Other ) const
|
||||
{
|
||||
return eof() || Other.eof() ? eof() == Other.eof() :
|
||||
bool bEof=eof();
|
||||
bool bOtherEof=Other.eof();
|
||||
|
||||
return bEof || bOtherEof ? bEof==bOtherEof :
|
||||
(
|
||||
m_Match==Other.m_Match &&
|
||||
m_Next==Other.m_Next &&
|
||||
m_End==Other.m_End
|
||||
m_End==Other.m_End
|
||||
);
|
||||
}
|
||||
|
||||
@ -316,12 +339,7 @@ namespace boost {
|
||||
*/
|
||||
bool eof() const
|
||||
{
|
||||
return
|
||||
this->is_null() ||
|
||||
(
|
||||
m_Match.begin() == m_End &&
|
||||
m_Match.end() == m_End
|
||||
);
|
||||
return this->is_null() || m_bEof;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -329,20 +347,21 @@ namespace boost {
|
||||
match_type m_Match;
|
||||
input_iterator_type m_Next;
|
||||
input_iterator_type m_End;
|
||||
bool m_bEof;
|
||||
};
|
||||
|
||||
//! split iterator construction helper
|
||||
/*!
|
||||
* Construct a split iterator to iterate through the specified collection
|
||||
*/
|
||||
template<typename CollectionT, typename FinderT>
|
||||
template<typename RangeT, typename FinderT>
|
||||
inline split_iterator<
|
||||
BOOST_STRING_TYPENAME result_iterator_of<CollectionT>::type>
|
||||
BOOST_STRING_TYPENAME range_result_iterator<RangeT>::type>
|
||||
make_split_iterator(
|
||||
CollectionT& Collection,
|
||||
RangeT& Collection,
|
||||
FinderT Finder)
|
||||
{
|
||||
return split_iterator<BOOST_STRING_TYPENAME result_iterator_of<CollectionT>::type>(
|
||||
return split_iterator<BOOST_STRING_TYPENAME range_result_iterator<RangeT>::type>(
|
||||
begin(Collection), end(Collection), Finder);
|
||||
}
|
||||
|
||||
|
@ -11,9 +11,14 @@
|
||||
#define BOOST_STRING_FINDER_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
|
||||
#include <boost/algorithm/string/constants.hpp>
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
#include <boost/algorithm/string/iterator_range.hpp>
|
||||
#include <boost/algorithm/string/detail/finder.hpp>
|
||||
#include <boost/algorithm/string/compare.hpp>
|
||||
|
||||
@ -42,14 +47,14 @@ namespace boost {
|
||||
*/
|
||||
template<typename ContainerT>
|
||||
inline detail::first_finderF<
|
||||
BOOST_STRING_TYPENAME const_iterator_of<ContainerT>::type,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<ContainerT>::type,
|
||||
is_equal>
|
||||
first_finder( const ContainerT& Search )
|
||||
{
|
||||
return
|
||||
detail::first_finderF<
|
||||
BOOST_STRING_TYPENAME
|
||||
const_iterator_of<ContainerT>::type,
|
||||
range_const_iterator<ContainerT>::type,
|
||||
is_equal>( Search, is_equal() ) ;
|
||||
}
|
||||
|
||||
@ -59,7 +64,7 @@ namespace boost {
|
||||
*/
|
||||
template<typename ContainerT,typename PredicateT>
|
||||
inline detail::first_finderF<
|
||||
BOOST_STRING_TYPENAME const_iterator_of<ContainerT>::type,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<ContainerT>::type,
|
||||
PredicateT>
|
||||
first_finder(
|
||||
const ContainerT& Search, PredicateT Comp )
|
||||
@ -67,7 +72,7 @@ namespace boost {
|
||||
return
|
||||
detail::first_finderF<
|
||||
BOOST_STRING_TYPENAME
|
||||
const_iterator_of<ContainerT>::type,
|
||||
range_const_iterator<ContainerT>::type,
|
||||
PredicateT>( Search, Comp );
|
||||
}
|
||||
|
||||
@ -83,14 +88,14 @@ namespace boost {
|
||||
*/
|
||||
template<typename ContainerT>
|
||||
inline detail::last_finderF<
|
||||
BOOST_STRING_TYPENAME const_iterator_of<ContainerT>::type,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<ContainerT>::type,
|
||||
is_equal>
|
||||
last_finder( const ContainerT& Search )
|
||||
{
|
||||
return
|
||||
detail::last_finderF<
|
||||
BOOST_STRING_TYPENAME
|
||||
const_iterator_of<ContainerT>::type,
|
||||
range_const_iterator<ContainerT>::type,
|
||||
is_equal>( Search, is_equal() );
|
||||
}
|
||||
//! "Last" finder
|
||||
@ -99,14 +104,14 @@ namespace boost {
|
||||
*/
|
||||
template<typename ContainerT, typename PredicateT>
|
||||
inline detail::last_finderF<
|
||||
BOOST_STRING_TYPENAME const_iterator_of<ContainerT>::type,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<ContainerT>::type,
|
||||
PredicateT>
|
||||
last_finder( const ContainerT& Search, PredicateT Comp )
|
||||
{
|
||||
return
|
||||
detail::last_finderF<
|
||||
BOOST_STRING_TYPENAME
|
||||
const_iterator_of<ContainerT>::type,
|
||||
range_const_iterator<ContainerT>::type,
|
||||
PredicateT>( Search, Comp ) ;
|
||||
}
|
||||
|
||||
@ -123,7 +128,7 @@ namespace boost {
|
||||
*/
|
||||
template<typename ContainerT>
|
||||
inline detail::nth_finderF<
|
||||
BOOST_STRING_TYPENAME const_iterator_of<ContainerT>::type,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<ContainerT>::type,
|
||||
is_equal>
|
||||
nth_finder(
|
||||
const ContainerT& Search,
|
||||
@ -132,7 +137,7 @@ namespace boost {
|
||||
return
|
||||
detail::nth_finderF<
|
||||
BOOST_STRING_TYPENAME
|
||||
const_iterator_of<ContainerT>::type,
|
||||
range_const_iterator<ContainerT>::type,
|
||||
is_equal>( Search, Nth, is_equal() ) ;
|
||||
}
|
||||
//! "Nth" finder
|
||||
@ -141,7 +146,7 @@ namespace boost {
|
||||
*/
|
||||
template<typename ContainerT, typename PredicateT>
|
||||
inline detail::nth_finderF<
|
||||
BOOST_STRING_TYPENAME const_iterator_of<ContainerT>::type,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<ContainerT>::type,
|
||||
PredicateT>
|
||||
nth_finder(
|
||||
const ContainerT& Search,
|
||||
@ -151,7 +156,7 @@ namespace boost {
|
||||
return
|
||||
detail::nth_finderF<
|
||||
BOOST_STRING_TYPENAME
|
||||
const_iterator_of<ContainerT>::type,
|
||||
range_const_iterator<ContainerT>::type,
|
||||
PredicateT>( Search, Nth, Comp );
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,9 @@
|
||||
#define BOOST_STRING_FORMATTER_HPP
|
||||
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
#include <boost/algorithm/string/iterator_range.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
#include <boost/algorithm/string/detail/formatter.hpp>
|
||||
|
||||
/*! \file
|
||||
@ -29,7 +30,7 @@
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// generic formaters ---------------------------------------------------------------//
|
||||
// generic formatters ---------------------------------------------------------------//
|
||||
|
||||
//! Constant formatter
|
||||
/*!
|
||||
@ -39,11 +40,11 @@ namespace boost {
|
||||
\param Format A predefined value used as a result for formating
|
||||
\return An instance of the \c const_formatter object.
|
||||
*/
|
||||
template<typename CollectionT>
|
||||
inline detail::const_formatF<CollectionT>
|
||||
const_formatter(const CollectionT& Format)
|
||||
template<typename RangeT>
|
||||
inline detail::const_formatF<RangeT>
|
||||
const_formatter(const RangeT& Format)
|
||||
{
|
||||
return detail::const_formatF<CollectionT>(Format);
|
||||
return detail::const_formatF<RangeT>(Format);
|
||||
}
|
||||
|
||||
//! Identity formatter
|
||||
@ -53,29 +54,29 @@ namespace boost {
|
||||
|
||||
\return An instance of the \c identity_formatter object.
|
||||
*/
|
||||
template<typename CollectionT>
|
||||
inline detail::identity_formatF<CollectionT>
|
||||
template<typename RangeT>
|
||||
inline detail::identity_formatF<RangeT>
|
||||
identity_formatter()
|
||||
{
|
||||
return detail::identity_formatF<CollectionT>();
|
||||
return detail::identity_formatF<RangeT>();
|
||||
}
|
||||
|
||||
//! Empty formatter
|
||||
/*!
|
||||
Construct the \c empty_formatter. Empty formater always returns an empty
|
||||
Construct the \c empty_formatter. Empty formatter always returns an empty
|
||||
sequence.
|
||||
|
||||
\param Input container used to select a correct value_type for the
|
||||
resulting empty_container<>.
|
||||
\return An instance of the \c empty_formatter object.
|
||||
*/
|
||||
template<typename CollectionT>
|
||||
template<typename RangeT>
|
||||
inline detail::empty_formatF<
|
||||
BOOST_STRING_TYPENAME value_type_of<CollectionT>::type>
|
||||
empty_formatter(const CollectionT& Input)
|
||||
BOOST_STRING_TYPENAME range_value<RangeT>::type>
|
||||
empty_formatter(const RangeT&)
|
||||
{
|
||||
return detail::empty_formatF<
|
||||
BOOST_STRING_TYPENAME value_type_of<CollectionT>::type>();
|
||||
BOOST_STRING_TYPENAME range_value<RangeT>::type>();
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,8 +14,13 @@
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
#include <boost/algorithm/string/iterator_range.hpp>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/result_iterator.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
|
||||
#include <boost/algorithm/string/concept.hpp>
|
||||
#include <boost/algorithm/string/find_iterator.hpp>
|
||||
#include <boost/algorithm/string/detail/util.hpp>
|
||||
@ -59,24 +64,24 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename SequenceSequenceT,
|
||||
typename CollectionT,
|
||||
typename RangeT,
|
||||
typename FinderT >
|
||||
inline SequenceSequenceT&
|
||||
iter_find(
|
||||
SequenceSequenceT& Result,
|
||||
CollectionT& Input,
|
||||
RangeT& Input,
|
||||
FinderT Finder )
|
||||
{
|
||||
function_requires<
|
||||
FinderConcept<FinderT,
|
||||
BOOST_STRING_TYPENAME result_iterator_of<CollectionT>::type> >();
|
||||
BOOST_STRING_TYPENAME range_result_iterator<RangeT>::type> >();
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
result_iterator_of<CollectionT>::type input_iterator_type;
|
||||
range_result_iterator<RangeT>::type input_iterator_type;
|
||||
typedef find_iterator<input_iterator_type> find_iterator_type;
|
||||
typedef detail::copy_iterator_rangeF<
|
||||
BOOST_STRING_TYPENAME
|
||||
value_type_of<SequenceSequenceT>::type,
|
||||
range_value<SequenceSequenceT>::type,
|
||||
input_iterator_type> copy_range_type;
|
||||
|
||||
input_iterator_type InputEnd=end(Input);
|
||||
@ -126,24 +131,24 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename SequenceSequenceT,
|
||||
typename CollectionT,
|
||||
typename RangeT,
|
||||
typename FinderT >
|
||||
inline SequenceSequenceT&
|
||||
iter_split(
|
||||
SequenceSequenceT& Result,
|
||||
CollectionT& Input,
|
||||
RangeT& Input,
|
||||
FinderT Finder )
|
||||
{
|
||||
function_requires<
|
||||
FinderConcept<FinderT,
|
||||
BOOST_STRING_TYPENAME result_iterator_of<CollectionT>::type> >();
|
||||
BOOST_STRING_TYPENAME range_result_iterator<RangeT>::type> >();
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
result_iterator_of<CollectionT>::type input_iterator_type;
|
||||
range_result_iterator<RangeT>::type input_iterator_type;
|
||||
typedef split_iterator<input_iterator_type> find_iterator_type;
|
||||
typedef detail::copy_iterator_rangeF<
|
||||
BOOST_STRING_TYPENAME
|
||||
value_type_of<SequenceSequenceT>::type,
|
||||
range_value<SequenceSequenceT>::type,
|
||||
input_iterator_type> copy_range_type;
|
||||
|
||||
input_iterator_type InputEnd=end(Input);
|
||||
|
@ -1,296 +0,0 @@
|
||||
// Boost string_algo library iterator_range.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_ITERATOR_RANGE_HPP
|
||||
#define BOOST_STRING_ITERATOR_RANGE_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <utility>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <ostream>
|
||||
#include <boost/detail/iterator.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines the \c iterator_class and related functions.
|
||||
\c iterator_range is a simple wrapper of the iterator pair idiom. It provides
|
||||
a rich subset of the Container interface.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// iterator range template class -----------------------------------------//
|
||||
|
||||
//! iterator_range class
|
||||
/*!
|
||||
An \c iterator_range delimits a range in a sequence by beginning and ending iterators.
|
||||
An iterator_range can be passed to an algorithm which requires a sequence as an input.
|
||||
For example, the \c toupper() function may most frequently be used on strings,
|
||||
but can also be used on iterator_ranges:
|
||||
|
||||
\code
|
||||
boost::tolower( find( s, "UPPERCASE STRING" ) );
|
||||
\endcode
|
||||
|
||||
Many algorithms working with sequences take a pair of iterators,
|
||||
delimiting a working range, as arguments. The \c iterator_range class is an
|
||||
encapsulation of a range identified by a pair of iterators.
|
||||
It provides a collection interface,
|
||||
so it is possible to pass an instance to an algorithm requiring a collection as an input.
|
||||
*/
|
||||
template<typename IteratorT>
|
||||
class iterator_range
|
||||
{
|
||||
public:
|
||||
//! this type
|
||||
typedef iterator_range<IteratorT> type;
|
||||
//! Encapsulated value type
|
||||
typedef BOOST_STRING_TYPENAME boost::detail::
|
||||
iterator_traits<IteratorT>::value_type value_type;
|
||||
//! Reference type
|
||||
typedef BOOST_STRING_TYPENAME boost::detail::
|
||||
iterator_traits<IteratorT>::reference reference;
|
||||
//! Difference type
|
||||
typedef BOOST_STRING_TYPENAME boost::detail::
|
||||
iterator_traits<IteratorT>::difference_type difference_type;
|
||||
//! Size type
|
||||
typedef BOOST_STRING_TYPENAME boost::detail::
|
||||
iterator_traits<IteratorT>::difference_type size_type;
|
||||
|
||||
//! const_iterator type
|
||||
/*!
|
||||
There is no distinction between const_iterator and iterator.
|
||||
These typedefs are provides to fulfill container interface
|
||||
*/
|
||||
typedef IteratorT const_iterator;
|
||||
//! iterator type
|
||||
typedef IteratorT iterator;
|
||||
|
||||
//! Empty constructor
|
||||
iterator_range() :
|
||||
m_Begin(), m_End() {}
|
||||
|
||||
//! Constructor from a pair of iterators
|
||||
iterator_range( iterator Begin, iterator End ) :
|
||||
m_Begin(Begin), m_End(End) {}
|
||||
|
||||
//! Constructor from a std::pair
|
||||
iterator_range( const std::pair<IteratorT,IteratorT>& Range ) :
|
||||
m_Begin(Range.first), m_End(Range.second) {}
|
||||
|
||||
//! Copy constructor
|
||||
iterator_range( const iterator_range& Other ) :
|
||||
m_Begin(Other.begin()), m_End(Other.end()) {}
|
||||
|
||||
//! Templated copy constructor
|
||||
/*!
|
||||
This constructor is provided to allow conversion between
|
||||
const and mutable iterator instances of this class template
|
||||
*/
|
||||
template< typename OtherItT >
|
||||
iterator_range( const iterator_range<OtherItT>& Other ) :
|
||||
m_Begin(Other.begin()), m_End(Other.end()) {}
|
||||
|
||||
//! Assignment operator
|
||||
iterator_range& operator=( const iterator_range& Other )
|
||||
{
|
||||
m_Begin=Other.begin(); m_End=Other.end();
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Assignment operator ( templated version )
|
||||
template< typename OtherItT >
|
||||
iterator_range& operator=( const iterator_range<OtherItT>& Other )
|
||||
{
|
||||
m_Begin=Other.begin(); m_End=Other.end();
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Comparison operator ( equal )
|
||||
/*!
|
||||
Compare operands for equality
|
||||
*/
|
||||
template< typename OtherItT >
|
||||
bool operator==( const iterator_range<OtherItT>& Other ) const
|
||||
{
|
||||
return m_Begin==Other.begin() && m_End==Other.end();
|
||||
}
|
||||
|
||||
//! Comparison operator ( not-equal )
|
||||
/*!
|
||||
Compare operands for non-equality
|
||||
*/
|
||||
template< typename OtherItT >
|
||||
bool operator!=( const iterator_range<OtherItT>& Other ) const
|
||||
{
|
||||
return m_Begin!=Other.begin() || m_End!=Other.end();
|
||||
}
|
||||
|
||||
//! begin access
|
||||
/*!
|
||||
Retrieve the begin iterator
|
||||
*/
|
||||
IteratorT begin() const
|
||||
{
|
||||
return m_Begin;
|
||||
}
|
||||
|
||||
//! end access
|
||||
/*!
|
||||
Retrieve the end iterator
|
||||
*/
|
||||
IteratorT end() const
|
||||
{
|
||||
return m_End;
|
||||
}
|
||||
|
||||
//! Empty container test
|
||||
/*!
|
||||
Test whether the range is empty
|
||||
*/
|
||||
bool empty() const
|
||||
{
|
||||
return m_Begin==m_End;
|
||||
}
|
||||
|
||||
//! Size of the range
|
||||
/*!
|
||||
Retrieve the size of the range
|
||||
*/
|
||||
difference_type size() const
|
||||
{
|
||||
return std::distance( m_Begin, m_End );
|
||||
}
|
||||
|
||||
//! Swap
|
||||
/*!
|
||||
Swap two ranges
|
||||
*/
|
||||
void swap( iterator_range& Other )
|
||||
{
|
||||
std::swap( m_Begin, Other.begin() );
|
||||
std::swap( m_End, Other.end() );
|
||||
}
|
||||
|
||||
//! Safe bool conversion
|
||||
/*!
|
||||
Check whether the range is empty.
|
||||
Allows to use construction like this:
|
||||
\code
|
||||
iterator_range r;
|
||||
if (!r)
|
||||
{
|
||||
...
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
typedef iterator (iterator_range::*unspecified_bool_type) () const;
|
||||
operator unspecified_bool_type() const
|
||||
{
|
||||
return empty()? 0: &iterator_range::end;
|
||||
}
|
||||
|
||||
private:
|
||||
// begin and end iterators
|
||||
IteratorT m_Begin;
|
||||
IteratorT m_End;
|
||||
};
|
||||
|
||||
// iterator range free-standing operators ---------------------------//
|
||||
|
||||
//! iterator_range output operator
|
||||
/*!
|
||||
Output the range to an ostream. Elements are outputed
|
||||
in a sequence without separators.
|
||||
*/
|
||||
template< typename IteratorT, typename Elem, typename Traits >
|
||||
std::basic_ostream<Elem,Traits>& operator<<(
|
||||
std::basic_ostream<Elem, Traits>& Os,
|
||||
const iterator_range<IteratorT>& Range )
|
||||
{
|
||||
std::copy(Range.begin(), Range.end(), std::ostream_iterator<Elem>(Os));
|
||||
|
||||
return Os;
|
||||
}
|
||||
|
||||
|
||||
// iterator range utilities -----------------------------------------//
|
||||
|
||||
//! iterator_range construct helper
|
||||
/*!
|
||||
Construct an \c iterator_range from a pair of iterators
|
||||
|
||||
\param Begin A begin iterator
|
||||
\param End An end iterator
|
||||
\return iterator_range object
|
||||
*/
|
||||
template< typename IteratorT >
|
||||
inline iterator_range< IteratorT > make_iterator_range( IteratorT Begin, IteratorT End )
|
||||
{
|
||||
return iterator_range<IteratorT>( Begin, End );
|
||||
}
|
||||
|
||||
//! iterator_range construct helper
|
||||
/*!
|
||||
Construct an \c iterator_range from a \c std::pair<> containing the begin
|
||||
and end iterators.
|
||||
|
||||
\param Pair A \c std::pair<> with begin and end iterators
|
||||
\return \c iterator_range object
|
||||
*/
|
||||
template< typename IteratorT >
|
||||
inline iterator_range< IteratorT > make_iterator_range( const std::pair<IteratorT,IteratorT>& Pair )
|
||||
{
|
||||
return iterator_range<IteratorT>( Pair.first, Pair.second );
|
||||
}
|
||||
|
||||
//! copy a range into a sequence
|
||||
/*!
|
||||
Construct a new sequence of the specified type from the elements
|
||||
in the given range
|
||||
|
||||
\param Range An input range
|
||||
\return New sequence
|
||||
*/
|
||||
template< typename SeqT, typename IteratorT >
|
||||
inline SeqT copy_iterator_range( const iterator_range<IteratorT>& Range )
|
||||
{
|
||||
return SeqT( Range.begin(), Range.end() );
|
||||
}
|
||||
|
||||
//! transform a range into a sequence
|
||||
/*!
|
||||
Create a new sequence from the elements in the range, transformed
|
||||
by a function
|
||||
|
||||
\param Range An input range
|
||||
\param Func Transformation function
|
||||
\return New sequence
|
||||
*/
|
||||
template< typename SeqT, typename IteratorT, typename FuncT >
|
||||
inline SeqT transform_iterator_range( const iterator_range<IteratorT>& Range, FuncT Func )
|
||||
{
|
||||
SeqT Seq;
|
||||
std::transform( Range.begin(), Range.end(), std::back_inserter(Seq), Func );
|
||||
return Seq;
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names to the namespace boost
|
||||
using algorithm::iterator_range;
|
||||
using algorithm::make_iterator_range;
|
||||
using algorithm::copy_iterator_range;
|
||||
using algorithm::transform_iterator_range;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_ITERATOR_RANGE_HPP
|
@ -11,8 +11,12 @@
|
||||
#define BOOST_STRING_PREDICATE_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
|
||||
#include <boost/algorithm/string/compare.hpp>
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
#include <boost/algorithm/string/find.hpp>
|
||||
#include <boost/algorithm/string/detail/predicate.hpp>
|
||||
|
||||
@ -34,7 +38,7 @@ namespace boost {
|
||||
|
||||
//! 'Starts with' predicate
|
||||
/*!
|
||||
This predicate holds when the test collection is a prefix of the Input.
|
||||
This predicate holds when the test string is a prefix of the Input.
|
||||
In other words, if the input starts with the test.
|
||||
When the optional predicate is specified, it is used for character-wise
|
||||
comparison.
|
||||
@ -46,16 +50,16 @@ namespace boost {
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Collection1T, typename Collection2T, typename PredicateT>
|
||||
template<typename Range1T, typename Range2T, typename PredicateT>
|
||||
inline bool starts_with(
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Test,
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
PredicateT Comp)
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
const_iterator_of<Collection1T>::type Iterator1T;
|
||||
range_const_iterator<Range1T>::type Iterator1T;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
const_iterator_of<Collection2T>::type Iterator2T;
|
||||
range_const_iterator<Range2T>::type Iterator2T;
|
||||
|
||||
Iterator1T InputEnd=end(Input);
|
||||
Iterator2T TestEnd=end(Test);
|
||||
@ -77,17 +81,17 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename Collection1T, typename Collection2T>
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool starts_with(
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Test)
|
||||
const Range1T& Input,
|
||||
const Range2T& Test)
|
||||
{
|
||||
return starts_with(Input, Test, is_equal());
|
||||
}
|
||||
|
||||
//! 'Starts with' predicate ( case insensitive )
|
||||
/*!
|
||||
This predicate holds when the test container is a prefix of the Input.
|
||||
This predicate holds when the test string is a prefix of the Input.
|
||||
In other words, if the input starts with the test.
|
||||
Elements are compared case insensitively.
|
||||
|
||||
@ -98,10 +102,10 @@ namespace boost {
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Collection1T, typename Collection2T>
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool istarts_with(
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Test,
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return starts_with(Input, Test, is_iequal(Loc));
|
||||
@ -112,7 +116,7 @@ namespace boost {
|
||||
|
||||
//! 'Ends with' predicate
|
||||
/*!
|
||||
This predicate holds when the test container is a suffix of the Input.
|
||||
This predicate holds when the test string is a suffix of the Input.
|
||||
In other words, if the input ends with the test.
|
||||
When the optional predicate is specified, it is used for character-wise
|
||||
comparison.
|
||||
@ -125,14 +129,14 @@ namespace boost {
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Collection1T, typename Collection2T, typename PredicateT>
|
||||
template<typename Range1T, typename Range2T, typename PredicateT>
|
||||
inline bool ends_with(
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Test,
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
PredicateT Comp)
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
const_iterator_of<Collection1T>::type Iterator1T;
|
||||
range_const_iterator<Range1T>::type Iterator1T;
|
||||
typedef BOOST_STRING_TYPENAME boost::detail::
|
||||
iterator_traits<Iterator1T>::iterator_category category;
|
||||
|
||||
@ -151,10 +155,10 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename Collection1T, typename Collection2T>
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool ends_with(
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Test)
|
||||
const Range1T& Input,
|
||||
const Range2T& Test)
|
||||
{
|
||||
return ends_with(Input, Test, is_equal());
|
||||
}
|
||||
@ -172,10 +176,10 @@ namespace boost {
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Collection1T, typename Collection2T>
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool iends_with(
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Test,
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return ends_with(Input, Test, is_iequal(Loc));
|
||||
@ -196,10 +200,10 @@ namespace boost {
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Collection1T, typename Collection2T, typename PredicateT>
|
||||
template<typename Range1T, typename Range2T, typename PredicateT>
|
||||
inline bool contains(
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Test,
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
PredicateT Comp)
|
||||
{
|
||||
if (empty(Test))
|
||||
@ -208,17 +212,19 @@ namespace boost {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (first_finder(Test,Comp)(begin(Input), end(Input)));
|
||||
// Use the temporary variable to make VACPP happy
|
||||
bool bResult=(first_finder(Test,Comp)(begin(Input), end(Input)));
|
||||
return bResult;
|
||||
}
|
||||
|
||||
//! 'Contains' predicate
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename Collection1T, typename Collection2T>
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool contains(
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Test)
|
||||
const Range1T& Input,
|
||||
const Range2T& Test)
|
||||
{
|
||||
return contains(Input, Test, is_equal());
|
||||
}
|
||||
@ -235,10 +241,10 @@ namespace boost {
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Collection1T, typename Collection2T>
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool icontains(
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Test,
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return contains(Input, Test, is_iequal(Loc));
|
||||
@ -262,16 +268,16 @@ namespace boost {
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Collection1T, typename Collection2T, typename PredicateT>
|
||||
template<typename Range1T, typename Range2T, typename PredicateT>
|
||||
inline bool equals(
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Test,
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
PredicateT Comp)
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
const_iterator_of<Collection1T>::type Iterator1T;
|
||||
range_const_iterator<Range1T>::type Iterator1T;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
const_iterator_of<Collection2T>::type Iterator2T;
|
||||
range_const_iterator<Range2T>::type Iterator2T;
|
||||
|
||||
Iterator1T InputEnd=end(Input);
|
||||
Iterator2T TestEnd=end(Test);
|
||||
@ -293,10 +299,10 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename Collection1T, typename Collection2T>
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool equals(
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Test)
|
||||
const Range1T& Input,
|
||||
const Range2T& Test)
|
||||
{
|
||||
return equals(Input, Test, is_equal());
|
||||
}
|
||||
@ -316,10 +322,10 @@ namespace boost {
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Collection1T, typename Collection2T>
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool iequals(
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Test,
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return equals(Input, Test, is_iequal(Loc));
|
||||
@ -338,13 +344,13 @@ namespace boost {
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename CollectionT, typename PredicateT>
|
||||
template<typename RangeT, typename PredicateT>
|
||||
inline bool all(
|
||||
const CollectionT& Input,
|
||||
const RangeT& Input,
|
||||
PredicateT Pred)
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
const_iterator_of<CollectionT>::type Iterator1T;
|
||||
range_const_iterator<RangeT>::type Iterator1T;
|
||||
|
||||
Iterator1T InputEnd=end(Input);
|
||||
for( Iterator1T It=begin(Input); It!=InputEnd; ++It)
|
||||
|
@ -12,8 +12,12 @@
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
#include <boost/algorithm/string/iterator_range.hpp>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/result_iterator.hpp>
|
||||
|
||||
#include <boost/algorithm/string/find_format.hpp>
|
||||
#include <boost/algorithm/string/regex_find_format.hpp>
|
||||
#include <boost/algorithm/string/formatter.hpp>
|
||||
@ -37,21 +41,21 @@ namespace boost {
|
||||
\param Flags Regex options
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c InputContainerT::iterator or
|
||||
\c InputContainerT::const_iterator, depending on the constness of
|
||||
Returned iterator is either \c RangeT::iterator or
|
||||
\c RangeT::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename CollectionT,
|
||||
typename RangeT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT, typename RegexAllocatorT>
|
||||
typename RegexTraitsT>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME result_iterator_of<CollectionT>::type >
|
||||
BOOST_STRING_TYPENAME range_result_iterator<RangeT>::type >
|
||||
find_regex(
|
||||
CollectionT& Input,
|
||||
const reg_expression<CharT, RegexTraitsT, RegexAllocatorT>& Rx,
|
||||
RangeT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type Flags=match_default )
|
||||
{
|
||||
return regex_finder(Rx,Flags)(
|
||||
@ -79,14 +83,14 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename CollectionT,
|
||||
typename RangeT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT, typename RegexAllocatorT,
|
||||
typename RegexTraitsT,
|
||||
typename FormatStringTraitsT, typename FormatStringAllocatorT >
|
||||
inline OutputIteratorT replace_regex_copy(
|
||||
OutputIteratorT Output,
|
||||
const CollectionT& Input,
|
||||
const reg_expression<CharT, RegexTraitsT, RegexAllocatorT>& Rx,
|
||||
const RangeT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format,
|
||||
match_flag_type Flags=match_default | format_default )
|
||||
{
|
||||
@ -104,11 +108,11 @@ namespace boost {
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT, typename RegexAllocatorT,
|
||||
typename RegexTraitsT,
|
||||
typename FormatStringTraitsT, typename FormatStringAllocatorT >
|
||||
inline SequenceT replace_regex_copy(
|
||||
const SequenceT& Input,
|
||||
const reg_expression<CharT, RegexTraitsT, RegexAllocatorT>& Rx,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format,
|
||||
match_flag_type Flags=match_default | format_default )
|
||||
{
|
||||
@ -131,11 +135,11 @@ namespace boost {
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT, typename RegexAllocatorT,
|
||||
typename RegexTraitsT,
|
||||
typename FormatStringTraitsT, typename FormatStringAllocatorT >
|
||||
inline void replace_regex(
|
||||
SequenceT& Input,
|
||||
const reg_expression<CharT, RegexTraitsT, RegexAllocatorT>& Rx,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format,
|
||||
match_flag_type Flags=match_default | format_default )
|
||||
{
|
||||
@ -165,14 +169,14 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename CollectionT,
|
||||
typename RangeT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT, typename RegexAllocatorT,
|
||||
typename RegexTraitsT,
|
||||
typename FormatStringTraitsT, typename FormatStringAllocatorT >
|
||||
inline OutputIteratorT replace_all_regex_copy(
|
||||
OutputIteratorT Output,
|
||||
const CollectionT& Input,
|
||||
const reg_expression<CharT, RegexTraitsT, RegexAllocatorT>& Rx,
|
||||
const RangeT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format,
|
||||
match_flag_type Flags=match_default | format_default )
|
||||
{
|
||||
@ -190,11 +194,11 @@ namespace boost {
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT, typename RegexAllocatorT,
|
||||
typename RegexTraitsT,
|
||||
typename FormatStringTraitsT, typename FormatStringAllocatorT >
|
||||
inline SequenceT replace_all_regex_copy(
|
||||
const SequenceT& Input,
|
||||
const reg_expression<CharT, RegexTraitsT, RegexAllocatorT>& Rx,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format,
|
||||
match_flag_type Flags=match_default | format_default )
|
||||
{
|
||||
@ -217,11 +221,11 @@ namespace boost {
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT, typename RegexAllocatorT,
|
||||
typename RegexTraitsT,
|
||||
typename FormatStringTraitsT, typename FormatStringAllocatorT >
|
||||
inline void replace_all_regex(
|
||||
SequenceT& Input,
|
||||
const reg_expression<CharT, RegexTraitsT, RegexAllocatorT>& Rx,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format,
|
||||
match_flag_type Flags=match_default | format_default )
|
||||
{
|
||||
@ -250,13 +254,13 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename CollectionT,
|
||||
typename RangeT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT, typename RegexAllocatorT >
|
||||
typename RegexTraitsT >
|
||||
inline OutputIteratorT erase_regex_copy(
|
||||
OutputIteratorT Output,
|
||||
const CollectionT& Input,
|
||||
const reg_expression<CharT, RegexTraitsT, RegexAllocatorT>& Rx,
|
||||
const RangeT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type Flags=match_default )
|
||||
{
|
||||
return find_format_copy(
|
||||
@ -273,10 +277,10 @@ namespace boost {
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT, typename RegexAllocatorT >
|
||||
typename RegexTraitsT >
|
||||
inline SequenceT erase_regex_copy(
|
||||
const SequenceT& Input,
|
||||
const reg_expression<CharT, RegexTraitsT, RegexAllocatorT>& Rx,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type Flags=match_default )
|
||||
{
|
||||
return find_format_copy(
|
||||
@ -297,10 +301,10 @@ namespace boost {
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT, typename RegexAllocatorT >
|
||||
typename RegexTraitsT >
|
||||
inline void erase_regex(
|
||||
SequenceT& Input,
|
||||
const reg_expression<CharT, RegexTraitsT, RegexAllocatorT>& Rx,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type Flags=match_default )
|
||||
{
|
||||
find_format(
|
||||
@ -329,13 +333,13 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename CollectionT,
|
||||
typename RangeT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT, typename RegexAllocatorT >
|
||||
typename RegexTraitsT >
|
||||
inline OutputIteratorT erase_all_regex_copy(
|
||||
OutputIteratorT Output,
|
||||
const CollectionT& Input,
|
||||
const reg_expression<CharT, RegexTraitsT, RegexAllocatorT>& Rx,
|
||||
const RangeT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type Flags=match_default )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
@ -352,10 +356,10 @@ namespace boost {
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT, typename RegexAllocatorT >
|
||||
typename RegexTraitsT >
|
||||
inline SequenceT erase_all_regex_copy(
|
||||
const SequenceT& Input,
|
||||
const reg_expression<CharT, RegexTraitsT, RegexAllocatorT>& Rx,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type Flags=match_default )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
@ -376,10 +380,10 @@ namespace boost {
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT, typename RegexAllocatorT>
|
||||
typename RegexTraitsT>
|
||||
inline void erase_all_regex(
|
||||
SequenceT& Input,
|
||||
const reg_expression<CharT, RegexTraitsT, RegexAllocatorT>& Rx,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type Flags=match_default )
|
||||
{
|
||||
find_format_all(
|
||||
@ -414,13 +418,13 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename SequenceSequenceT,
|
||||
typename CollectionT,
|
||||
typename RangeT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT, typename RegexAllocatorT >
|
||||
typename RegexTraitsT >
|
||||
inline SequenceSequenceT& find_all_regex(
|
||||
SequenceSequenceT& Result,
|
||||
const CollectionT& Input,
|
||||
const reg_expression<CharT, RegexTraitsT, RegexAllocatorT>& Rx,
|
||||
const RangeT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type Flags=match_default )
|
||||
{
|
||||
return iter_find(
|
||||
@ -455,13 +459,13 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename SequenceSequenceT,
|
||||
typename CollectionT,
|
||||
typename RangeT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT, typename RegexAllocatorT >
|
||||
typename RegexTraitsT >
|
||||
inline SequenceSequenceT& split_regex(
|
||||
SequenceSequenceT& Result,
|
||||
const CollectionT& Input,
|
||||
const reg_expression<CharT, RegexTraitsT, RegexAllocatorT>& Rx,
|
||||
const RangeT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type Flags=match_default )
|
||||
{
|
||||
return iter_split(
|
||||
|
@ -40,15 +40,15 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename CharT,
|
||||
typename RegexTraitsT, typename RegexAllocatorT>
|
||||
inline detail::find_regexF< reg_expression<CharT, RegexTraitsT, RegexAllocatorT> >
|
||||
typename RegexTraitsT>
|
||||
inline detail::find_regexF< basic_regex<CharT, RegexTraitsT> >
|
||||
regex_finder(
|
||||
const reg_expression<CharT, RegexTraitsT, RegexAllocatorT>& Rx,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type MatchFlags=match_default )
|
||||
{
|
||||
return detail::
|
||||
find_regexF<
|
||||
reg_expression<CharT, RegexTraitsT, RegexAllocatorT> >( Rx, MatchFlags );
|
||||
basic_regex<CharT, RegexTraitsT> >( Rx, MatchFlags );
|
||||
}
|
||||
|
||||
// regex_formater ---------------------------------------------//
|
||||
@ -78,6 +78,11 @@ namespace boost {
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull the names to the boost namespace
|
||||
using algorithm::regex_finder;
|
||||
using algorithm::regex_formatter;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
@ -11,8 +11,13 @@
|
||||
#define BOOST_STRING_REPLACE_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
#include <boost/algorithm/string/iterator_range.hpp>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
|
||||
#include <boost/algorithm/string/find_format.hpp>
|
||||
#include <boost/algorithm/string/finder.hpp>
|
||||
#include <boost/algorithm/string/formatter.hpp>
|
||||
@ -45,15 +50,15 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Collection1T,
|
||||
typename Collection2T>
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT replace_range_copy(
|
||||
OutputIteratorT Output,
|
||||
const Collection1T& Input,
|
||||
const Range1T& Input,
|
||||
const iterator_range<
|
||||
BOOST_STRING_TYPENAME
|
||||
const_iterator_of<Collection1T>::type>& SearchRange,
|
||||
const Collection2T& Format)
|
||||
range_const_iterator<Range1T>::type>& SearchRange,
|
||||
const Range2T& Format)
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
@ -66,13 +71,13 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT replace_range_copy(
|
||||
const SequenceT& Input,
|
||||
const iterator_range<
|
||||
BOOST_STRING_TYPENAME
|
||||
const_iterator_of<SequenceT>::type>& SearchRange,
|
||||
const CollectionT& Format)
|
||||
range_const_iterator<SequenceT>::type>& SearchRange,
|
||||
const RangeT& Format)
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
@ -89,13 +94,13 @@ namespace boost {
|
||||
\param SearchRange A range in the input to be substituted
|
||||
\param Format A substitute string
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void replace_range(
|
||||
SequenceT& Input,
|
||||
const iterator_range<
|
||||
BOOST_STRING_TYPENAME
|
||||
iterator_of<SequenceT>::type>& SearchRange,
|
||||
const CollectionT& Format)
|
||||
range_iterator<SequenceT>::type>& SearchRange,
|
||||
const RangeT& Format)
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
@ -123,14 +128,14 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Collection1T,
|
||||
typename Collection2T,
|
||||
typename Collection3T>
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT replace_first_copy(
|
||||
OutputIteratorT Output,
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Search,
|
||||
const Collection3T& Format)
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const Range3T& Format)
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
@ -143,11 +148,11 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Collection1T, typename Collection2T>
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline SequenceT replace_first_copy(
|
||||
const SequenceT& Input,
|
||||
const Collection1T& Search,
|
||||
const Collection2T& Format )
|
||||
const Range1T& Search,
|
||||
const Range2T& Format )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
@ -164,11 +169,11 @@ namespace boost {
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
*/
|
||||
template<typename SequenceT, typename Collection1T, typename Collection2T>
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void replace_first(
|
||||
SequenceT& Input,
|
||||
const Collection1T& Search,
|
||||
const Collection2T& Format )
|
||||
const Range1T& Search,
|
||||
const Range2T& Format )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
@ -198,14 +203,14 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Collection1T,
|
||||
typename Collection2T,
|
||||
typename Collection3T>
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT ireplace_first_copy(
|
||||
OutputIteratorT Output,
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Search,
|
||||
const Collection3T& Format,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const Range3T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
@ -219,11 +224,11 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Collection2T, typename Collection1T>
|
||||
template<typename SequenceT, typename Range2T, typename Range1T>
|
||||
inline SequenceT ireplace_first_copy(
|
||||
const SequenceT& Input,
|
||||
const Collection2T& Search,
|
||||
const Collection1T& Format,
|
||||
const Range2T& Search,
|
||||
const Range1T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
@ -243,11 +248,11 @@ namespace boost {
|
||||
\param Format A substitute string
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename Collection1T, typename Collection2T>
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void ireplace_first(
|
||||
SequenceT& Input,
|
||||
const Collection1T& Search,
|
||||
const Collection2T& Format,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
find_format(
|
||||
@ -276,14 +281,14 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Collection1T,
|
||||
typename Collection2T,
|
||||
typename Collection3T>
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT replace_last_copy(
|
||||
OutputIteratorT Output,
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Search,
|
||||
const Collection3T& Format )
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const Range3T& Format )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
@ -296,11 +301,11 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Collection1T, typename Collection2T>
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline SequenceT replace_last_copy(
|
||||
const SequenceT& Input,
|
||||
const Collection1T& Search,
|
||||
const Collection2T& Format )
|
||||
const Range1T& Search,
|
||||
const Range2T& Format )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
@ -317,11 +322,11 @@ namespace boost {
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
*/
|
||||
template<typename SequenceT, typename Collection1T, typename Collection2T>
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void replace_last(
|
||||
SequenceT& Input,
|
||||
const Collection1T& Search,
|
||||
const Collection2T& Format )
|
||||
const Range1T& Search,
|
||||
const Range2T& Format )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
@ -351,14 +356,14 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Collection1T,
|
||||
typename Collection2T,
|
||||
typename Collection3T>
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT ireplace_last_copy(
|
||||
OutputIteratorT Output,
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Search,
|
||||
const Collection3T& Format,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const Range3T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
@ -372,11 +377,11 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Collection1T, typename Collection2T>
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline SequenceT ireplace_last_copy(
|
||||
const SequenceT& Input,
|
||||
const Collection1T& Search,
|
||||
const Collection2T& Format,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
@ -397,11 +402,11 @@ namespace boost {
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return A reference to the modified input
|
||||
*/
|
||||
template<typename SequenceT, typename Collection1T, typename Collection2T>
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void ireplace_last(
|
||||
SequenceT& Input,
|
||||
const Collection1T& Search,
|
||||
const Collection2T& Format,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
find_format(
|
||||
@ -431,15 +436,15 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Collection1T,
|
||||
typename Collection2T,
|
||||
typename Collection3T>
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT replace_nth_copy(
|
||||
OutputIteratorT Output,
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Search,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
unsigned int Nth,
|
||||
const Collection3T& Format )
|
||||
const Range3T& Format )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
@ -452,12 +457,12 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Collection1T, typename Collection2T>
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline SequenceT replace_nth_copy(
|
||||
const SequenceT& Input,
|
||||
const Collection1T& Search,
|
||||
const Range1T& Search,
|
||||
unsigned int Nth,
|
||||
const Collection2T& Format )
|
||||
const Range2T& Format )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
@ -475,12 +480,12 @@ namespace boost {
|
||||
\param Nth An index of the match to be replaced. The index is 0-based.
|
||||
\param Format A substitute string
|
||||
*/
|
||||
template<typename SequenceT, typename Collection1T, typename Collection2T>
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void replace_nth(
|
||||
SequenceT& Input,
|
||||
const Collection1T& Search,
|
||||
const Range1T& Search,
|
||||
unsigned int Nth,
|
||||
const Collection2T& Format )
|
||||
const Range2T& Format )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
@ -511,15 +516,15 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Collection1T,
|
||||
typename Collection2T,
|
||||
typename Collection3T>
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT ireplace_nth_copy(
|
||||
OutputIteratorT Output,
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Search,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
unsigned int Nth,
|
||||
const Collection3T& Format,
|
||||
const Range3T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
@ -533,12 +538,12 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Collection1T, typename Collection2T>
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline SequenceT ireplace_nth_copy(
|
||||
const SequenceT& Input,
|
||||
const Collection1T& Search,
|
||||
const Range1T& Search,
|
||||
unsigned int Nth,
|
||||
const Collection2T& Format,
|
||||
const Range2T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
@ -559,12 +564,12 @@ namespace boost {
|
||||
\param Format A substitute string
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename Collection1T, typename Collection2T>
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void ireplace_nth(
|
||||
SequenceT& Input,
|
||||
const Collection1T& Search,
|
||||
const Range1T& Search,
|
||||
unsigned int Nth,
|
||||
const Collection2T& Format,
|
||||
const Range2T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
find_format(
|
||||
@ -593,14 +598,14 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Collection1T,
|
||||
typename Collection2T,
|
||||
typename Collection3T>
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT replace_all_copy(
|
||||
OutputIteratorT Output,
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Search,
|
||||
const Collection3T& Format )
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const Range3T& Format )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
Output,
|
||||
@ -613,11 +618,11 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Collection1T, typename Collection2T>
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline SequenceT replace_all_copy(
|
||||
const SequenceT& Input,
|
||||
const Collection1T& Search,
|
||||
const Collection2T& Format )
|
||||
const Range1T& Search,
|
||||
const Range2T& Format )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
Input,
|
||||
@ -635,11 +640,11 @@ namespace boost {
|
||||
\param Format A substitute string
|
||||
\return A reference to the modified input
|
||||
*/
|
||||
template<typename SequenceT, typename Collection1T, typename Collection2T>
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void replace_all(
|
||||
SequenceT& Input,
|
||||
const Collection1T& Search,
|
||||
const Collection2T& Format )
|
||||
const Range1T& Search,
|
||||
const Range2T& Format )
|
||||
{
|
||||
find_format_all(
|
||||
Input,
|
||||
@ -669,14 +674,14 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Collection1T,
|
||||
typename Collection2T,
|
||||
typename Collection3T>
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT ireplace_all_copy(
|
||||
OutputIteratorT Output,
|
||||
const Collection1T& Input,
|
||||
const Collection2T& Search,
|
||||
const Collection3T& Format,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const Range3T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
@ -690,11 +695,11 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Collection1T, typename Collection2T>
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline SequenceT ireplace_all_copy(
|
||||
const SequenceT& Input,
|
||||
const Collection1T& Search,
|
||||
const Collection2T& Format,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
@ -714,11 +719,11 @@ namespace boost {
|
||||
\param Format A substitute string
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename Collection1T, typename Collection2T>
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void ireplace_all(
|
||||
SequenceT& Input,
|
||||
const Collection1T& Search,
|
||||
const Collection2T& Format,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
find_format_all(
|
||||
@ -749,13 +754,13 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Collection1T,
|
||||
typename Collection2T>
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT replace_head_copy(
|
||||
OutputIteratorT Output,
|
||||
const Collection1T& Input,
|
||||
const Range1T& Input,
|
||||
unsigned int N,
|
||||
const Collection2T& Format )
|
||||
const Range2T& Format )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
@ -768,11 +773,11 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT replace_head_copy(
|
||||
const SequenceT& Input,
|
||||
unsigned int N,
|
||||
const CollectionT& Format )
|
||||
const RangeT& Format )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
@ -791,11 +796,11 @@ namespace boost {
|
||||
\param N Length of the head
|
||||
\param Format A substitute string
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void replace_head(
|
||||
SequenceT& Input,
|
||||
unsigned int N,
|
||||
const CollectionT& Format )
|
||||
const RangeT& Format )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
@ -825,13 +830,13 @@ namespace boost {
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Collection1T,
|
||||
typename Collection2T>
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT replace_tail_copy(
|
||||
OutputIteratorT Output,
|
||||
const Collection1T& Input,
|
||||
const Range1T& Input,
|
||||
unsigned int N,
|
||||
const Collection2T& Format )
|
||||
const Range2T& Format )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
@ -844,11 +849,11 @@ namespace boost {
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT replace_tail_copy(
|
||||
const SequenceT& Input,
|
||||
unsigned int N,
|
||||
const CollectionT& Format )
|
||||
const RangeT& Format )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
@ -867,11 +872,11 @@ namespace boost {
|
||||
\param N Length of the tail
|
||||
\param Format A substitute string
|
||||
*/
|
||||
template<typename SequenceT, typename CollectionT>
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void replace_tail(
|
||||
SequenceT& Input,
|
||||
unsigned int N,
|
||||
const CollectionT& Format )
|
||||
const RangeT& Format )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
Due to a language restriction, it is not currently possible to define specializations for
|
||||
stl containers without including the corresponding header. To decrease the overhead
|
||||
needed by this inclusion, user can selectively include a specialization
|
||||
needed by this inclusion, user can selectively include a specialization
|
||||
header for a specific container. They are located in boost/algorithm/string/stl
|
||||
directory. Alternatively she can include boost/algorithm/string/std_collection_traits.hpp
|
||||
header which contains specializations for all stl containers.
|
||||
@ -39,7 +39,7 @@ namespace boost {
|
||||
|
||||
//! Native replace tester
|
||||
/*!
|
||||
Declare an override of this tester function with return
|
||||
Declare an override of this tester function with return
|
||||
type boost::string_algo::yes_type for a sequence with this property.
|
||||
|
||||
\return yes_type if the container has basic_string like native replace
|
||||
@ -49,31 +49,31 @@ namespace boost {
|
||||
|
||||
//! Stable iterators tester
|
||||
/*!
|
||||
Declare an override of this tester function with return
|
||||
Declare an override of this tester function with return
|
||||
type boost::string_algo::yes_type for a sequence with this property.
|
||||
|
||||
\return yes_type if the sequence's insert/replace/erase methods do not invalidate
|
||||
existing iterators.
|
||||
*/
|
||||
no_type has_stable_iterators_tester(...);
|
||||
no_type has_stable_iterators_tester(...);
|
||||
|
||||
//! const time insert tester
|
||||
/*!
|
||||
Declare an override of this tester function with return
|
||||
Declare an override of this tester function with return
|
||||
type boost::string_algo::yes_type for a sequence with this property.
|
||||
|
||||
\return yes_type if the sequence's insert method is working in constant time
|
||||
*/
|
||||
no_type has_const_time_insert_tester(...);
|
||||
no_type has_const_time_insert_tester(...);
|
||||
|
||||
//! const time erase tester
|
||||
/*!
|
||||
Declare an override of this tester function with return
|
||||
Declare an override of this tester function with return
|
||||
type boost::string_algo::yes_type for a sequence with this property.
|
||||
|
||||
\return yes_type if the sequence's erase method is working in constant time
|
||||
*/
|
||||
no_type has_const_time_erase_tester(...);
|
||||
no_type has_const_time_erase_tester(...);
|
||||
|
||||
#endif //BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
@ -89,7 +89,7 @@ namespace boost {
|
||||
private:
|
||||
static T* t;
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, value=(
|
||||
BOOST_STATIC_CONSTANT(bool, value=(
|
||||
sizeof(has_native_replace_tester(t))==sizeof(yes_type) ) );
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
public:
|
||||
@ -99,9 +99,9 @@ namespace boost {
|
||||
BOOST_STATIC_CONSTANT(bool, value=false);
|
||||
# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
|
||||
typedef mpl::bool_<value> type;
|
||||
|
||||
typedef mpl::bool_<has_native_replace<T>::value> type;
|
||||
};
|
||||
|
||||
|
||||
@ -117,7 +117,7 @@ namespace boost {
|
||||
private:
|
||||
static T* t;
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, value=(
|
||||
BOOST_STATIC_CONSTANT(bool, value=(
|
||||
sizeof(has_stable_iterators_tester(t))==sizeof(yes_type) ) );
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
public:
|
||||
@ -128,13 +128,13 @@ namespace boost {
|
||||
# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
typedef mpl::bool_<value> type;
|
||||
typedef mpl::bool_<has_stable_iterators<T>::value> type;
|
||||
};
|
||||
|
||||
|
||||
//! Const time insert trait
|
||||
/*!
|
||||
This trait specifies that the sequence's insert method has
|
||||
This trait specifies that the sequence's insert method has
|
||||
constant time complexity.
|
||||
*/
|
||||
template< typename T >
|
||||
@ -144,7 +144,7 @@ namespace boost {
|
||||
private:
|
||||
static T* t;
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, value=(
|
||||
BOOST_STATIC_CONSTANT(bool, value=(
|
||||
sizeof(has_const_time_insert_tester(t))==sizeof(yes_type) ) );
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
public:
|
||||
@ -155,13 +155,13 @@ namespace boost {
|
||||
# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
typedef mpl::bool_<value> type;
|
||||
typedef mpl::bool_<has_const_time_insert<T>::value> type;
|
||||
};
|
||||
|
||||
|
||||
//! Const time erase trait
|
||||
/*!
|
||||
This trait specifies that the sequence's erase method has
|
||||
This trait specifies that the sequence's erase method has
|
||||
constant time complexity.
|
||||
*/
|
||||
template< typename T >
|
||||
@ -171,7 +171,7 @@ namespace boost {
|
||||
private:
|
||||
static T* t;
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, value=(
|
||||
BOOST_STATIC_CONSTANT(bool, value=(
|
||||
sizeof(has_const_time_erase_tester(t))==sizeof(yes_type) ) );
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
public:
|
||||
@ -182,7 +182,7 @@ namespace boost {
|
||||
# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
typedef mpl::bool_<value> type;
|
||||
typedef mpl::bool_<has_const_time_erase<T>::value> type;
|
||||
};
|
||||
|
||||
} // namespace algorithm
|
||||
|
@ -11,8 +11,7 @@
|
||||
#define BOOST_STRING_SPLIT_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
#include <boost/algorithm/string/iterator_range.hpp>
|
||||
|
||||
#include <boost/algorithm/string/iter_find.hpp>
|
||||
#include <boost/algorithm/string/finder.hpp>
|
||||
#include <boost/algorithm/string/compare.hpp>
|
||||
@ -58,11 +57,11 @@ namespace boost {
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template< typename SequenceSequenceT, typename Collection1T, typename Collection2T >
|
||||
template< typename SequenceSequenceT, typename Range1T, typename Range2T >
|
||||
inline SequenceSequenceT& find_all(
|
||||
SequenceSequenceT& Result,
|
||||
Collection1T& Input,
|
||||
const Collection2T& Search)
|
||||
Range1T& Input,
|
||||
const Range2T& Search)
|
||||
{
|
||||
return iter_find(
|
||||
Result,
|
||||
@ -93,11 +92,11 @@ namespace boost {
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template< typename SequenceSequenceT, typename Collection1T, typename Collection2T >
|
||||
template< typename SequenceSequenceT, typename Range1T, typename Range2T >
|
||||
inline SequenceSequenceT& ifind_all(
|
||||
SequenceSequenceT& Result,
|
||||
Collection1T& Input,
|
||||
const Collection2T& Search,
|
||||
Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return iter_find(
|
||||
@ -136,10 +135,10 @@ namespace boost {
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template< typename SequenceSequenceT, typename CollectionT, typename PredicateT >
|
||||
template< typename SequenceSequenceT, typename RangeT, typename PredicateT >
|
||||
inline SequenceSequenceT& split(
|
||||
SequenceSequenceT& Result,
|
||||
CollectionT& Input,
|
||||
RangeT& Input,
|
||||
PredicateT Pred,
|
||||
token_compress_mode_type eCompress=token_compress_off )
|
||||
{
|
||||
|
@ -33,9 +33,9 @@ namespace boost {
|
||||
template<typename T, typename AllocT>
|
||||
yes_type has_const_time_erase_tester( const ::std::list<T,AllocT>* );
|
||||
|
||||
|
||||
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
|
||||
// stable iterators trait
|
||||
template<typename T, typename AllocT>
|
||||
class has_stable_iterators< ::std::list<T,AllocT> >
|
||||
@ -46,7 +46,7 @@ namespace boost {
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<value> type;
|
||||
typedef mpl::bool_<has_stable_iterators<T>::value> type;
|
||||
};
|
||||
|
||||
// const time insert trait
|
||||
@ -59,7 +59,7 @@ namespace boost {
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<value> type;
|
||||
typedef mpl::bool_<has_const_time_insert<T>::value> type;
|
||||
};
|
||||
|
||||
// const time erase trait
|
||||
@ -72,11 +72,11 @@ namespace boost {
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<value> type;
|
||||
typedef mpl::bool_<has_const_time_erase<T>::value> type;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#ifndef BOOST_STRING_STD_SLIST_TRAITS_HPP
|
||||
#define BOOST_STRING_STD_SLIST_TRAITS_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/algorithm/string/yes_no_type.hpp>
|
||||
#include <slist>
|
||||
#include <boost/algorithm/string/sequence_traits.hpp>
|
||||
@ -23,21 +24,21 @@ namespace boost {
|
||||
|
||||
// stable iterators tester
|
||||
template<typename T, typename AllocT>
|
||||
yes_type has_stable_iterators_tester( const std::slist<T,AllocT>* );
|
||||
yes_type has_stable_iterators_tester( const BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT>* );
|
||||
|
||||
// const time insert tester
|
||||
template<typename T, typename AllocT>
|
||||
yes_type has_const_time_insert_tester( const std::slist<T,AllocT>* );
|
||||
yes_type has_const_time_insert_tester( const BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT>* );
|
||||
|
||||
// const time erase tester
|
||||
template<typename T, typename AllocT>
|
||||
yes_type has_const_time_erase_tester( const std::slist<T,AllocT>* );
|
||||
yes_type has_const_time_erase_tester( const BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT>* );
|
||||
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
|
||||
// stable iterators trait
|
||||
template<typename T, typename AllocT>
|
||||
class has_stable_iterators< std::slist<T,AllocT> >
|
||||
class has_stable_iterators< BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT> >
|
||||
{
|
||||
public:
|
||||
#if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
@ -45,12 +46,12 @@ namespace boost {
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<value> type;
|
||||
typedef mpl::bool_<has_stable_iterators<T>::value> type;
|
||||
};
|
||||
|
||||
// const time insert trait
|
||||
template<typename T, typename AllocT>
|
||||
class has_const_time_insert< std::slist<T,AllocT> >
|
||||
class has_const_time_insert< BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT> >
|
||||
{
|
||||
public:
|
||||
#if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
@ -58,12 +59,12 @@ namespace boost {
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<value> type;
|
||||
typedef mpl::bool_<has_const_time_insert<T>::value> type;
|
||||
};
|
||||
|
||||
// const time erase trait
|
||||
template<typename T, typename AllocT>
|
||||
class has_const_time_erase< std::slist<T,AllocT> >
|
||||
class has_const_time_erase< BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT> >
|
||||
{
|
||||
public:
|
||||
#if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
@ -71,7 +72,7 @@ namespace boost {
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<value> type;
|
||||
typedef mpl::bool_<has_const_time_erase<T>::value> type;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -38,7 +38,7 @@ namespace boost {
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
|
||||
typedef mpl::bool_<value> type;
|
||||
typedef mpl::bool_<has_native_replace<T>::value> type;
|
||||
};
|
||||
|
||||
|
||||
|
@ -11,7 +11,11 @@
|
||||
#define BOOST_STRING_TRIM_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
|
||||
#include <boost/algorithm/string/detail/trim.hpp>
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <locale>
|
||||
@ -42,7 +46,7 @@ namespace boost {
|
||||
or copied to the output iterator
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input collection
|
||||
\param Input An input range
|
||||
\param IsSpace An unary predicate identifying spaces
|
||||
\return
|
||||
An output iterator pointing just after the last inserted character or
|
||||
@ -50,14 +54,14 @@ namespace boost {
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename OutputIteratorT, typename CollectionT, typename PredicateT>
|
||||
template<typename OutputIteratorT, typename RangeT, typename PredicateT>
|
||||
inline OutputIteratorT trim_left_copy_if(
|
||||
OutputIteratorT Output,
|
||||
const CollectionT& Input,
|
||||
const RangeT& Input,
|
||||
PredicateT IsSpace)
|
||||
{
|
||||
std::copy(
|
||||
detail::trim_begin(
|
||||
::boost::algorithm::detail::trim_begin(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
IsSpace ),
|
||||
@ -75,7 +79,7 @@ namespace boost {
|
||||
inline SequenceT trim_left_copy_if(const SequenceT& Input, PredicateT IsSpace)
|
||||
{
|
||||
return SequenceT(
|
||||
detail::trim_begin(
|
||||
::boost::algorithm::detail::trim_begin(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
IsSpace ),
|
||||
@ -116,7 +120,7 @@ namespace boost {
|
||||
{
|
||||
Input.erase(
|
||||
begin(Input),
|
||||
detail::trim_begin(
|
||||
::boost::algorithm::detail::trim_begin(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
IsSpace));
|
||||
@ -148,7 +152,7 @@ namespace boost {
|
||||
or copied to the output iterator
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input collection
|
||||
\param Input An input range
|
||||
\param IsSpace An unary predicate identifying spaces
|
||||
\return
|
||||
An output iterator pointing just after the last inserted character or
|
||||
@ -156,15 +160,15 @@ namespace boost {
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename OutputIteratorT, typename CollectionT, typename PredicateT>
|
||||
template<typename OutputIteratorT, typename RangeT, typename PredicateT>
|
||||
inline OutputIteratorT trim_right_copy_if(
|
||||
OutputIteratorT Output,
|
||||
const CollectionT& Input,
|
||||
const RangeT& Input,
|
||||
PredicateT IsSpace )
|
||||
{
|
||||
std::copy(
|
||||
begin(Input),
|
||||
detail::trim_end(
|
||||
::boost::algorithm::detail::trim_end(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
IsSpace ),
|
||||
@ -182,7 +186,7 @@ namespace boost {
|
||||
{
|
||||
return SequenceT(
|
||||
begin(Input),
|
||||
detail::trim_end(
|
||||
::boost::algorithm::detail::trim_end(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
IsSpace)
|
||||
@ -223,7 +227,7 @@ namespace boost {
|
||||
inline void trim_right_if(SequenceT& Input, PredicateT IsSpace)
|
||||
{
|
||||
Input.erase(
|
||||
detail::trim_end(
|
||||
::boost::algorithm::detail::trim_end(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
IsSpace ),
|
||||
@ -258,7 +262,7 @@ namespace boost {
|
||||
or copied to the output iterator
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input collection
|
||||
\param Input An input range
|
||||
\param IsSpace An unary predicate identifying spaces
|
||||
\return
|
||||
An output iterator pointing just after the last inserted character or
|
||||
@ -266,15 +270,15 @@ namespace boost {
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename OutputIteratorT, typename CollectionT, typename PredicateT>
|
||||
template<typename OutputIteratorT, typename RangeT, typename PredicateT>
|
||||
inline OutputIteratorT trim_copy_if(
|
||||
OutputIteratorT Output,
|
||||
const CollectionT& Input,
|
||||
const RangeT& Input,
|
||||
PredicateT IsSpace)
|
||||
{
|
||||
BOOST_STRING_TYPENAME
|
||||
const_iterator_of<CollectionT>::type TrimEnd=
|
||||
detail::trim_end(
|
||||
range_const_iterator<RangeT>::type TrimEnd=
|
||||
::boost::algorithm::detail::trim_end(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
IsSpace);
|
||||
@ -297,8 +301,8 @@ namespace boost {
|
||||
inline SequenceT trim_copy_if(const SequenceT& Input, PredicateT IsSpace)
|
||||
{
|
||||
BOOST_STRING_TYPENAME
|
||||
const_iterator_of<SequenceT>::type TrimEnd=
|
||||
detail::trim_end(
|
||||
range_const_iterator<SequenceT>::type TrimEnd=
|
||||
::boost::algorithm::detail::trim_end(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
IsSpace);
|
||||
|
@ -1,9 +1,9 @@
|
||||
// Boost string_algo library string_algo.hpp header file ---------------------------//
|
||||
// Boost string_algo library string_regex.hpp header file ---------------------------//
|
||||
|
||||
// (C) Copyright Pavol Droba 2002-2003. Permission to copy, use, modify, sell and
|
||||
// distribute this software is granted provided this copyright notice appears
|
||||
// in all copies. This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
// Copyright Pavol Droba 2002-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/string_algo.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/algorithm/string/regex.hpp>
|
||||
|
||||
#endif // BOOST_STRING_ALGO_REGEX_HPP
|
||||
|
@ -1,3 +1,8 @@
|
||||
// (C) Copyright Herve Bronnimann 2004.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
|
@ -1,3 +1,8 @@
|
||||
// (C) Copyright Herve Bronnimann 2004.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <utility>
|
||||
#include <functional>
|
||||
#include <algorithm>
|
||||
@ -55,14 +60,14 @@ int repeats = 10;
|
||||
for (int i=0; i<repeats; ++i) { cmd ; } \
|
||||
std::cout << " " << std::setprecision(4) \
|
||||
<< (double)n*repeats/t.elapsed()/1.0E6 \
|
||||
<< "M items/sec " << cmdname << "\n"
|
||||
<< "M items/sec " << cmdname << "\n"
|
||||
|
||||
#define CTIMER( n, cmd , cmdname, count, opt ) \
|
||||
t.restart(); lc.reset(); \
|
||||
for (int i=0; i<repeats; ++i) { cmd ; } \
|
||||
std::cout << " " << std::setprecision(4) \
|
||||
<< (double)n*repeats/t.elapsed()/1.0E6 \
|
||||
<< "M items/sec " << cmdname \
|
||||
<< "M items/sec " << cmdname \
|
||||
<< " ("<< (count)/repeats << " vs " << opt << ")\n"
|
||||
|
||||
template <class CIterator>
|
||||
@ -99,10 +104,10 @@ void test_minmax_element(CIterator first, CIterator last, int n, char* name)
|
||||
TIMER( n, boost::max_element_if(first, last, pred),
|
||||
"boost::max_element_if" << name << "");
|
||||
TIMER( n, std::min_element(boost::make_filter_iterator(first, last, pred),
|
||||
boost::make_filter_iterator(last, last, pred)),
|
||||
boost::make_filter_iterator(last, last, pred)),
|
||||
"std::min_element_with_filter_iterator" << name << "");
|
||||
TIMER( n, std::max_element(boost::make_filter_iterator(first, last, pred),
|
||||
boost::make_filter_iterator(last, last, pred)),
|
||||
boost::make_filter_iterator(last, last, pred)),
|
||||
"std::max_element_if_with_filter_iterator" << name << "");
|
||||
#undef pred
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<LINK REL="stylesheet" TYPE="text/css" HREF="../../../../boost.css">
|
||||
<LINK REL="stylesheet" TYPE="text/css" HREF="../../../boost.css">
|
||||
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<META name="GENERATOR" content="Mozilla/4.77 [en] (X11; U; Linux 2.2.19 i686) [Netscape]">
|
||||
<META name="Author" content="Herve Bronnimann">
|
||||
@ -10,8 +10,8 @@
|
||||
</HEAD>
|
||||
<body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B" alink="#FF0000">
|
||||
|
||||
<h2><img src="../../../c++boost.gif" WIDTH="276" HEIGHT="86">Header <<A
|
||||
HREF="../../../../boost/minmax.hpp">boost/algorithm/minmax.hpp</A>> </H2>
|
||||
<h2><img src="../../../boost.png" WIDTH="276" HEIGHT="86">Header <<A
|
||||
HREF="../../../boost/algorithm/minmax.hpp">boost/algorithm/minmax.hpp</A>> </H2>
|
||||
|
||||
<quote>
|
||||
<b>
|
||||
@ -19,7 +19,7 @@ HREF="../../../../boost/minmax.hpp">boost/algorithm/minmax.hpp</A>> </H2>
|
||||
<a href="#synopsis">Synopsis</a><br>
|
||||
<a href="#description">Function templates description</a><br>
|
||||
<a href="#definition">Definition</a><br>
|
||||
<a href="#reqs">Requirements on type</a>s<br>
|
||||
<a href="#reqs">Requirements on types</a><br>
|
||||
<a href="#precond">Preconditions</a><br>
|
||||
<a href="#postcond">Postconditions</a><br>
|
||||
<a href="#complexity">Complexity</a><br>
|
||||
@ -71,7 +71,7 @@ but I ruled against that (see <a href="#no-policy">rationale</a>).
|
||||
</p>
|
||||
|
||||
<p>If you are interested about
|
||||
<a href="minmax_benchs.html">performance</a>,
|
||||
<a href="doc/minmax_benchs.html">performance</a>,
|
||||
you will see that <tt>minmax_element</tt> is just slightly less efficient
|
||||
than a single <tt>min_element</tt> or <tt>max_element</tt>, and thus
|
||||
twice as efficient as two separate calls to <tt>min_element</tt> and
|
||||
@ -95,7 +95,7 @@ namespace boost {
|
||||
tuple<T const&, T const&> >
|
||||
minmax(const T& a, const T& b);
|
||||
|
||||
template <class T, class <a href="http://www.sgi.com/tech/stl/ BinaryPredicate.html">BinaryPredicate</a>>
|
||||
template <class T, class <a href="http://www.sgi.com/tech/stl/BinaryPredicate.html">BinaryPredicate</a>>
|
||||
tuple<T const&, T const&> >
|
||||
minmax(const T& a, const T& b, BinaryPredicate comp);
|
||||
|
||||
@ -301,8 +301,8 @@ the library under
|
||||
<a name="notes">
|
||||
<h3>
|
||||
Notes</h3>
|
||||
<a NAME="Note1"></a><a href="#Note1">[1]</a>We do not support
|
||||
idioms such as <tt><a href="http://www.boost.org/libs/tuple/doc/tuple_users_guide.html#tiers">tie</a>(a,b)=minmax(a,b)</tt>
|
||||
<a NAME="Note1"></a><a href="#Note1">[1]</a> We do not support
|
||||
idioms such as <tt><a href="../../tuple/doc/tuple_users_guide.html#tiers">tie</a>(a,b)=minmax(a,b)</tt>
|
||||
to order two elements <tt>a</tt>, <tt>b</tt>, although this would have
|
||||
the desired effect if we returned a reference instead of a constant
|
||||
reference. The reason is that two unnecessary assignments are
|
||||
|
@ -11,7 +11,10 @@ import testing ;
|
||||
|
||||
{
|
||||
test-suite algorithm/minmax:
|
||||
[ run minmax_element_test.cpp ]
|
||||
;
|
||||
: [ run minmax_element_test.cpp
|
||||
: : : : minmax_element ]
|
||||
[ run minmax_test.cpp
|
||||
: : : : minmax ]
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
// (C) Copyright Herve Bronnimann 2004.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <utility>
|
||||
#include <functional>
|
||||
#include <algorithm>
|
||||
@ -6,8 +11,9 @@
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <boost/config.hpp> /* prevents some nasty warns in MSVC */
|
||||
#include <boost/algorithm/minmax_element.hpp>
|
||||
#include <boost/test/included/test_exec_monitor.hpp>
|
||||
#include <boost/iterator/reverse_iterator.hpp>
|
||||
@ -15,7 +21,6 @@
|
||||
class custom {
|
||||
int m_x;
|
||||
friend bool operator<(custom const& x, custom const& y);
|
||||
friend std::ostream& operator<<(std::ostream& str, custom const& x);
|
||||
public:
|
||||
explicit custom(int x = 0) : m_x(x) {}
|
||||
custom(custom const& y) : m_x(y.m_x) {}
|
||||
@ -28,11 +33,7 @@ bool operator< (custom const& x, custom const& y)
|
||||
return x.m_x < y.m_x;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& str, custom const& x)
|
||||
{
|
||||
str << x.m_x;
|
||||
return str;
|
||||
}
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(custom)
|
||||
|
||||
namespace std {
|
||||
|
||||
@ -179,65 +180,62 @@ void test_minmax(CIterator first, CIterator last, int n)
|
||||
}
|
||||
|
||||
template <class Container, class Iterator, class Value>
|
||||
void test_container(Iterator first, Iterator last, int n, Container* dummy = 0 )
|
||||
void test_container(Iterator first, Iterator last, int n,
|
||||
Container* dummy = 0
|
||||
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Value) )
|
||||
{
|
||||
Container c(first, last);
|
||||
test_minmax(c.begin(), c.end(), n);
|
||||
}
|
||||
|
||||
template <class Iterator>
|
||||
void test_range(Iterator first, Iterator last, int n, char* /* name */)
|
||||
void test_range(Iterator first, Iterator last, int n)
|
||||
{
|
||||
typedef typename std::iterator_traits<Iterator>::value_type Value;
|
||||
// Test various containers with these values
|
||||
// std::cout << " vector<" << name << ">...";
|
||||
test_container< std::vector<Value>, Iterator, Value >(first, last, n);
|
||||
// std::cout << " list<" << name << ">...";
|
||||
test_container< std::list<Value>, Iterator, Value >(first, last, n);
|
||||
// std::cout << " set<" << name << ">...";
|
||||
test_container< std::set<Value>, Iterator, Value >(first, last, n);
|
||||
// std::cout << "\n";
|
||||
}
|
||||
|
||||
template <class Value>
|
||||
void test(int n, char* name)
|
||||
void test(int n BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Value))
|
||||
{
|
||||
// Populate test vector with identical values
|
||||
// std::cout << " Identical values... ";
|
||||
std::vector<Value> test_vector(n, Value(1));
|
||||
typename std::vector<Value>::iterator first( test_vector.begin() );
|
||||
typename std::vector<Value>::iterator last( test_vector.end() );
|
||||
test_range(first, last, n, name);
|
||||
test_range(first, last, n);
|
||||
|
||||
// Populate test vector with two values
|
||||
// std::cout << " Two distinct values...";
|
||||
typename std::vector<Value>::iterator middle( first + n/2 );
|
||||
std::fill(middle, last, Value(2));
|
||||
test_range(first, last, n, name);
|
||||
test_range(first, last, n);
|
||||
|
||||
// Populate test vector with increasing values
|
||||
// std::cout << " Increasing values... ";
|
||||
std::accumulate(first, last, Value(0));
|
||||
test_range(first, last, n, name);
|
||||
test_range(first, last, n);
|
||||
|
||||
// Populate test vector with decreasing values
|
||||
// std::cout << " Decreasing values... ";
|
||||
std::reverse(first, last);
|
||||
test_range(first, last, n, name);
|
||||
test_range(first, last, n);
|
||||
|
||||
// Populate test vector with random values
|
||||
// std::cout << " Random values... ";
|
||||
std::random_shuffle(first, last);
|
||||
test_range(first, last, n, name);
|
||||
test_range(first, last, n);
|
||||
}
|
||||
|
||||
int test_main( int argc, char* argv[] )
|
||||
{
|
||||
#ifndef BOOST_NO_STDC_NAMESPACE
|
||||
using std::atoi;
|
||||
#endif
|
||||
|
||||
int n = 100;
|
||||
if (argc > 1) n = atoi(argv[1]);
|
||||
|
||||
test<int>(n, "builtin");
|
||||
test<custom>(n, "custom ");
|
||||
test<int>(n);
|
||||
test<custom>(n);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,7 +1,12 @@
|
||||
// (C) Copyright Herve Bronnimann 2004.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <utility>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/algorithm/minmax.hpp>
|
||||
#include <boost/test/included/test_exec_monitor.hpp>
|
||||
|
||||
@ -39,41 +44,42 @@ private:
|
||||
int& m_counter;
|
||||
};
|
||||
|
||||
using namespace boost;
|
||||
|
||||
template <class Value>
|
||||
void test(char*)
|
||||
void test(BOOST_EXPLICIT_TEMPLATE_TYPE(Value))
|
||||
{
|
||||
using namespace boost;
|
||||
Value zero(0), one(1);
|
||||
int counter = 0;
|
||||
less_count<Value> lc(counter);
|
||||
|
||||
// Test functionality
|
||||
tuple<Value const&, Value const&> result1 = minmax(zero, one);
|
||||
BOOST_CHECK_EQUAL( result1.get<0>(), zero );
|
||||
BOOST_CHECK_EQUAL( result1.get<1>(), one );
|
||||
BOOST_CHECK_EQUAL( get<0>(result1), zero );
|
||||
BOOST_CHECK_EQUAL( get<1>(result1), one );
|
||||
|
||||
tuple<Value const&, Value const&> result2 = minmax(one, zero);
|
||||
BOOST_CHECK_EQUAL( result2.get<0>(), zero );
|
||||
BOOST_CHECK_EQUAL( result2.get<1>(), one );
|
||||
BOOST_CHECK_EQUAL( get<0>(result2), zero );
|
||||
BOOST_CHECK_EQUAL( get<1>(result2), one );
|
||||
|
||||
// Test functionality and number of comparisons
|
||||
lc.reset();
|
||||
tuple<Value const&, Value const&> result3 = minmax(zero, one, lc );
|
||||
BOOST_CHECK_EQUAL( result3.get<0>(), zero );
|
||||
BOOST_CHECK_EQUAL( result3.get<1>(), one );
|
||||
BOOST_CHECK_EQUAL( get<0>(result3), zero );
|
||||
BOOST_CHECK_EQUAL( get<1>(result3), one );
|
||||
BOOST_CHECK_EQUAL( counter, 1 );
|
||||
|
||||
lc.reset();
|
||||
tuple<Value const&, Value const&> result4 = minmax(one, zero, lc );
|
||||
BOOST_CHECK_EQUAL( result4.get<0>(), zero );
|
||||
BOOST_CHECK_EQUAL( result4.get<1>(), one );
|
||||
BOOST_CHECK_EQUAL( get<0>(result4), zero );
|
||||
BOOST_CHECK_EQUAL( get<1>(result4), one );
|
||||
BOOST_CHECK_EQUAL( counter, 1);
|
||||
}
|
||||
|
||||
int test_main( int , char* [] )
|
||||
{
|
||||
test<int>("builtin");
|
||||
test<custom>("custom ");
|
||||
test<int>(); // ("builtin");
|
||||
test<custom>(); // ("custom ");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ doxygen autodoc
|
||||
[ glob ../../../../boost/algorithm/string/iterator_range.hpp ]
|
||||
[ glob ../../../../boost/algorithm/string/sequence_traits.hpp ]
|
||||
[ glob ../../../../boost/algorithm/string/std_containers_traits.hpp ]
|
||||
[ glob ../../../../boost/algorithm/string/collection_traits.hpp ]
|
||||
[ glob ../../../../boost/algorithm/string/concept.hpp ]
|
||||
[ glob ../../../../boost/algorithm/string/compare.hpp ]
|
||||
[ glob ../../../../boost/algorithm/string/constants.hpp ]
|
||||
|
@ -11,5 +11,9 @@
|
||||
in the review process, namely David Abrahams, Daniel Frey, Beman Dawes, John Maddock, David B.Held, Pavel Vozenilek
|
||||
and many other.
|
||||
</para>
|
||||
<para>
|
||||
Additional thanks go to Stefan Slapeta and Toon Knapen, who have been very resourceful in solving various
|
||||
portability issues.
|
||||
</para>
|
||||
</section>
|
||||
</section>
|
||||
|
@ -18,15 +18,13 @@
|
||||
</para>
|
||||
<para>
|
||||
<emphasis role="bold">Definition:</emphasis> A string is a
|
||||
<ulink url="../../libs/utility/Collection.html">collection</ulink> of characters accessible in sequential
|
||||
<ulink url="../../libs/range/doc/range.html">range</ulink> of characters accessible in sequential
|
||||
ordered fashion. Character is any value type with "cheap" copying and assignment.
|
||||
</para>
|
||||
<para>
|
||||
First requirement of string-type is that it must accessible using
|
||||
<link linkend="string_algo.collection_traits">collection traits</link>. This facility allows to access
|
||||
<ulink url="../../libs/range/index.html">Boost.Range</ulink>. This facility allows to access
|
||||
the elements inside the string in a uniform iterator-based fashion.
|
||||
This requirement is actually less stringent than that of collection concept. It implements
|
||||
an <ulink url="../../libs/algorithm/string/doc/external_concepts.html">external</ulink> collection interface.
|
||||
This is sufficient for our library
|
||||
</para>
|
||||
<para>
|
||||
@ -42,166 +40,11 @@
|
||||
</para>
|
||||
<para>
|
||||
In the reference and also in the code, requirement on the string type is designated by the name of
|
||||
template argument. <code>CollectionT</code> means that the basic collection requirements must hold.
|
||||
template argument. <code>RangeT</code> means that the basic range requirements must hold.
|
||||
<code>SequenceT</code> designates extended sequence requirements.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
|
||||
<section id="string_algo.iterator_range">
|
||||
<title><code>iterator_range</code> class</title>
|
||||
|
||||
<para>
|
||||
An <classname>iterator_range</classname> is an encapsulation of a pair of iterators that
|
||||
delimit a sequence (or, a range). This concept is widely used by
|
||||
sequence manipulating algorithms. Although being so useful, there no direct support
|
||||
for it in the standard library (The closest thing is that some algorithms return a pair of iterators).
|
||||
Instead all STL algorithms have two distinct parameters for beginning and end of a range. This design
|
||||
is natural for implementation of generic algorithms, but it forbids to work with a range as a single value.
|
||||
</para>
|
||||
<para>
|
||||
It is possible to encapsulate a range in <code>std::pair<></code>, but
|
||||
<code>std::pair<></code> is an overly generic encapsulation, so it is not best match for a range.
|
||||
For instance, it does not enforce that begin and end iterators be of the same type.
|
||||
</para>
|
||||
<para>
|
||||
Naturally the range concept is heavily used also in this library. During the development of
|
||||
the library, it was discovered, that there is a need for a reasonable encapsulation for it, since
|
||||
core part of the library deals with substring searching algorithms and any such algorithm
|
||||
returns a range delimiting the result of the search. <code>std::pair<></code> was deemed as
|
||||
unsuitable. Therefore the <code>iterator_range</code> was defined.
|
||||
</para>
|
||||
<para>
|
||||
The intention of the <code>iterator_range</code> class is to manage a range as a single value and provide
|
||||
a basic interface for common operations. Its interface is similar to that of a collection.
|
||||
In addition to <code>begin()</code>
|
||||
and <code>end()</code> accessors, it has member functions for checking whether the range is empty,
|
||||
or to determine the size of the range. It also has a set of member typedefs that extract
|
||||
type information from the encapsulated iterators. As such, the interface is compatible with
|
||||
the <link linkend="string_algo.collection_traits">collection traits</link> requirements so
|
||||
it is possible to use this class as a parameter to many algorithms in this library.
|
||||
</para>
|
||||
<para>
|
||||
<classname>iterator_range</classname> will be moved to Boost.Range library in the future
|
||||
releases. The internal version will be deprecated then.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id="string_algo.collection_traits">
|
||||
<title>Collection Traits</title>
|
||||
|
||||
<para>
|
||||
Collection traits provide uniform access to different types of
|
||||
<ulink url="../../libs/utility/Collection.html">collections</ulink> .
|
||||
This functionality allows to write generic algorithms which work with several
|
||||
different kinds of collections. For this library it means, that, for instance,
|
||||
many algorithms work with <code>std::string</code> as well as with <code>char[]</code>.
|
||||
This facility implements the
|
||||
<ulink url="../../libs/algorithm/string/doc/external_concepts.html">external</ulink> collection
|
||||
concept.
|
||||
</para>
|
||||
<para>
|
||||
The following collection types are supported:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
Standard containers
|
||||
</listitem>
|
||||
<listitem>
|
||||
Built-in arrays (like int[])
|
||||
</listitem>
|
||||
<listitem>
|
||||
Null terminated strings (this includes char[],wchar_t[],char*, and wchar_t*)
|
||||
</listitem>
|
||||
<listitem>
|
||||
std::pair<iterator,iterator>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
Collection traits support a subset of the container concept (Std §23.1). This subset
|
||||
can be described as an input container concept, e.g. a container with immutable content.
|
||||
Its definition can be found in the header <headername>boost/algorithm/string/collection_traits.hpp</headername>.
|
||||
</para>
|
||||
<para>
|
||||
In the table C denotes a container and c is an object of C.
|
||||
</para>
|
||||
<table>
|
||||
<title>Collection Traits</title>
|
||||
<tgroup cols="3" align="left">
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Name</entry>
|
||||
<entry>Standard collection equivalent</entry>
|
||||
<entry>Description</entry>
|
||||
</row>Maeterlinck
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry><classname>value_type_of<C></classname>::type</entry>
|
||||
<entry><code>C::value_type</code></entry>
|
||||
<entry>Type of contained values</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><classname>difference_type_of<C></classname>::type</entry>
|
||||
<entry><code>C::difference_type</code></entry>
|
||||
<entry>difference type of the collection</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><classname>iterator_of<C></classname>::type</entry>
|
||||
<entry><code>C::iterator</code></entry>
|
||||
<entry>iterator type of the collection</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><classname>const_iterator_of<C></classname>::type</entry>
|
||||
<entry><code>C::const_iterator</code></entry>
|
||||
<entry>const_iterator type of the collection</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><classname>result_iterator_of<C></classname>::type</entry>
|
||||
<entry></entry>
|
||||
<entry>
|
||||
result_iterator type of the collection. This type maps to <code>C::iterator</code>
|
||||
for mutable collection and <code>C::const_iterator</code> for const collection.
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><functionname>begin(c)</functionname></entry>
|
||||
<entry><code>c.begin()</code></entry>
|
||||
<entry>
|
||||
Gets the iterator pointing to the start of the collection.
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><functionname>end(c)</functionname></entry>
|
||||
<entry><code>c.end()</code></entry>
|
||||
<entry>
|
||||
Gets the iterator pointing to the end of the collection.
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><functionname>size(c)</functionname></entry>
|
||||
<entry><code>c.size()</code></entry>
|
||||
<entry>
|
||||
Gets the size of the collection.
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><functionname>empty(c)</functionname></entry>
|
||||
<entry><code>c.empty()</code></entry>
|
||||
<entry>
|
||||
Checks if the collection is empty.
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
|
||||
<para>
|
||||
The collection traits are only a temporary part of this library. They will be replaced in the future
|
||||
releases by Boost.Range library. Use of the internal implementation will be deprecated then.
|
||||
</para>
|
||||
|
||||
</section>
|
||||
<section id="string_algo.sequence_traits">
|
||||
<title>Sequence Traits</title>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title> Concepts and External Concepts </title><meta http-equiv="Content-Type"content="text/html; charset=iso-8859-1"></head> <body><table ><tr ><td ><img src="cboost.gif" width="100%" border="0"></td><td ><h1 >Concepts and External Concepts</h1></td></tr></table><p >Generic programming in C++ is characterized by the use of function and class templates where
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title> Concepts and External Concepts </title><meta http-equiv="Content-Type"content="text/html; charset=iso-8859-1"></head> <body><table ><tr ><td ><img src="../../../../boost.png" width="100%" border="0"></td><td ><h1 >Concepts and External Concepts</h1></td></tr></table><p >Generic programming in C++ is characterized by the use of function and class templates where
|
||||
the template parameter(s) must satisfy certain requirements.Often these
|
||||
requirements are so important that we give them a name: we call
|
||||
such a set of type requirements a <b>concept</b>. We say that a type <i>
|
||||
|
17
string/doc/release_notes.xml
Normal file
17
string/doc/release_notes.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
|
||||
"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
|
||||
<section id="string_algo.release_notes" last-revision="$Date$">
|
||||
<title>Release Notes</title>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">1.32</emphasis></para>
|
||||
<para>Initial release in Boost</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">1.33</emphasis></para>
|
||||
<para>Internal version of collection traits removed, library adapted to Boost.Range</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
@ -33,6 +33,7 @@
|
||||
|
||||
<title>Boost String Algorithms Library</title>
|
||||
<xi:include href="intro.xml"/>
|
||||
<xi:include href="release_notes.xml"/>
|
||||
<xi:include href="usage.xml"/>
|
||||
<xi:include href="quickref.xml"/>
|
||||
<xi:include href="design.xml"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
Using the algorithms is straightforward. Let us have a look at the first example:
|
||||
</para>
|
||||
<programlisting>
|
||||
#include <boost/string_algo.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
using namespace std;
|
||||
using namespace boost;
|
||||
|
||||
@ -46,10 +46,10 @@
|
||||
<code>to_lower(str1)</code>, than <code>to_lower(str1.begin(), str1.end())</code>.
|
||||
</para>
|
||||
<para>
|
||||
The magic of <link linkend="string_algo.collection_traits">collection_traits</link>
|
||||
The magic of <ulink url="../../libs/range/index.html">Boost.Range</ulink>
|
||||
provides a uniform way of handling different string types.
|
||||
If there is a need to pass a pair of iterators,
|
||||
<link linkend="string_algo.iterator_range"><code>iterator_range</code></link>
|
||||
<ulink url="../../libs/range/doc/utility_class.html"><code>boost::iterator_range</code></ulink>
|
||||
can be used to package iterators into a structure with a compatible interface.
|
||||
</para>
|
||||
</listitem>
|
||||
@ -200,16 +200,16 @@
|
||||
</programlisting>
|
||||
<para>
|
||||
We have used <functionname>find_last()</functionname> to search the <code>text</code> for "ll".
|
||||
The result is given in the <link linkend="string_algo.iterator_range"><code>iterator_range</code></link>.
|
||||
The result is given in the <ulink url="../../libs/range/doc/utility_class.html"><code>boost::iterator_range</code></ulink>.
|
||||
This range delimits the
|
||||
part of the input which satisfies the find criteria. In our example it is the last occurrence of "ll".
|
||||
|
||||
As we can see, input of the <functionname>find_last()</functionname> algorithm can be also
|
||||
char[] because this type is supported by
|
||||
<link linkend="string_algo.collection_traits">collection_traits</link>.
|
||||
<ulink linkend="../../libs/range/doc/index.html">Boost.Range</ulink>.
|
||||
|
||||
The following lines transform the result. Notice that
|
||||
<link linkend="string_algo.iterator_range"><code>iterator_range</code></link> has familiar
|
||||
<ulink url="../../libs/range/doc/utility_class.html"><code>boost::iterator_range</code></ulink> has familiar
|
||||
<code>begin()</code> and <code>end()</code> methods, so it can be used like any other STL container.
|
||||
Also it is convertible to bool therefore it is easy to use find algorithms for a simple containment checking.
|
||||
</para>
|
||||
@ -256,7 +256,7 @@
|
||||
the find iterator allows us to iterate over the substrings matching the specified criteria.
|
||||
This facility is using the <link linkend="string_algo.finder_concept">Finder</link> to incrementally
|
||||
search the string.
|
||||
Dereferencing a find iterator yields an <link linkend="string_algo.iterator_range"><code>iterator_range</code></link>
|
||||
Dereferencing a find iterator yields an <ulink url="../../libs/range/doc/utility_class.html"><code>boost::iterator_range</code></ulink>
|
||||
object, that delimits the current match.
|
||||
</para>
|
||||
<para>
|
||||
@ -274,7 +274,7 @@
|
||||
It!=string_find_iterator();
|
||||
++It)
|
||||
{
|
||||
cout << copy_iterator_range<std::string>(*It) << endl;
|
||||
cout << copy_range<std::string>(*It) << endl;
|
||||
}
|
||||
|
||||
// Output will be:
|
||||
@ -288,7 +288,7 @@
|
||||
It!=string_find_iterator();
|
||||
++It)
|
||||
{
|
||||
cout << copy_iterator_range<std::string>(*It) << endl;
|
||||
cout << copy_range<std::string>(*It) << endl;
|
||||
}
|
||||
|
||||
// Output will be:
|
||||
@ -300,7 +300,7 @@
|
||||
Note that the find iterators have only one template parameter. It is the base iterator type.
|
||||
The Finder is specified at runtime. This allows us to typedef a find iterator for
|
||||
common string types and reuse it. Additionally make_*_iterator functions help
|
||||
to construct a find iterator for a particular collection.
|
||||
to construct a find iterator for a particular range.
|
||||
</para>
|
||||
<para>
|
||||
See the reference in <headername>boost/algorithm/string/find_iterator.hpp</headername>.
|
||||
@ -331,7 +331,7 @@
|
||||
typedef vector< string > split_vector_type;
|
||||
|
||||
split_vector_type SplitVec; // #2: Search for tokens
|
||||
split( SplitVec, str1, is_any_of<char>("-*") ); // SplitVec == { "hello abc","ABC","aBc goodbye" }
|
||||
split( SplitVec, str1, is_any_of("-*") ); // SplitVec == { "hello abc","ABC","aBc goodbye" }
|
||||
</programlisting>
|
||||
<para>
|
||||
<code>[hello]</code> designates an <code>iterator_range</code> delimiting this substring.
|
||||
|
@ -10,9 +10,10 @@
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/algorithm/string/erase.hpp>
|
||||
#include <boost/algorithm/string/case_conv.hpp>
|
||||
//#include <boost/algorithm/string/replace.hpp>
|
||||
//#include <boost/algorithm/string/erase.hpp>
|
||||
//#include <boost/algorithm/string/case_conv.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
//Following two includes contain second-layer function.
|
||||
//They are already included by first-layer header
|
||||
|
@ -24,7 +24,7 @@ using namespace std;
|
||||
using namespace boost;
|
||||
|
||||
// replace mark specification, specialize for a specific element type
|
||||
template< typename T > T repeat_mark() { return std::numeric_limits<T>::max(); };
|
||||
template< typename T > T repeat_mark() { return (std::numeric_limits<T>::max)(); };
|
||||
|
||||
// Compression -----------------------------------------------------------------------
|
||||
|
||||
@ -59,7 +59,7 @@ struct find_compressF
|
||||
{
|
||||
input_iterator_type It2=It++;
|
||||
|
||||
if ( It==End || Cnt>=std::numeric_limits<value_type>::max() )
|
||||
if ( It==End || Cnt>=(std::numeric_limits<value_type>::max)() )
|
||||
{
|
||||
return result_type( MStart, It );
|
||||
}
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <functional>
|
||||
#include <boost/algorithm/string/iterator_range.hpp>
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/algorithm/string/find_iterator.hpp>
|
||||
@ -36,7 +35,7 @@ int main()
|
||||
It!=string_find_iterator();
|
||||
++It)
|
||||
{
|
||||
cout << copy_iterator_range<std::string>(*It) << endl;
|
||||
cout << copy_range<std::string>(*It) << endl;
|
||||
// shift all chars in the match by one
|
||||
transform(
|
||||
It->begin(), It->end(),
|
||||
|
@ -17,15 +17,7 @@ DEPENDS all : test ;
|
||||
|
||||
{
|
||||
test-suite algorithm/string
|
||||
: [ run
|
||||
container_test.cpp
|
||||
: :
|
||||
:
|
||||
std::locale-support
|
||||
std::facet-support
|
||||
: container
|
||||
]
|
||||
[ run
|
||||
: [ run
|
||||
trim_test.cpp
|
||||
: :
|
||||
:
|
||||
|
@ -10,13 +10,7 @@
|
||||
import testing ;
|
||||
|
||||
test-suite algorithm/string
|
||||
: [ run
|
||||
container_test.cpp
|
||||
: :
|
||||
:
|
||||
: container
|
||||
]
|
||||
[ run
|
||||
: [ run
|
||||
trim_test.cpp
|
||||
: :
|
||||
:
|
||||
|
@ -1,127 +0,0 @@
|
||||
// Boost string_algo library substr_test.cpp file ------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <boost/algorithm/string/collection_traits.hpp>
|
||||
// equals predicate is used for result comparison
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
|
||||
// Include unit test framework
|
||||
#include <boost/test/included/test_exec_monitor.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/type_traits.hpp>
|
||||
|
||||
// test tools
|
||||
#include <boost/test/test_tools.hpp>
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace boost;
|
||||
|
||||
namespace algo = ::boost::algorithm;
|
||||
|
||||
template< typename T >
|
||||
void argument_cv_test( const T& C, const string& strResult )
|
||||
{
|
||||
BOOST_CHECK( equals( make_iterator_range(algo::begin(C),algo::end(C)), strResult ) );
|
||||
BOOST_CHECK( algo::size(C)==strResult.size() );
|
||||
BOOST_CHECK( algo::empty(C)==strResult.empty() );
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
void argument_test( T& C, const string& strResult )
|
||||
{
|
||||
BOOST_CHECK( equals( make_iterator_range(algo::begin(C),algo::end(C)), strResult ) );
|
||||
BOOST_CHECK( algo::size(C)==strResult.size() );
|
||||
BOOST_CHECK( algo::empty(C)==strResult.empty() );
|
||||
}
|
||||
|
||||
void container_test()
|
||||
{
|
||||
BOOST_CHECKPOINT( "type test" );
|
||||
|
||||
// types test
|
||||
BOOST_REQUIRE( (is_same<
|
||||
algo::result_iterator_of<string>::type,
|
||||
string::iterator>::value) );
|
||||
BOOST_REQUIRE( (is_same<
|
||||
algo::result_iterator_of<const string>::type,
|
||||
string::const_iterator>::value) );
|
||||
BOOST_REQUIRE( (is_same<
|
||||
algo::result_iterator_of<char[4]>::type, char*>::value) );
|
||||
BOOST_REQUIRE( (is_same<
|
||||
algo::result_iterator_of<const char[4]>::type,
|
||||
const char*>::value) );
|
||||
BOOST_REQUIRE( (is_same<
|
||||
algo::result_iterator_of<char*>::type, char*>::value) );
|
||||
BOOST_REQUIRE( (is_same<
|
||||
algo::result_iterator_of<const char*>::type,
|
||||
const char*>::value) );
|
||||
BOOST_REQUIRE( (is_same<
|
||||
algo::result_iterator_of<
|
||||
pair<string::iterator, string::iterator> >::type, string::iterator>::value) );
|
||||
BOOST_REQUIRE( (is_same<
|
||||
algo::result_iterator_of<
|
||||
const pair<string::iterator, string::iterator> >::type,
|
||||
string::iterator>::value) );
|
||||
|
||||
BOOST_CHECKPOINT( "non-empty sequence test" );
|
||||
|
||||
string str1("abc");
|
||||
vector<char> vec1( str1.begin(), str1.end() );
|
||||
pair<string::iterator, string::iterator> pair1=
|
||||
make_pair( str1.begin(), str1.end() );
|
||||
char ach1[]="abc";
|
||||
char *pch1="abc";
|
||||
|
||||
// begin/end tests
|
||||
argument_cv_test( str1, "abc" );
|
||||
argument_test( str1, "abc" );
|
||||
argument_cv_test( vec1, "abc" );
|
||||
argument_test( vec1, "abc" );
|
||||
argument_cv_test( pair1, "abc" );
|
||||
argument_test( pair1, "abc" );
|
||||
argument_cv_test( ach1, "abc" );
|
||||
argument_test( ach1, "abc" );
|
||||
argument_cv_test( pch1, "abc" );
|
||||
argument_test( pch1, "abc" );
|
||||
|
||||
BOOST_CHECKPOINT( "empty sequence test" );
|
||||
|
||||
string str2;
|
||||
vector<char> vec2( str2.begin(), str2.end() );
|
||||
pair<string::iterator, string::iterator> pair2=
|
||||
make_pair( str2.begin(), str2.end() );
|
||||
char ach2[]="";
|
||||
char *pch2=0;
|
||||
|
||||
// begin/end tests
|
||||
argument_cv_test( str2, "" );
|
||||
argument_test( str2, "" );
|
||||
argument_cv_test( vec2, "" );
|
||||
argument_test( vec2, "" );
|
||||
argument_cv_test( pair2, "" );
|
||||
argument_test( pair2, "" );
|
||||
argument_cv_test( ach2, "" );
|
||||
argument_test( ach2, "" );
|
||||
argument_cv_test( pch2, "" );
|
||||
argument_test( pch2, "" );
|
||||
};
|
||||
|
||||
|
||||
// test main
|
||||
int test_main( int, char*[] )
|
||||
{
|
||||
container_test();
|
||||
|
||||
return 0;
|
||||
}
|
@ -82,8 +82,8 @@ void conv_test()
|
||||
to_upper( str3 );
|
||||
BOOST_CHECK( str3=="" );
|
||||
|
||||
free(pch1);
|
||||
free(pch2);
|
||||
delete[] pch1;
|
||||
delete[] pch2;
|
||||
}
|
||||
|
||||
// test main
|
||||
|
@ -28,7 +28,7 @@ void find_test()
|
||||
string str1("123abcxXxabcXxXabc321");
|
||||
string str2("abc");
|
||||
string str3("");
|
||||
char* pch1="123abcxxxabcXXXabc321";
|
||||
const char* pch1="123abcxxxabcXXXabc321";
|
||||
vector<int> vec1( str1.begin(), str1.end() );
|
||||
|
||||
// find results ------------------------------------------------------------//
|
||||
@ -48,18 +48,18 @@ void find_test()
|
||||
|
||||
nc_result=find_first( str1, string("abc") );
|
||||
BOOST_CHECK(
|
||||
(distance<string::const_iterator>( str1.begin(),nc_result.begin()) == 3) &&
|
||||
(distance<string::const_iterator>( str1.begin(),nc_result.end()) == 6) );
|
||||
( (nc_result.begin()-str1.begin()) == 3) &&
|
||||
( (nc_result.end()-str1.begin()) == 6) );
|
||||
|
||||
cv_result=find_first( const_cast<const string&>(str1), str2 );
|
||||
BOOST_CHECK(
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.begin()) == 3) &&
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.end()) == 6) );
|
||||
( (cv_result.begin()-str1.begin()) == 3) &&
|
||||
( (cv_result.end()-str1.begin()) == 6) );
|
||||
|
||||
cv_result=ifind_first( const_cast<const string&>(str1), "xXX" );
|
||||
BOOST_CHECK(
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.begin()) == 6) &&
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.end()) == 9) );
|
||||
( (cv_result.begin()-str1.begin()) == 6) &&
|
||||
( (cv_result.end()-str1.begin()) == 9) );
|
||||
|
||||
ch_result=find_first( pch1, "abc" );
|
||||
BOOST_CHECK(( (ch_result.begin() - pch1 ) == 3) && ( (ch_result.end() - pch1 ) == 6 ) );
|
||||
@ -69,18 +69,18 @@ void find_test()
|
||||
|
||||
nc_result=find_last( str1, string("abc") );
|
||||
BOOST_CHECK(
|
||||
(distance<string::const_iterator>( str1.begin(),nc_result.begin()) == 15) &&
|
||||
(distance<string::const_iterator>( str1.begin(),nc_result.end()) == 18) );
|
||||
( (nc_result.begin()-str1.begin()) == 15) &&
|
||||
( (nc_result.end()-str1.begin()) == 18) );
|
||||
|
||||
cv_result=find_last( const_cast<const string&>(str1), str2 );
|
||||
BOOST_CHECK(
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.begin()) == 15) &&
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.end()) == 18) );
|
||||
( (cv_result.begin()-str1.begin()) == 15) &&
|
||||
( (cv_result.end()-str1.begin()) == 18) );
|
||||
|
||||
cv_result=ifind_last( const_cast<const string&>(str1), "XXx" );
|
||||
BOOST_CHECK(
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.begin()) == 12) &&
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.end()) == 15) );
|
||||
( (cv_result.begin()-str1.begin()) == 12) &&
|
||||
( (cv_result.end()-str1.begin()) == 15) );
|
||||
|
||||
ch_result=find_last( pch1, "abc" );
|
||||
BOOST_CHECK(( (ch_result.begin() - pch1 ) == 15) && ( (ch_result.end() - pch1 ) == 18 ) );
|
||||
@ -90,18 +90,18 @@ void find_test()
|
||||
|
||||
nc_result=find_nth( str1, string("abc"), 1 );
|
||||
BOOST_CHECK(
|
||||
(distance<string::const_iterator>( str1.begin(),nc_result.begin()) == 9) &&
|
||||
(distance<string::const_iterator>( str1.begin(),nc_result.end()) == 12) );
|
||||
( (nc_result.begin()-str1.begin()) == 9) &&
|
||||
( (nc_result.end()-str1.begin()) == 12) );
|
||||
|
||||
cv_result=find_nth( const_cast<const string&>(str1), str2, 1 );
|
||||
BOOST_CHECK(
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.begin()) == 9) &&
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.end()) == 12) );
|
||||
( (cv_result.begin()-str1.begin()) == 9) &&
|
||||
( (cv_result.end()-str1.begin()) == 12) );
|
||||
|
||||
cv_result=ifind_nth( const_cast<const string&>(str1), "xxx", 1 );
|
||||
BOOST_CHECK(
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.begin()) == 12) &&
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.end()) == 15) );
|
||||
( (cv_result.begin()-str1.begin()) == 12) &&
|
||||
( (cv_result.end()-str1.begin()) == 15) );
|
||||
|
||||
ch_result=find_nth( pch1, "abc", 1 );
|
||||
BOOST_CHECK(( (ch_result.begin() - pch1 ) == 9) && ( (ch_result.end() - pch1 ) == 12 ) );
|
||||
@ -111,13 +111,13 @@ void find_test()
|
||||
|
||||
nc_result=find_head( str1, 6 );
|
||||
BOOST_CHECK(
|
||||
(distance<string::const_iterator>( str1.begin(),nc_result.begin()) == 0) &&
|
||||
(distance<string::const_iterator>( str1.begin(),nc_result.end()) == 6) );
|
||||
( (nc_result.begin()-str1.begin()) == 0) &&
|
||||
( (nc_result.end()-str1.begin()) == 6) );
|
||||
|
||||
cv_result=find_head( const_cast<const string&>(str1), 6 );
|
||||
BOOST_CHECK(
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.begin()) == 0) &&
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.end()) == 6) );
|
||||
( (cv_result.begin()-str1.begin()) == 0) &&
|
||||
( (cv_result.end()-str1.begin()) == 6) );
|
||||
|
||||
ch_result=find_head( pch1, 6 );
|
||||
BOOST_CHECK( ( (ch_result.begin() - pch1 ) == 0 ) && ( (ch_result.end() - pch1 ) == 6 ) );
|
||||
@ -127,13 +127,13 @@ void find_test()
|
||||
|
||||
nc_result=find_tail( str1, 6 );
|
||||
BOOST_CHECK(
|
||||
(distance<string::const_iterator>( str1.begin(),nc_result.begin()) == 15) &&
|
||||
(distance<string::const_iterator>( str1.begin(),nc_result.end()) == 21) );
|
||||
( (nc_result.begin()-str1.begin()) == 15) &&
|
||||
( (nc_result.end()-str1.begin()) == 21) );
|
||||
|
||||
cv_result=find_tail( const_cast<const string&>(str1), 6 );
|
||||
BOOST_CHECK(
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.begin()) == 15) &&
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.end()) == 21) );
|
||||
( (cv_result.begin()-str1.begin()) == 15) &&
|
||||
( (cv_result.end()-str1.begin()) == 21) );
|
||||
|
||||
ch_result=find_tail( pch1, 6 );
|
||||
BOOST_CHECK( ( (ch_result.begin() - pch1 ) == 15 ) && ( (ch_result.end() - pch1 ) == 21 ) );
|
||||
@ -143,23 +143,23 @@ void find_test()
|
||||
|
||||
nc_result=find_token( str1, is_any_of("abc"), token_compress_on );
|
||||
BOOST_CHECK(
|
||||
(distance<string::const_iterator>( str1.begin(),nc_result.begin()) == 3) &&
|
||||
(distance<string::const_iterator>( str1.begin(),nc_result.end()) == 6) );
|
||||
( (nc_result.begin()-str1.begin()) == 3) &&
|
||||
( (nc_result.end()-str1.begin()) == 6) );
|
||||
|
||||
cv_result=find_token( const_cast<const string&>(str1), is_any_of("abc"), token_compress_on );
|
||||
BOOST_CHECK(
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.begin()) == 3) &&
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.end()) == 6) );
|
||||
( (cv_result.begin()-str1.begin()) == 3) &&
|
||||
( (cv_result.end()-str1.begin()) == 6) );
|
||||
|
||||
nc_result=find_token( str1, is_any_of("abc"), token_compress_off );
|
||||
BOOST_CHECK(
|
||||
(distance<string::const_iterator>( str1.begin(),nc_result.begin()) == 3) &&
|
||||
(distance<string::const_iterator>( str1.begin(),nc_result.end()) == 4) );
|
||||
( (nc_result.begin()-str1.begin()) == 3) &&
|
||||
( (nc_result.end()-str1.begin()) == 4) );
|
||||
|
||||
cv_result=find_token( const_cast<const string&>(str1), is_any_of("abc"), token_compress_off );
|
||||
BOOST_CHECK(
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.begin()) == 3) &&
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.end()) == 4) );
|
||||
( (cv_result.begin()-str1.begin()) == 3) &&
|
||||
( (cv_result.end()-str1.begin()) == 4) );
|
||||
|
||||
ch_result=find_token( pch1, is_any_of("abc"), token_compress_off );
|
||||
BOOST_CHECK( ( (ch_result.begin() - pch1 ) == 3 ) && ( (ch_result.end() - pch1 ) == 4 ) );
|
||||
@ -169,26 +169,26 @@ void find_test()
|
||||
|
||||
nc_result=find(str1, first_finder(string("abc")));
|
||||
BOOST_CHECK(
|
||||
(distance<string::const_iterator>( str1.begin(),nc_result.begin()) == 3) &&
|
||||
(distance<string::const_iterator>( str1.begin(),nc_result.end()) == 6) );
|
||||
( (nc_result.begin()-str1.begin()) == 3) &&
|
||||
( (nc_result.end()-str1.begin()) == 6) );
|
||||
|
||||
cv_result=find(const_cast<const string&>(str1), first_finder(str2) );
|
||||
BOOST_CHECK(
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.begin()) == 3) &&
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.end()) == 6) );
|
||||
( (cv_result.begin()-str1.begin()) == 3) &&
|
||||
( (cv_result.end()-str1.begin()) == 6) );
|
||||
|
||||
// multi-type comparison test
|
||||
BOOST_CHECKPOINT( "multi-type" );
|
||||
|
||||
nc_vresult=find_first( vec1, string("abc") );
|
||||
BOOST_CHECK(
|
||||
(distance<vector<int>::const_iterator>( vec1.begin(),nc_vresult.begin()) == 3) &&
|
||||
(distance<vector<int>::const_iterator>( vec1.begin(),nc_vresult.end()) == 6) );
|
||||
( (nc_result.begin()-str1.begin()) == 3) &&
|
||||
( (nc_result.end()-str1.begin()) == 6) );
|
||||
|
||||
cv_vresult=find_first( const_cast<const vector<int>&>(vec1), str2 );
|
||||
BOOST_CHECK(
|
||||
(distance<vector<int>::const_iterator>( vec1.begin(),cv_vresult.begin()) == 3) &&
|
||||
(distance<vector<int>::const_iterator>( vec1.begin(),cv_vresult.end()) == 6) );
|
||||
( (cv_result.begin()-str1.begin()) == 3) &&
|
||||
( (cv_result.end()-str1.begin()) == 6) );
|
||||
|
||||
// overflow test
|
||||
BOOST_CHECKPOINT( "overflow" );
|
||||
|
@ -25,7 +25,7 @@ using namespace boost;
|
||||
static void find_test()
|
||||
{
|
||||
string str1("123a1cxxxa23cXXXa456c321");
|
||||
char* pch1="123a1cxxxa23cXXXa456c321";
|
||||
const char* pch1="123a1cxxxa23cXXXa456c321";
|
||||
regex rx("a[0-9]+c");
|
||||
vector<int> vec1( str1.begin(), str1.end() );
|
||||
vector<string> tokens;
|
||||
@ -42,13 +42,13 @@ static void find_test()
|
||||
// basic tests
|
||||
nc_result=find_regex( str1, rx );
|
||||
BOOST_CHECK(
|
||||
(distance<string::const_iterator>( str1.begin(),nc_result.begin()) == 3) &&
|
||||
(distance<string::const_iterator>( str1.begin(),nc_result.end()) == 6) );
|
||||
( (nc_result.begin()-str1.begin()) == 3) &&
|
||||
( (nc_result.end()-str1.begin()) == 6) );
|
||||
|
||||
cv_result=find_regex( str1, rx );
|
||||
BOOST_CHECK(
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.begin()) == 3) &&
|
||||
(distance<string::const_iterator>( str1.begin(),cv_result.end()) == 6) );
|
||||
( (cv_result.begin()-str1.begin()) == 3) &&
|
||||
( (cv_result.end()-str1.begin()) == 6) );
|
||||
|
||||
ch_result=find_regex( pch1, rx );
|
||||
BOOST_CHECK(( (ch_result.begin() - pch1 ) == 3) && ( (ch_result.end() - pch1 ) == 6 ) );
|
||||
@ -56,13 +56,13 @@ static void find_test()
|
||||
// multi-type comparison test
|
||||
nc_vresult=find_regex( vec1, rx );
|
||||
BOOST_CHECK(
|
||||
(distance<vector<int>::const_iterator>( vec1.begin(),nc_vresult.begin()) == 3) &&
|
||||
(distance<vector<int>::const_iterator>( vec1.begin(),nc_vresult.end()) == 6) );
|
||||
( (nc_result.begin()-str1.begin()) == 3) &&
|
||||
( (nc_result.end()-str1.begin()) == 6) );
|
||||
|
||||
cv_vresult=find_regex( vec1, rx );
|
||||
BOOST_CHECK(
|
||||
(distance<vector<int>::const_iterator>( vec1.begin(),cv_vresult.begin()) == 3) &&
|
||||
(distance<vector<int>::const_iterator>( vec1.begin(),cv_vresult.end()) == 6) );
|
||||
( (cv_result.begin()-str1.begin()) == 3) &&
|
||||
( (cv_result.end()-str1.begin()) == 6) );
|
||||
|
||||
// find_all_regex test
|
||||
find_all_regex( tokens, str1, rx );
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/preprocessor/seq/enum.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace boost;
|
||||
@ -51,6 +50,7 @@ void sequence_traits_test()
|
||||
}
|
||||
|
||||
// Combine tests for all variants of the algorithm
|
||||
#define C_ ,
|
||||
#define TEST_ALGO( Algo, Input, Params, Output ) \
|
||||
{\
|
||||
BOOST_CHECKPOINT( #Algo " - Copy" );\
|
||||
@ -58,12 +58,12 @@ void sequence_traits_test()
|
||||
string str1(Input);\
|
||||
\
|
||||
/* Copy test */ \
|
||||
BOOST_CHECK( Algo##_copy( str1, BOOST_PP_SEQ_ENUM( Params ) )==Output );\
|
||||
BOOST_CHECK( Algo##_copy( str1, Params )==Output );\
|
||||
\
|
||||
BOOST_CHECKPOINT( #Algo " - Iterator" );\
|
||||
/* Iterator test */\
|
||||
string strout;\
|
||||
Algo##_copy( back_inserter(strout), str1, BOOST_PP_SEQ_ENUM( Params ) );\
|
||||
Algo##_copy( back_inserter(strout), str1, Params );\
|
||||
BOOST_CHECK( strout==Output ); \
|
||||
\
|
||||
/* In-place test */\
|
||||
@ -71,98 +71,116 @@ void sequence_traits_test()
|
||||
list<char> list1( str1.begin(), str1.end() );\
|
||||
\
|
||||
BOOST_CHECKPOINT( #Algo " - Inplace(string)" );\
|
||||
Algo( str1, BOOST_PP_SEQ_ENUM( Params ) ); \
|
||||
Algo( str1, Params ); \
|
||||
BOOST_CHECK( equals( str1, Output ) ); \
|
||||
\
|
||||
BOOST_CHECKPOINT( #Algo " - Inplace(vector)" );\
|
||||
Algo( vec1, BOOST_PP_SEQ_ENUM( Params ) ); \
|
||||
Algo( vec1, Params ); \
|
||||
BOOST_CHECK( equals( vec1, Output ) );\
|
||||
\
|
||||
BOOST_CHECKPOINT( #Algo " - Inplace(list)" );\
|
||||
Algo( list1, BOOST_PP_SEQ_ENUM( Params ) ); \
|
||||
Algo( list1, Params ); \
|
||||
BOOST_CHECK( equals( list1, Output ) );\
|
||||
}
|
||||
|
||||
void replace_test()
|
||||
void replace_first_test()
|
||||
{
|
||||
// replace first
|
||||
TEST_ALGO( replace_first, "1abc3abc2", (string("abc"))(string("YYY")), string("1YYY3abc2") );
|
||||
TEST_ALGO( ireplace_first, "1AbC3abc2", ("aBc")("YYY"), string("1YYY3abc2") );
|
||||
TEST_ALGO( replace_first, "1abc3abc2", (string("abc"))(string("Z")), string("1Z3abc2") );
|
||||
TEST_ALGO( replace_first, "1abc3abc2", (string("abc"))(string("XXXX")), string("1XXXX3abc2") );
|
||||
TEST_ALGO( replace_first, "1abc3abc2", (string(""))(string("XXXX")), string("1abc3abc2") );
|
||||
TEST_ALGO( replace_first, "1abc3abc2", ("")("XXXX"), string("1abc3abc2") );
|
||||
TEST_ALGO( replace_first, "", (string(""))(string("XXXX")), string("") );
|
||||
TEST_ALGO( erase_first, "1abc3abc2", (string("abc")), string("13abc2") );
|
||||
TEST_ALGO( ierase_first, "1aBc3abc2", ("abC"), "13abc2" );
|
||||
TEST_ALGO( erase_first, "1abc3abc2", ("abc"), "13abc2" );
|
||||
TEST_ALGO( erase_first, "1abc3abc2", (string("")), string("1abc3abc2") );
|
||||
TEST_ALGO( erase_first, "", (string("abc")), string("") );
|
||||
TEST_ALGO( replace_first, "1abc3abc2", string("abc") C_ string("YYY"), string("1YYY3abc2") );
|
||||
TEST_ALGO( ireplace_first, "1AbC3abc2", "aBc" C_ "YYY", string("1YYY3abc2") );
|
||||
TEST_ALGO( replace_first, "1abc3abc2", string("abc") C_ string("Z"), string("1Z3abc2") );
|
||||
TEST_ALGO( replace_first, "1abc3abc2", string("abc") C_ string("XXXX"), string("1XXXX3abc2") );
|
||||
TEST_ALGO( replace_first, "1abc3abc2", string("") C_ string("XXXX"), string("1abc3abc2") );
|
||||
TEST_ALGO( replace_first, "1abc3abc2", "" C_ "XXXX", string("1abc3abc2") );
|
||||
TEST_ALGO( replace_first, "", string("") C_ string("XXXX"), string("") );
|
||||
TEST_ALGO( erase_first, "1abc3abc2", string("abc"), string("13abc2") );
|
||||
TEST_ALGO( ierase_first, "1aBc3abc2", "abC", "13abc2" );
|
||||
TEST_ALGO( erase_first, "1abc3abc2", "abc", "13abc2" );
|
||||
TEST_ALGO( erase_first, "1abc3abc2", string(""), string("1abc3abc2") );
|
||||
TEST_ALGO( erase_first, "", string("abc"), string("") );
|
||||
}
|
||||
|
||||
void replace_last_test()
|
||||
{
|
||||
// replace last
|
||||
TEST_ALGO( replace_last, "1abc3abc2", (string("abc"))(string("YYY")), string("1abc3YYY2") );
|
||||
TEST_ALGO( ireplace_last, "1abc3AbC2", ("aBc")("YYY"), string("1abc3YYY2") );
|
||||
TEST_ALGO( replace_last, "1abc3abc2", (string("abc"))(string("Z")), string("1abc3Z2") );
|
||||
TEST_ALGO( replace_last, "1abc3abc2", (string("abc"))(string("XXXX")), string("1abc3XXXX2") );
|
||||
TEST_ALGO( replace_last, "1abc3abc2", ("abc")("XXXX"), string("1abc3XXXX2") );
|
||||
TEST_ALGO( replace_last, "", (string(""))(string("XXXX")), string("") );
|
||||
TEST_ALGO( erase_last, "1abc3abc2", (string("abc")), string("1abc32") );
|
||||
TEST_ALGO( ierase_last, "1aBc3aBc2", ("ABC"), string("1aBc32") );
|
||||
TEST_ALGO( erase_last, "1abc3abc2", ("abc"), string("1abc32") );
|
||||
TEST_ALGO( erase_last, "1abc3abc2", (string("")), string("1abc3abc2") );
|
||||
TEST_ALGO( erase_last, "", (string("abc")), string("") );
|
||||
TEST_ALGO( replace_last, "1abc3abc2", string("abc") C_ string("YYY"), string("1abc3YYY2") );
|
||||
TEST_ALGO( ireplace_last, "1abc3AbC2", "aBc" C_ "YYY", string("1abc3YYY2") );
|
||||
TEST_ALGO( replace_last, "1abc3abc2", string("abc") C_ string("Z"), string("1abc3Z2") );
|
||||
TEST_ALGO( replace_last, "1abc3abc2", string("abc") C_ string("XXXX"), string("1abc3XXXX2") );
|
||||
TEST_ALGO( replace_last, "1abc3abc2", "abc" C_ "XXXX", string("1abc3XXXX2") );
|
||||
TEST_ALGO( replace_last, "", string("") C_ string("XXXX"), string("") );
|
||||
TEST_ALGO( erase_last, "1abc3abc2", string("abc"), string("1abc32") );
|
||||
TEST_ALGO( ierase_last, "1aBc3aBc2", "ABC", string("1aBc32") );
|
||||
TEST_ALGO( erase_last, "1abc3abc2", "abc", string("1abc32") );
|
||||
TEST_ALGO( erase_last, "1abc3abc2", string(""), string("1abc3abc2") );
|
||||
TEST_ALGO( erase_last, "", string("abc"), string("") );
|
||||
}
|
||||
|
||||
void replace_all_test()
|
||||
{
|
||||
// replace all
|
||||
TEST_ALGO( replace_all, "1abc3abc2", (string("abc"))(string("YYY")), string("1YYY3YYY2") );
|
||||
TEST_ALGO( ireplace_all, "1aBc3AbC2", ("abC")("YYY"), string("1YYY3YYY2") );
|
||||
TEST_ALGO( replace_all, "1abc3abc2", (string("abc"))(string("Z")), string("1Z3Z2") );
|
||||
TEST_ALGO( replace_all, "1abc3abc2", (string("abc"))(string("XXXX")), string("1XXXX3XXXX2") );
|
||||
TEST_ALGO( replace_all, "1abc3abc2", ("abc")("XXXX"), string("1XXXX3XXXX2") );
|
||||
TEST_ALGO( replace_all, "", (string(""))(string("XXXX")), string("") );
|
||||
TEST_ALGO( erase_all, "1abc3abc2", (string("abc")), string("132") );
|
||||
TEST_ALGO( ierase_all, "1aBc3aBc2", ("aBC"), string("132") );
|
||||
TEST_ALGO( erase_all, "1abc3abc2", ("abc"), string("132") );
|
||||
TEST_ALGO( erase_all, "1abc3abc2", (string("")), string("1abc3abc2") );
|
||||
TEST_ALGO( erase_all, "", (string("abc")), string("") );
|
||||
TEST_ALGO( replace_all, "1abc3abc2", string("abc") C_ string("YYY"), string("1YYY3YYY2") );
|
||||
TEST_ALGO( ireplace_all, "1aBc3AbC2", "abC" C_ "YYY", string("1YYY3YYY2") );
|
||||
TEST_ALGO( replace_all, "1abc3abc2", string("abc") C_ string("Z"), string("1Z3Z2") );
|
||||
TEST_ALGO( replace_all, "1abc3abc2", string("abc") C_ string("XXXX"), string("1XXXX3XXXX2") );
|
||||
TEST_ALGO( replace_all, "1abc3abc2", "abc" C_ "XXXX", string("1XXXX3XXXX2") );
|
||||
TEST_ALGO( replace_all, "", string("") C_ string("XXXX"), string("") );
|
||||
TEST_ALGO( erase_all, "1abc3abc2", string("abc"), string("132") );
|
||||
TEST_ALGO( ierase_all, "1aBc3aBc2", "aBC", string("132") );
|
||||
TEST_ALGO( erase_all, "1abc3abc2", "abc", string("132") );
|
||||
TEST_ALGO( erase_all, "1abc3abc2", string(""), string("1abc3abc2") );
|
||||
TEST_ALGO( erase_all, "", string("abc"), string("") );
|
||||
}
|
||||
|
||||
void replace_nth_test()
|
||||
{
|
||||
// replace nth
|
||||
TEST_ALGO( replace_nth, "1abc3abc2", (string("abc"))(0)(string("YYY")), string("1YYY3abc2") );
|
||||
TEST_ALGO( ireplace_nth, "1AbC3abc2", ("aBc")(0)("YYY"), string("1YYY3abc2") );
|
||||
TEST_ALGO( replace_nth, "1abc3abc2", (string("abc"))(0)(string("Z")), string("1Z3abc2") );
|
||||
TEST_ALGO( replace_nth, "1abc3abc2", (string("abc"))(0)(string("XXXX")), string("1XXXX3abc2") );
|
||||
TEST_ALGO( replace_nth, "1abc3abc2", ("abc")(0)("XXXX"), string("1XXXX3abc2") );
|
||||
TEST_ALGO( replace_nth, "1abc3abc2", (string(""))(0)(string("XXXX")), string("1abc3abc2") );
|
||||
TEST_ALGO( replace_nth, "", (string(""))(0)(string("XXXX")), string("") );
|
||||
TEST_ALGO( erase_nth, "1abc3abc2", (string("abc"))(0), string("13abc2") );
|
||||
TEST_ALGO( ierase_nth, "1aBc3aBc2", ("ABC")(0), string("13aBc2") );
|
||||
TEST_ALGO( erase_nth, "1abc3abc2", ("abc")(0), string("13abc2") );
|
||||
TEST_ALGO( erase_nth, "1abc3abc2", (string(""))(0), string("1abc3abc2") );
|
||||
TEST_ALGO( erase_nth, "", (string("abc"))(0), string("") );
|
||||
TEST_ALGO( replace_nth, "1abc3abc2", (string("abc"))(1)(string("YYY")), string("1abc3YYY2") );
|
||||
TEST_ALGO( replace_nth, "1abc3abc2", (string("abc"))(2)(string("YYY")), string("1abc3abc2") );
|
||||
TEST_ALGO( replace_nth, "1abc3abc2", string("abc") C_ 0 C_ string("YYY"), string("1YYY3abc2") );
|
||||
TEST_ALGO( ireplace_nth, "1AbC3abc2", "aBc" C_ 0 C_ "YYY", string("1YYY3abc2") );
|
||||
TEST_ALGO( replace_nth, "1abc3abc2", string("abc") C_ 0 C_ string("Z"), string("1Z3abc2") );
|
||||
TEST_ALGO( replace_nth, "1abc3abc2", string("abc") C_ 0 C_ string("XXXX"), string("1XXXX3abc2") );
|
||||
TEST_ALGO( replace_nth, "1abc3abc2", "abc" C_ 0 C_ "XXXX", string("1XXXX3abc2") );
|
||||
TEST_ALGO( replace_nth, "1abc3abc2", string("") C_ 0 C_ string("XXXX"), string("1abc3abc2") );
|
||||
TEST_ALGO( replace_nth, "", string("") C_ 0 C_ string("XXXX"), string("") );
|
||||
TEST_ALGO( erase_nth, "1abc3abc2", string("abc") C_ 0, string("13abc2") );
|
||||
TEST_ALGO( ierase_nth, "1aBc3aBc2", "ABC" C_ 0, string("13aBc2") );
|
||||
TEST_ALGO( erase_nth, "1abc3abc2", "abc" C_ 0, string("13abc2") );
|
||||
TEST_ALGO( erase_nth, "1abc3abc2", string("") C_ 0, string("1abc3abc2") );
|
||||
TEST_ALGO( erase_nth, "", string("abc") C_ 0, string("") );
|
||||
TEST_ALGO( replace_nth, "1abc3abc2", string("abc") C_ 1 C_ string("YYY"), string("1abc3YYY2") );
|
||||
TEST_ALGO( replace_nth, "1abc3abc2", string("abc") C_ 2 C_ string("YYY"), string("1abc3abc2") );
|
||||
}
|
||||
|
||||
void replace_head_test()
|
||||
{
|
||||
// replace head
|
||||
TEST_ALGO( replace_head, "abc3abc2", (3)(string("YYY")), string("YYY3abc2") );
|
||||
TEST_ALGO( replace_head, "abc3abc2", (3)("YYY"), string("YYY3abc2") );
|
||||
TEST_ALGO( replace_head, "abc", (3)(string("Z")), string("Z") );
|
||||
TEST_ALGO( replace_head, "abc", (6)(string("XXXX")), string("XXXX") );
|
||||
TEST_ALGO( replace_head, "abc3abc2", (0)(string("XXXX")), string("abc3abc2") );
|
||||
TEST_ALGO( replace_head, "", (4)(string("XXXX")), string("") );
|
||||
TEST_ALGO( erase_head, "abc3abc2", (3), string("3abc2") );
|
||||
TEST_ALGO( erase_head, "abc3abc2", (0), string("abc3abc2") );
|
||||
TEST_ALGO( erase_head, "", (4), string("") );
|
||||
TEST_ALGO( replace_head, "abc3abc2", 3 C_ string("YYY"), string("YYY3abc2") );
|
||||
TEST_ALGO( replace_head, "abc3abc2", 3 C_ "YYY", string("YYY3abc2") );
|
||||
TEST_ALGO( replace_head, "abc", 3 C_ string("Z"), string("Z") );
|
||||
TEST_ALGO( replace_head, "abc", 6 C_ string("XXXX"), string("XXXX") );
|
||||
TEST_ALGO( replace_head, "abc3abc2", 0 C_ string("XXXX"), string("abc3abc2") );
|
||||
TEST_ALGO( replace_head, "", 4 C_ string("XXXX"), string("") );
|
||||
TEST_ALGO( erase_head, "abc3abc2", 3, string("3abc2") );
|
||||
TEST_ALGO( erase_head, "abc3abc2", 0, string("abc3abc2") );
|
||||
TEST_ALGO( erase_head, "", 4, string("") );
|
||||
}
|
||||
|
||||
void replace_tail_test()
|
||||
{
|
||||
// replace tail
|
||||
TEST_ALGO( replace_tail, "abc3abc", (3)(string("YYY")), string("abc3YYY") );
|
||||
TEST_ALGO( replace_tail, "abc3abc", (3)("YYY"), string("abc3YYY") );
|
||||
TEST_ALGO( replace_tail, "abc", (3)(string("Z")), string("Z") );
|
||||
TEST_ALGO( replace_tail, "abc", (6)(string("XXXX")), string("XXXX") );
|
||||
TEST_ALGO( replace_tail, "abc3abc", (0)(string("XXXX")), string("abc3abc") );
|
||||
TEST_ALGO( replace_tail, "", (4)(string("XXXX")), string("") );
|
||||
TEST_ALGO( erase_tail, "abc3abc", (3), string("abc3") );
|
||||
TEST_ALGO( erase_tail, "abc3abc", (0), string("abc3abc") );
|
||||
TEST_ALGO( erase_tail, "", (4), string("") );
|
||||
TEST_ALGO( replace_tail, "abc3abc", 3 C_ string("YYY"), string("abc3YYY") );
|
||||
TEST_ALGO( replace_tail, "abc3abc", 3 C_ "YYY", string("abc3YYY") );
|
||||
TEST_ALGO( replace_tail, "abc", 3 C_ string("Z"), string("Z") );
|
||||
TEST_ALGO( replace_tail, "abc", 6 C_ string("XXXX"), string("XXXX") );
|
||||
TEST_ALGO( replace_tail, "abc3abc", 0 C_ string("XXXX"), string("abc3abc") );
|
||||
TEST_ALGO( replace_tail, "", 4 C_ string("XXXX"), string("") );
|
||||
TEST_ALGO( erase_tail, "abc3abc", 3, string("abc3") );
|
||||
TEST_ALGO( erase_tail, "abc3abc", 0, string("abc3abc") );
|
||||
TEST_ALGO( erase_tail, "", 4, string("") );
|
||||
}
|
||||
|
||||
void replace_range_test()
|
||||
{
|
||||
// replace_range
|
||||
{
|
||||
BOOST_CHECKPOINT( "replace_range" );
|
||||
@ -210,8 +228,11 @@ void replace_test()
|
||||
make_iterator_range(str1.begin()+1, str1.begin()+4));
|
||||
BOOST_CHECK( str1==string("13abc2") );
|
||||
}
|
||||
}
|
||||
|
||||
// container traits complatibility tests
|
||||
void collection_comp_test()
|
||||
{
|
||||
// container traits compatibility tests
|
||||
{
|
||||
string strout;
|
||||
replace_first_copy( back_inserter(strout), "1abc3abc2", "abc", "YYY" );
|
||||
@ -248,7 +269,14 @@ void replace_test()
|
||||
int test_main( int, char*[] )
|
||||
{
|
||||
sequence_traits_test();
|
||||
replace_test();
|
||||
|
||||
replace_first_test();
|
||||
replace_last_test();
|
||||
replace_all_test();
|
||||
replace_nth_test();
|
||||
replace_head_test();
|
||||
replace_tail_test();
|
||||
replace_range_test();
|
||||
collection_comp_test();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -38,9 +38,9 @@ void deep_compare( const T1& X, const T2& Y )
|
||||
void iterator_test()
|
||||
{
|
||||
string str1("xx-abc--xx-abb");
|
||||
string str2("Xx-abc--xX-abb");
|
||||
string str2("Xx-abc--xX-abb-xx");
|
||||
string str3("xx");
|
||||
char* pch1="xx-abc--xx-abb";
|
||||
const char* pch1="xx-abc--xx-abb";
|
||||
vector<string> tokens;
|
||||
vector< vector<int> > vtokens;
|
||||
|
||||
@ -59,9 +59,10 @@ void iterator_test()
|
||||
str2,
|
||||
"xx" );
|
||||
|
||||
BOOST_REQUIRE( tokens.size()==2 );
|
||||
BOOST_REQUIRE( tokens.size()==3 );
|
||||
BOOST_CHECK( tokens[0]==string("Xx") );
|
||||
BOOST_CHECK( tokens[1]==string("xX") );
|
||||
BOOST_CHECK( tokens[2]==string("xx") );
|
||||
|
||||
find_all(
|
||||
tokens,
|
||||
@ -81,14 +82,15 @@ void iterator_test()
|
||||
// split tests
|
||||
split(
|
||||
tokens,
|
||||
str1,
|
||||
is_any_of("x"),
|
||||
str2,
|
||||
is_any_of("xX"),
|
||||
token_compress_on );
|
||||
|
||||
BOOST_REQUIRE( tokens.size()==3 );
|
||||
BOOST_REQUIRE( tokens.size()==4 );
|
||||
BOOST_CHECK( tokens[0]==string("") );
|
||||
BOOST_CHECK( tokens[1]==string("-abc--") );
|
||||
BOOST_CHECK( tokens[2]==string("-abb") );
|
||||
BOOST_CHECK( tokens[2]==string("-abb-") );
|
||||
BOOST_CHECK( tokens[3]==string("") );
|
||||
|
||||
split(
|
||||
tokens,
|
||||
|
Reference in New Issue
Block a user