mirror of
https://github.com/boostorg/algorithm.git
synced 2025-06-25 20:11:50 +02:00
Compare commits
50 Commits
boost-1.47
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
0abb237962 | |||
235c81be61 | |||
1eb3d83534 | |||
8f2b8d4888 | |||
6c0f953c01 | |||
e439792494 | |||
236b142308 | |||
9bad789175 | |||
d84f81d841 | |||
ce98e8b87e | |||
e8a2596637 | |||
7b2754b937 | |||
784402e5c0 | |||
1188575e7b | |||
bff2a1e112 | |||
6d5e7b5a04 | |||
760af1798b | |||
1f5542b44c | |||
baf3dd99e2 | |||
7299b29bf8 | |||
539c170b9d | |||
c81ee948b7 | |||
ba5e4c30c6 | |||
cd26ed816c | |||
4e15767bed | |||
9fa2f90db4 | |||
35f317aeac | |||
d0a03fdb4e | |||
346f032be2 | |||
a389d768c4 | |||
90fca39906 | |||
5b24f31486 | |||
b25d6511b3 | |||
1541a554f5 | |||
7a97b3390e | |||
6e5a7497ae | |||
f0b8b60379 | |||
66019abb2f | |||
8758222006 | |||
4eef56761a | |||
b94a3fbfba | |||
614cc2ebab | |||
869660ed14 | |||
777f30780e | |||
26aa37733b | |||
f1e60579c2 | |||
389dd3c863 | |||
f23f61ae9b | |||
608112b112 | |||
b21b54dc4e |
@ -31,7 +31,7 @@ namespace boost {
|
||||
struct to_lowerF : public std::unary_function<CharT, CharT>
|
||||
{
|
||||
// Constructor
|
||||
to_lowerF( const std::locale& Loc ) : m_Loc( &Loc ) {}
|
||||
to_lowerF( const std::locale& Loc ) : m_Loc( Loc ) {}
|
||||
|
||||
// Operation
|
||||
CharT operator ()( CharT Ch ) const
|
||||
@ -39,11 +39,11 @@ namespace boost {
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
return std::tolower( Ch);
|
||||
#else
|
||||
return std::tolower<CharT>( Ch, *m_Loc );
|
||||
return std::tolower<CharT>( Ch, m_Loc );
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
const std::locale* m_Loc;
|
||||
const std::locale& m_Loc;
|
||||
};
|
||||
|
||||
// a toupper functor
|
||||
@ -51,7 +51,7 @@ namespace boost {
|
||||
struct to_upperF : public std::unary_function<CharT, CharT>
|
||||
{
|
||||
// Constructor
|
||||
to_upperF( const std::locale& Loc ) : m_Loc( &Loc ) {}
|
||||
to_upperF( const std::locale& Loc ) : m_Loc( Loc ) {}
|
||||
|
||||
// Operation
|
||||
CharT operator ()( CharT Ch ) const
|
||||
@ -59,11 +59,11 @@ namespace boost {
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
return std::toupper( Ch);
|
||||
#else
|
||||
return std::toupper<CharT>( Ch, *m_Loc );
|
||||
return std::toupper<CharT>( Ch, m_Loc );
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
const std::locale* m_Loc;
|
||||
const std::locale& m_Loc;
|
||||
};
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
||||
|
@ -32,8 +32,8 @@ namespace boost {
|
||||
struct is_classifiedF :
|
||||
public predicate_facade<is_classifiedF>
|
||||
{
|
||||
// Boost.ResultOf support
|
||||
typedef bool result_type;
|
||||
// Boost.Lambda support
|
||||
template <class Args> struct sig { typedef bool type; };
|
||||
|
||||
// Constructor from a locale
|
||||
is_classifiedF(std::ctype_base::mask Type, std::locale const & Loc = std::locale()) :
|
||||
@ -72,8 +72,8 @@ namespace boost {
|
||||
typedef typename ::boost::remove_const<CharT>::type set_value_type;
|
||||
|
||||
public:
|
||||
// Boost.ResultOf support
|
||||
typedef bool result_type;
|
||||
// Boost.Lambda support
|
||||
template <class Args> struct sig { typedef bool type; };
|
||||
|
||||
// Constructor
|
||||
template<typename RangeT>
|
||||
@ -253,8 +253,8 @@ namespace boost {
|
||||
struct is_from_rangeF :
|
||||
public predicate_facade< is_from_rangeF<CharT> >
|
||||
{
|
||||
// Boost.ResultOf support
|
||||
typedef bool result_type;
|
||||
// Boost.Lambda support
|
||||
template <class Args> struct sig { typedef bool type; };
|
||||
|
||||
// Constructor
|
||||
is_from_rangeF( CharT From, CharT To ) : m_From(From), m_To(To) {}
|
||||
@ -278,8 +278,8 @@ namespace boost {
|
||||
{
|
||||
public:
|
||||
|
||||
// Boost.ResultOf support
|
||||
typedef bool result_type;
|
||||
// Boost.Lambda support
|
||||
template <class Args> struct sig { typedef bool type; };
|
||||
|
||||
// Constructor
|
||||
pred_andF( Pred1T Pred1, Pred2T Pred2 ) :
|
||||
@ -303,8 +303,8 @@ namespace boost {
|
||||
public predicate_facade< pred_orF<Pred1T,Pred2T> >
|
||||
{
|
||||
public:
|
||||
// Boost.ResultOf support
|
||||
typedef bool result_type;
|
||||
// Boost.Lambda support
|
||||
template <class Args> struct sig { typedef bool type; };
|
||||
|
||||
// Constructor
|
||||
pred_orF( Pred1T Pred1, Pred2T Pred2 ) :
|
||||
@ -328,8 +328,8 @@ namespace boost {
|
||||
public predicate_facade< pred_notF<PredT> >
|
||||
{
|
||||
public:
|
||||
// Boost.ResultOf support
|
||||
typedef bool result_type;
|
||||
// Boost.Lambda support
|
||||
template <class Args> struct sig { typedef bool type; };
|
||||
|
||||
// Constructor
|
||||
pred_notF( PredT Pred ) : m_Pred(Pred) {}
|
||||
|
@ -49,17 +49,17 @@ namespace boost {
|
||||
if ( !M )
|
||||
{
|
||||
// Match not found - return original sequence
|
||||
Output = std::copy( ::boost::begin(Input), ::boost::end(Input), Output );
|
||||
std::copy( ::boost::begin(Input), ::boost::end(Input), Output );
|
||||
return Output;
|
||||
}
|
||||
|
||||
// Copy the beginning of the sequence
|
||||
Output = std::copy( ::boost::begin(Input), ::boost::begin(M), Output );
|
||||
std::copy( ::boost::begin(Input), ::boost::begin(M), Output );
|
||||
// Format find result
|
||||
// Copy formated result
|
||||
Output = std::copy( ::boost::begin(M.format_result()), ::boost::end(M.format_result()), Output );
|
||||
std::copy( ::boost::begin(M.format_result()), ::boost::end(M.format_result()), Output );
|
||||
// Copy the rest of the sequence
|
||||
Output = std::copy( M.end(), ::boost::end(Input), Output );
|
||||
std::copy( M.end(), ::boost::end(Input), Output );
|
||||
|
||||
return Output;
|
||||
}
|
||||
@ -74,17 +74,13 @@ namespace boost {
|
||||
const InputT& Input,
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult )
|
||||
{
|
||||
if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) {
|
||||
return ::boost::algorithm::detail::find_format_copy_impl2(
|
||||
Output,
|
||||
Input,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
} else {
|
||||
return std::copy( ::boost::begin(Input), ::boost::end(Input), Output );
|
||||
}
|
||||
{
|
||||
return ::boost::algorithm::detail::find_format_copy_impl2(
|
||||
Output,
|
||||
Input,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
}
|
||||
|
||||
|
||||
@ -136,15 +132,11 @@ namespace boost {
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult)
|
||||
{
|
||||
if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) {
|
||||
return ::boost::algorithm::detail::find_format_copy_impl2(
|
||||
Input,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
} else {
|
||||
return Input;
|
||||
}
|
||||
return ::boost::algorithm::detail::find_format_copy_impl2(
|
||||
Input,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
}
|
||||
|
||||
// replace implementation ----------------------------------------------------//
|
||||
@ -188,13 +180,11 @@ namespace boost {
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult)
|
||||
{
|
||||
if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) {
|
||||
::boost::algorithm::detail::find_format_impl2(
|
||||
Input,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
}
|
||||
::boost::algorithm::detail::find_format_impl2(
|
||||
Input,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
@ -57,9 +57,9 @@ namespace boost {
|
||||
while( M )
|
||||
{
|
||||
// Copy the beginning of the sequence
|
||||
Output = std::copy( LastMatch, M.begin(), Output );
|
||||
std::copy( LastMatch, M.begin(), Output );
|
||||
// Copy formated result
|
||||
Output = std::copy( ::boost::begin(M.format_result()), ::boost::end(M.format_result()), Output );
|
||||
std::copy( ::boost::begin(M.format_result()), ::boost::end(M.format_result()), Output );
|
||||
|
||||
// Proceed to the next match
|
||||
LastMatch=M.end();
|
||||
@ -67,7 +67,7 @@ namespace boost {
|
||||
}
|
||||
|
||||
// Copy the rest of the sequence
|
||||
Output = std::copy( LastMatch, ::boost::end(Input), Output );
|
||||
std::copy( LastMatch, ::boost::end(Input), Output );
|
||||
|
||||
return Output;
|
||||
}
|
||||
@ -84,18 +84,14 @@ namespace boost {
|
||||
FinderT Finder,
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult )
|
||||
{
|
||||
if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) {
|
||||
return ::boost::algorithm::detail::find_format_all_copy_impl2(
|
||||
Output,
|
||||
Input,
|
||||
Finder,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
} else {
|
||||
return std::copy( ::boost::begin(Input), ::boost::end(Input), Output );
|
||||
}
|
||||
{
|
||||
return ::boost::algorithm::detail::find_format_all_copy_impl2(
|
||||
Output,
|
||||
Input,
|
||||
Finder,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
}
|
||||
|
||||
// find_format_all_copy implementation ----------------------------------------------//
|
||||
@ -160,16 +156,12 @@ namespace boost {
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult)
|
||||
{
|
||||
if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) {
|
||||
return ::boost::algorithm::detail::find_format_all_copy_impl2(
|
||||
Input,
|
||||
Finder,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
} else {
|
||||
return Input;
|
||||
}
|
||||
return ::boost::algorithm::detail::find_format_all_copy_impl2(
|
||||
Input,
|
||||
Finder,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
}
|
||||
|
||||
// find_format_all implementation ------------------------------------------------//
|
||||
@ -256,14 +248,12 @@ namespace boost {
|
||||
FormatterT Formatter,
|
||||
FindResultT FindResult)
|
||||
{
|
||||
if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) {
|
||||
::boost::algorithm::detail::find_format_all_impl2(
|
||||
Input,
|
||||
Finder,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
}
|
||||
::boost::algorithm::detail::find_format_all_impl2(
|
||||
Input,
|
||||
Finder,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
@ -52,9 +52,7 @@ namespace boost {
|
||||
find_format_store& operator=( FindResultT FindResult )
|
||||
{
|
||||
iterator_range<ForwardIteratorT>::operator=(FindResult);
|
||||
if( !this->empty() ) {
|
||||
m_FormatResult=m_Formatter(FindResult);
|
||||
}
|
||||
m_FormatResult=m_Formatter(FindResult);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@ -70,15 +68,6 @@ namespace boost {
|
||||
const formatter_type& m_Formatter;
|
||||
};
|
||||
|
||||
template<typename InputT, typename FindResultT>
|
||||
bool check_find_result(InputT&, FindResultT& FindResult)
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<InputT>::type input_iterator_type;
|
||||
iterator_range<input_iterator_type> ResultRange(FindResult);
|
||||
return !ResultRange.empty();
|
||||
}
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
@ -87,31 +87,6 @@ namespace boost {
|
||||
}
|
||||
};
|
||||
|
||||
// dissect format functor ----------------------------------------------------//
|
||||
|
||||
// dissect format functor
|
||||
template<typename FinderT>
|
||||
struct dissect_formatF
|
||||
{
|
||||
public:
|
||||
// Construction
|
||||
dissect_formatF(FinderT Finder) :
|
||||
m_Finder(Finder) {}
|
||||
|
||||
// Operation
|
||||
template<typename RangeT>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type>
|
||||
operator()(const RangeT& Replace) const
|
||||
{
|
||||
return m_Finder(::boost::begin(Replace), ::boost::end(Replace));
|
||||
}
|
||||
|
||||
private:
|
||||
FinderT m_Finder;
|
||||
};
|
||||
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
@ -752,7 +752,7 @@ namespace boost {
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param N Length of the tail.
|
||||
\param N Length of the head.
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, size(Input)-|N| characters are extracted.
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
@ -797,7 +797,7 @@ namespace boost {
|
||||
considered to be the tail. The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param N Length of the tail
|
||||
\param N Length of the head
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, size(Input)-|N| characters are extracted.
|
||||
*/
|
||||
|
@ -257,7 +257,7 @@ namespace boost {
|
||||
|
||||
//! Find tail algorithm
|
||||
/*!
|
||||
Get the tail of the input. Tail is a suffix of the string of the
|
||||
Get the head of the input. Head is a suffix of the string of the
|
||||
given size. If the input is shorter then required, whole input if considered
|
||||
to be the tail.
|
||||
|
||||
|
@ -240,7 +240,7 @@ namespace boost {
|
||||
m_Match(Other.m_Match),
|
||||
m_Next(Other.m_Next),
|
||||
m_End(Other.m_End),
|
||||
m_bEof(Other.m_bEof)
|
||||
m_bEof(false)
|
||||
{}
|
||||
|
||||
//! Constructor
|
||||
@ -259,11 +259,7 @@ namespace boost {
|
||||
m_End(End),
|
||||
m_bEof(false)
|
||||
{
|
||||
// force the correct behavior for empty sequences and yield at least one token
|
||||
if(Begin!=End)
|
||||
{
|
||||
increment();
|
||||
}
|
||||
increment();
|
||||
}
|
||||
//! Constructor
|
||||
/*!
|
||||
@ -282,11 +278,7 @@ namespace boost {
|
||||
m_Next=::boost::begin(lit_col);
|
||||
m_End=::boost::end(lit_col);
|
||||
|
||||
// force the correct behavior for empty sequences and yield at least one token
|
||||
if(m_Next!=m_End)
|
||||
{
|
||||
increment();
|
||||
}
|
||||
increment();
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,7 +36,7 @@ namespace boost {
|
||||
|
||||
//! Constant formatter
|
||||
/*!
|
||||
Constructs a \c const_formatter. Const formatter always returns
|
||||
Construct the \c const_formatter. Const formatter always returns
|
||||
the same value, regardless of the parameter.
|
||||
|
||||
\param Format A predefined value used as a result for formating
|
||||
@ -55,7 +55,7 @@ namespace boost {
|
||||
|
||||
//! Identity formatter
|
||||
/*!
|
||||
Constructs an \c identity_formatter. Identity formatter always returns
|
||||
Construct the \c identity_formatter. Identity formatter always returns
|
||||
the parameter.
|
||||
|
||||
\return An instance of the \c identity_formatter object.
|
||||
@ -73,7 +73,7 @@ namespace boost {
|
||||
|
||||
//! Empty formatter
|
||||
/*!
|
||||
Constructs an \c empty_formatter. Empty formatter 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
|
||||
@ -89,22 +89,6 @@ namespace boost {
|
||||
BOOST_STRING_TYPENAME range_value<RangeT>::type>();
|
||||
}
|
||||
|
||||
//! Empty formatter
|
||||
/*!
|
||||
Constructs a \c dissect_formatter. Dissect formatter uses a specified finder
|
||||
to extract a portion of the formatted sequence. The first finder's match is returned
|
||||
as a result
|
||||
|
||||
\param Finder a finder used to select a portion of the formated sequence
|
||||
\return An instance of the \c dissect_formatter object.
|
||||
*/
|
||||
template<typename FinderT>
|
||||
inline detail::dissect_formatF< FinderT >
|
||||
dissect_formatter(const FinderT& Finder)
|
||||
{
|
||||
return detail::dissect_formatF<FinderT>(Finder);
|
||||
}
|
||||
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
@ -112,7 +96,6 @@ namespace boost {
|
||||
using algorithm::const_formatter;
|
||||
using algorithm::identity_formatter;
|
||||
using algorithm::empty_formatter;
|
||||
using algorithm::dissect_formatter;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
@ -1,217 +0,0 @@
|
||||
// Boost string_algo library trim.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under 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_TRIM_ALL_HPP
|
||||
#define BOOST_STRING_TRIM_ALL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <boost/algorithm/string/find_format.hpp>
|
||||
#include <boost/algorithm/string/formatter.hpp>
|
||||
#include <boost/algorithm/string/finder.hpp>
|
||||
#include <locale>
|
||||
|
||||
/*! \file
|
||||
Defines trim_all algorithms.
|
||||
|
||||
Just like \c trim, \c trim_all removes all trailing and leading spaces from a
|
||||
sequence (string). In addition, spaces in the middle of the sequence are truncated
|
||||
to just one character. Space is recognized using given locales.
|
||||
|
||||
\c trim_fill acts as trim_all, but the spaces in the middle are replaces with
|
||||
a user-define sequence of character.
|
||||
|
||||
Parametric (\c _if) variants use a predicate (functor) to select which characters
|
||||
are to be trimmed..
|
||||
Functions take a selection predicate as a parameter, which is used to determine
|
||||
whether a character is a space. Common predicates are provided in classification.hpp header.
|
||||
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// multi line trim ----------------------------------------------- //
|
||||
|
||||
//! Trim All - parametric
|
||||
/*!
|
||||
Remove all leading and trailing spaces from the input and
|
||||
compress all other spaces to a single character.
|
||||
The result is a trimmed copy of the input
|
||||
|
||||
\param Input An input sequence
|
||||
\param IsSpace An unary predicate identifying spaces
|
||||
\return A trimmed copy of the input
|
||||
*/
|
||||
template<typename SequenceT, typename PredicateT>
|
||||
inline SequenceT trim_all_copy_if(const SequenceT& Input, PredicateT IsSpace)
|
||||
{
|
||||
return
|
||||
::boost::find_format_all_copy(
|
||||
::boost::trim_copy_if(Input, IsSpace),
|
||||
::boost::token_finder(IsSpace, ::boost::token_compress_on),
|
||||
::boost::dissect_formatter(::boost::head_finder(1)));
|
||||
}
|
||||
|
||||
|
||||
//! Trim All
|
||||
/*!
|
||||
Remove all leading and trailing spaces from the input and
|
||||
compress all other spaces to a single character.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input sequence
|
||||
\param IsSpace An unary predicate identifying spaces
|
||||
*/
|
||||
template<typename SequenceT, typename PredicateT>
|
||||
inline void trim_all_if(SequenceT& Input, PredicateT IsSpace)
|
||||
{
|
||||
::boost::trim_if(Input, IsSpace);
|
||||
::boost::find_format_all(
|
||||
Input,
|
||||
::boost::token_finder(IsSpace, ::boost::token_compress_on),
|
||||
::boost::dissect_formatter(::boost::head_finder(1)));
|
||||
}
|
||||
|
||||
|
||||
//! Trim All
|
||||
/*!
|
||||
Remove all leading and trailing spaces from the input and
|
||||
compress all other spaces to a single character.
|
||||
The result is a trimmed copy of the input
|
||||
|
||||
\param Input An input sequence
|
||||
\param Loc A locale used for 'space' classification
|
||||
\return A trimmed copy of the input
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline SequenceT trim_all_copy(const SequenceT& Input, const std::locale& Loc =std::locale())
|
||||
{
|
||||
return trim_all_copy_if(Input, ::boost::is_space(Loc));
|
||||
}
|
||||
|
||||
|
||||
//! Trim All
|
||||
/*!
|
||||
Remove all leading and trailing spaces from the input and
|
||||
compress all other spaces to a single character.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Loc A locale used for 'space' classification
|
||||
\return A trimmed copy of the input
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline void trim_all(SequenceT& Input, const std::locale& Loc =std::locale())
|
||||
{
|
||||
trim_all_if(Input, ::boost::is_space(Loc));
|
||||
}
|
||||
|
||||
|
||||
//! Trim Fill - parametric
|
||||
/*!
|
||||
Remove all leading and trailing spaces from the input and
|
||||
replace all every block of consecutive spaces with a fill string
|
||||
defined by user.
|
||||
The result is a trimmed copy of the input
|
||||
|
||||
\param Input An input sequence
|
||||
\param Fill A string used to fill the inner spaces
|
||||
\param IsSpace An unary predicate identifying spaces
|
||||
\return A trimmed copy of the input
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT, typename PredicateT>
|
||||
inline SequenceT trim_fill_copy_if(const SequenceT& Input, const RangeT& Fill, PredicateT IsSpace)
|
||||
{
|
||||
return
|
||||
::boost::find_format_all_copy(
|
||||
::boost::trim_copy_if(Input, IsSpace),
|
||||
::boost::token_finder(IsSpace, ::boost::token_compress_on),
|
||||
::boost::const_formatter(::boost::as_literal(Fill)));
|
||||
}
|
||||
|
||||
|
||||
//! Trim Fill
|
||||
/*!
|
||||
Remove all leading and trailing spaces from the input and
|
||||
replace all every block of consecutive spaces with a fill string
|
||||
defined by user.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Fill A string used to fill the inner spaces
|
||||
\param IsSpace An unary predicate identifying spaces
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT, typename PredicateT>
|
||||
inline void trim_fill_if(SequenceT& Input, const RangeT& Fill, PredicateT IsSpace)
|
||||
{
|
||||
::boost::trim_if(Input, IsSpace);
|
||||
::boost::find_format_all(
|
||||
Input,
|
||||
::boost::token_finder(IsSpace, ::boost::token_compress_on),
|
||||
::boost::const_formatter(::boost::as_literal(Fill)));
|
||||
}
|
||||
|
||||
|
||||
//! Trim Fill
|
||||
/*!
|
||||
Remove all leading and trailing spaces from the input and
|
||||
replace all every block of consecutive spaces with a fill string
|
||||
defined by user.
|
||||
The result is a trimmed copy of the input
|
||||
|
||||
\param Input An input sequence
|
||||
\param Fill A string used to fill the inner spaces
|
||||
\param Loc A locale used for 'space' classification
|
||||
\return A trimmed copy of the input
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT trim_fill_copy(const SequenceT& Input, const RangeT& Fill, const std::locale& Loc =std::locale())
|
||||
{
|
||||
return trim_fill_copy_if(Input, Fill, ::boost::is_space(Loc));
|
||||
}
|
||||
|
||||
|
||||
//! Trim Fill
|
||||
/*!
|
||||
Remove all leading and trailing spaces from the input and
|
||||
replace all every block of consecutive spaces with a fill string
|
||||
defined by user.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Fill A string used to fill the inner spaces
|
||||
\param Loc A locale used for 'space' classification
|
||||
\return A trimmed copy of the input
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void trim_fill(SequenceT& Input, const RangeT& Fill, const std::locale& Loc =std::locale())
|
||||
{
|
||||
trim_fill_if(Input, Fill, ::boost::is_space(Loc));
|
||||
}
|
||||
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names to the boost namespace
|
||||
using algorithm::trim_all;
|
||||
using algorithm::trim_all_if;
|
||||
using algorithm::trim_all_copy;
|
||||
using algorithm::trim_all_copy_if;
|
||||
using algorithm::trim_fill;
|
||||
using algorithm::trim_fill_if;
|
||||
using algorithm::trim_fill_copy;
|
||||
using algorithm::trim_fill_copy_if;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_STRING_TRIM_ALL_HPP
|
@ -92,11 +92,11 @@ Synopsis of <tt><boost/algorithm/minmax.hpp></tt></h3>
|
||||
namespace boost {
|
||||
|
||||
template <class T>
|
||||
tuple<T const&, T const&>
|
||||
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>>
|
||||
tuple<T const&, T const&>
|
||||
tuple<T const&, T const&> >
|
||||
minmax(const T& a, const T& b, BinaryPredicate comp);
|
||||
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ toolset.using doxygen ;
|
||||
|
||||
boostbook string_algo : string_algo.xml autodoc
|
||||
:
|
||||
<xsl:param>boost.root=../../../../..
|
||||
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html
|
||||
;
|
||||
|
||||
|
@ -32,9 +32,7 @@
|
||||
free-standing functions and type-generators exists:</p><code>void foo( const T&, int ); <br>
|
||||
int bar( T& ); <br>
|
||||
foo_type_of< T >::type;</code> <br> <br><hr size="1" ><h3 >Literature</h3><ul ><li > <a href="http://www.boost.org/more/generic_programming.html#type_generator" target="_self" >Type Generators</a> </li><li > <a href="http://www.boost.org/more/generic_programming.html#concept" target="_self" >Concepts</a> </li><li > <a href="http://www.sgi.com/tech/stl/stl_introduction.html" target="_self" >Concepts and SGI STL</a> </li></ul><hr size="1" ><p >© Thorsten Ottosen 2003-2004 (nesotto_AT_cs.auc.dk).
|
||||
<br>Use, modification and distribution is subject to the Boost
|
||||
Software License, Version 1.0. (See accompanying file
|
||||
<code class="filename">LICENSE_1_0.txt</code> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</br>
|
||||
</p>
|
||||
<!-- Copyright Dezide Aps 2003-2004 -->
|
||||
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.</p><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br></body></html>
|
||||
<!-- Copyright Dezide Aps 2003-2004 -->
|
@ -33,7 +33,7 @@
|
||||
<librarypurpose>
|
||||
A set of generic string-related algorithms and utilities
|
||||
</librarypurpose>
|
||||
<librarycategory name="category:algorithms"/>
|
||||
<librarycategory name="category:algoritms"/>
|
||||
<librarycategory name="category:string-text"/>
|
||||
</libraryinfo>
|
||||
|
||||
|
@ -57,7 +57,7 @@
|
||||
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,
|
||||
<ulink url="../../libs/range/doc/html/range/reference/utilities/iterator_range.html"><code>boost::iterator_range</code></ulink>
|
||||
<ulink url="../../libs/range/doc/html/range/utilities/iterator_range.html"><code>boost::iterator_range</code></ulink>
|
||||
can be used to package iterators into a structure with a compatible interface.
|
||||
</para>
|
||||
</listitem>
|
||||
@ -169,7 +169,7 @@
|
||||
<programlisting>
|
||||
string str1=" hello world! ";
|
||||
string str2=trim_left_copy(str1); // str2 == "hello world! "
|
||||
string str3=trim_right_copy(str1); // str3 == " hello world!"
|
||||
string str3=trim_right_copy(str2); // str3 == " hello world!"
|
||||
trim(str1); // str1 == "hello world!"
|
||||
|
||||
string phone="00423333444";
|
||||
@ -208,7 +208,7 @@
|
||||
</programlisting>
|
||||
<para>
|
||||
We have used <functionname>find_last()</functionname> to search the <code>text</code> for "ll".
|
||||
The result is given in the <ulink url="../../libs/range/doc/html/range/reference/utilities/iterator_range.html"><code>boost::iterator_range</code></ulink>.
|
||||
The result is given in the <ulink url="../../libs/range/doc/html/range/utilities/iterator_range.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".
|
||||
|
||||
@ -217,7 +217,7 @@
|
||||
<ulink url="../../libs/range/index.html">Boost.Range</ulink>.
|
||||
|
||||
The following lines transform the result. Notice that
|
||||
<ulink url="../../libs/range/doc/html/range/reference/utilities/iterator_range.html"><code>boost::iterator_range</code></ulink> has familiar
|
||||
<ulink url="../../libs/range/doc/html/range/utilities/iterator_range.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>
|
||||
@ -264,7 +264,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 <ulink url="../../libs/range/doc/html/range/reference/utilities/iterator_range.html"><code>boost::iterator_range</code></ulink>
|
||||
Dereferencing a find iterator yields an <ulink url="../../libs/range/doc/html/range/utilities/iterator_range.html"><code>boost::iterator_range</code></ulink>
|
||||
object, that delimits the current match.
|
||||
</para>
|
||||
<para>
|
||||
@ -339,7 +339,7 @@
|
||||
typedef vector< string > split_vector_type;
|
||||
|
||||
split_vector_type SplitVec; // #2: Search for tokens
|
||||
split( SplitVec, str1, is_any_of("-*"), token_compress_on ); // 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.
|
||||
|
@ -59,11 +59,5 @@ test-suite algorithm/string
|
||||
:
|
||||
: regex
|
||||
]
|
||||
[ run
|
||||
find_format_test.cpp
|
||||
: :
|
||||
:
|
||||
: find_format
|
||||
]
|
||||
;
|
||||
|
||||
|
@ -1,163 +0,0 @@
|
||||
// Boost string_algo library find_format_test.cpp file ------------------//
|
||||
|
||||
// Copyright (c) 2009 Steven Watanabe
|
||||
// Distributed under 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/find_format.hpp>
|
||||
#include <boost/algorithm/string/finder.hpp>
|
||||
#include <boost/algorithm/string/formatter.hpp>
|
||||
|
||||
// Include unit test framework
|
||||
#include <boost/test/included/test_exec_monitor.hpp>
|
||||
|
||||
#include <boost/test/test_tools.hpp>
|
||||
|
||||
// We're only using const_formatter.
|
||||
template<class Formatter>
|
||||
struct formatter_result {
|
||||
typedef boost::iterator_range<const char*> type;
|
||||
};
|
||||
|
||||
template<class Formatter>
|
||||
struct checked_formatter {
|
||||
public:
|
||||
checked_formatter(const Formatter& formatter) : formatter_(formatter) {}
|
||||
template< typename T >
|
||||
typename formatter_result<Formatter>::type operator()( const T & s ) const {
|
||||
BOOST_CHECK( !s.empty() );
|
||||
return formatter_(s);
|
||||
}
|
||||
private:
|
||||
Formatter formatter_;
|
||||
};
|
||||
|
||||
template<class Formatter>
|
||||
checked_formatter<Formatter>
|
||||
make_checked_formatter(const Formatter& formatter) {
|
||||
return checked_formatter<Formatter>(formatter);
|
||||
}
|
||||
|
||||
void find_format_test()
|
||||
{
|
||||
const std::string source = "$replace $replace";
|
||||
std::string expected = "ok $replace";
|
||||
std::string output(80, '\0');
|
||||
|
||||
std::string::iterator pos =
|
||||
boost::find_format_copy(
|
||||
output.begin(),
|
||||
source,
|
||||
boost::first_finder("$replace"),
|
||||
make_checked_formatter(boost::const_formatter("ok")));
|
||||
BOOST_CHECK(pos == output.begin() + expected.size());
|
||||
output.erase(std::remove(output.begin(), output.end(), '\0'), output.end());
|
||||
BOOST_CHECK_EQUAL(output, expected);
|
||||
|
||||
output =
|
||||
boost::find_format_copy(
|
||||
source,
|
||||
boost::first_finder("$replace"),
|
||||
make_checked_formatter(boost::const_formatter("ok")));
|
||||
BOOST_CHECK_EQUAL(output, expected);
|
||||
|
||||
// now try finding a string that doesn't exist
|
||||
output.resize(80);
|
||||
pos =
|
||||
boost::find_format_copy(
|
||||
output.begin(),
|
||||
source,
|
||||
boost::first_finder("$noreplace"),
|
||||
make_checked_formatter(boost::const_formatter("bad")));
|
||||
BOOST_CHECK(pos == output.begin() + source.size());
|
||||
output.erase(std::remove(output.begin(), output.end(), '\0'), output.end());
|
||||
BOOST_CHECK_EQUAL(output, source);
|
||||
|
||||
output =
|
||||
boost::find_format_copy(
|
||||
source,
|
||||
boost::first_finder("$noreplace"),
|
||||
make_checked_formatter(boost::const_formatter("bad")));
|
||||
BOOST_CHECK_EQUAL(output, source);
|
||||
|
||||
// in place version
|
||||
output = source;
|
||||
boost::find_format(
|
||||
output,
|
||||
boost::first_finder("$replace"),
|
||||
make_checked_formatter(boost::const_formatter("ok")));
|
||||
BOOST_CHECK_EQUAL(output, expected);
|
||||
output = source;
|
||||
boost::find_format(
|
||||
output,
|
||||
boost::first_finder("$noreplace"),
|
||||
make_checked_formatter(boost::const_formatter("bad")));
|
||||
BOOST_CHECK_EQUAL(output, source);
|
||||
}
|
||||
|
||||
void find_format_all_test()
|
||||
{
|
||||
const std::string source = "$replace $replace";
|
||||
std::string expected = "ok ok";
|
||||
std::string output(80, '\0');
|
||||
|
||||
std::string::iterator pos =
|
||||
boost::find_format_all_copy(output.begin(),
|
||||
source,
|
||||
boost::first_finder("$replace"),
|
||||
boost::const_formatter("ok"));
|
||||
BOOST_CHECK(pos == output.begin() + expected.size());
|
||||
output.erase(std::remove(output.begin(), output.end(), '\0'), output.end());
|
||||
BOOST_CHECK_EQUAL(output, expected);
|
||||
|
||||
output =
|
||||
boost::find_format_all_copy(
|
||||
source,
|
||||
boost::first_finder("$replace"),
|
||||
make_checked_formatter(boost::const_formatter("ok")));
|
||||
BOOST_CHECK_EQUAL(output, expected);
|
||||
|
||||
// now try finding a string that doesn't exist
|
||||
output.resize(80);
|
||||
pos =
|
||||
boost::find_format_all_copy(
|
||||
output.begin(),
|
||||
source,
|
||||
boost::first_finder("$noreplace"),
|
||||
make_checked_formatter(boost::const_formatter("bad")));
|
||||
BOOST_CHECK(pos == output.begin() + source.size());
|
||||
output.erase(std::remove(output.begin(), output.end(), '\0'), output.end());
|
||||
BOOST_CHECK_EQUAL(output, source);
|
||||
|
||||
output =
|
||||
boost::find_format_all_copy(
|
||||
source,
|
||||
boost::first_finder("$noreplace"),
|
||||
make_checked_formatter(boost::const_formatter("bad")));
|
||||
BOOST_CHECK_EQUAL(output, source);
|
||||
|
||||
// in place version
|
||||
output = source;
|
||||
boost::find_format_all(
|
||||
output,
|
||||
boost::first_finder("$replace"),
|
||||
make_checked_formatter(boost::const_formatter("ok")));
|
||||
BOOST_CHECK_EQUAL(output, expected);
|
||||
output = source;
|
||||
boost::find_format_all(
|
||||
output,
|
||||
boost::first_finder("$noreplace"),
|
||||
make_checked_formatter(boost::const_formatter("bad")));
|
||||
BOOST_CHECK_EQUAL(output, source);
|
||||
}
|
||||
|
||||
int test_main( int, char*[] )
|
||||
{
|
||||
find_format_test();
|
||||
find_format_all_test();
|
||||
|
||||
return 0;
|
||||
}
|
@ -11,9 +11,6 @@
|
||||
#include <boost/algorithm/string/erase.hpp>
|
||||
#include <boost/algorithm/string/std/list_traits.hpp>
|
||||
#include <boost/algorithm/string/std/string_traits.hpp>
|
||||
#include <boost/algorithm/string/finder.hpp>
|
||||
#include <boost/algorithm/string/formatter.hpp>
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
|
||||
// Include unit test framework
|
||||
#include <boost/test/included/test_exec_monitor.hpp>
|
||||
@ -288,23 +285,6 @@ void collection_comp_test()
|
||||
}
|
||||
}
|
||||
|
||||
void dissect_format_test()
|
||||
{
|
||||
BOOST_CHECK(
|
||||
find_format_all_copy(
|
||||
string("aBc123Abc"),
|
||||
first_finder("abc", is_iequal()),
|
||||
dissect_formatter(token_finder(is_upper())))=="B123A");
|
||||
|
||||
|
||||
BOOST_CHECK(
|
||||
find_format_all_copy(
|
||||
string("abc 123 abc"),
|
||||
token_finder(is_space(), token_compress_on),
|
||||
dissect_formatter(head_finder(1)))=="abc 123 abc");
|
||||
|
||||
}
|
||||
|
||||
// test main
|
||||
int test_main( int, char*[] )
|
||||
{
|
||||
@ -317,7 +297,6 @@ int test_main( int, char*[] )
|
||||
replace_tail_test();
|
||||
replace_range_test();
|
||||
collection_comp_test();
|
||||
dissect_format_test();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ void iterator_test()
|
||||
string str1("xx-abc--xx-abb");
|
||||
string str2("Xx-abc--xX-abb-xx");
|
||||
string str3("xx");
|
||||
string strempty("");
|
||||
const char* pch1="xx-abc--xx-abb";
|
||||
vector<string> tokens;
|
||||
vector< vector<int> > vtokens;
|
||||
@ -124,25 +123,6 @@ void iterator_test()
|
||||
BOOST_CHECK( tokens[3]==string("xx") );
|
||||
BOOST_CHECK( tokens[4]==string("abb") );
|
||||
|
||||
split(
|
||||
tokens,
|
||||
str3,
|
||||
is_any_of(","),
|
||||
token_compress_off);
|
||||
|
||||
BOOST_REQUIRE( tokens.size()==1 );
|
||||
BOOST_CHECK( tokens[0]==string("xx") );
|
||||
|
||||
split(
|
||||
tokens,
|
||||
strempty,
|
||||
is_punct(),
|
||||
token_compress_off);
|
||||
|
||||
BOOST_REQUIRE( tokens.size()==1 );
|
||||
BOOST_CHECK( tokens[0]==string("") );
|
||||
|
||||
|
||||
find_iterator<string::iterator> fiter=make_find_iterator(str1, first_finder("xx"));
|
||||
BOOST_CHECK(equals(*fiter, "xx"));
|
||||
++fiter;
|
||||
@ -159,7 +139,6 @@ void iterator_test()
|
||||
++siter;
|
||||
BOOST_CHECK(equals(*siter, "abb"));
|
||||
++siter;
|
||||
BOOST_CHECK(siter==split_iterator<string::iterator>(siter));
|
||||
BOOST_CHECK(siter==split_iterator<string::iterator>());
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
#include <boost/algorithm/string/trim_all.hpp>
|
||||
|
||||
// Include unit test framework
|
||||
#include <boost/test/included/test_exec_monitor.hpp>
|
||||
@ -110,95 +109,10 @@ void trim_test()
|
||||
BOOST_CHECK( trim_copy_if( string("<>abc<>"), is_any_of( "<<>>" ) )=="abc" );
|
||||
}
|
||||
|
||||
void trim_all_test()
|
||||
{
|
||||
string str1(" 1x x x x1 ");
|
||||
string str2("+---...2x+--x--+x-+-x2...---+");
|
||||
string str3(" ");
|
||||
|
||||
// *** value passing tests *** //
|
||||
|
||||
// general string test
|
||||
BOOST_CHECK( trim_all_copy( str1 )=="1x x x x1" ) ;
|
||||
BOOST_CHECK( trim_all_copy_if( str2, is_punct() )=="2x+x-x-x2" ) ;
|
||||
|
||||
// spaces-only string test
|
||||
BOOST_CHECK( trim_all_copy( str3 )=="" );
|
||||
|
||||
// empty string check
|
||||
BOOST_CHECK( trim_all_copy( string("") )=="" );
|
||||
|
||||
// general string test
|
||||
trim_all( str1 );
|
||||
BOOST_CHECK( str1=="1x x x x1" ) ;
|
||||
trim_all_if( str2, is_punct() );
|
||||
BOOST_CHECK( str2=="2x+x-x-x2" ) ;
|
||||
|
||||
// spaces-only string test
|
||||
str3 = " "; trim_all( str3 );
|
||||
BOOST_CHECK( str3=="" );
|
||||
|
||||
// empty string check
|
||||
str3 = ""; trim_all( str3 );
|
||||
BOOST_CHECK( str3=="" );
|
||||
BOOST_CHECK( str3=="" );
|
||||
|
||||
// *** non-standard predicate tests *** //
|
||||
BOOST_CHECK(
|
||||
trim_all_copy_if(
|
||||
string("123abc127deb456"),
|
||||
is_classified(std::ctype_base::digit) )=="abc1deb" );
|
||||
BOOST_CHECK( trim_all_copy_if( string("<>abc<>def<>"), is_any_of( "<<>>" ) )=="abc<def" );
|
||||
}
|
||||
|
||||
void trim_fill_test()
|
||||
{
|
||||
string str1(" 1x x x x1 ");
|
||||
string str2("+---...2x+--x--+x-+-x2...---+");
|
||||
string str3(" ");
|
||||
|
||||
// *** value passing tests *** //
|
||||
|
||||
// general string test
|
||||
BOOST_CHECK( trim_fill_copy( str1, "-" )=="1x-x-x-x1" ) ;
|
||||
BOOST_CHECK( trim_fill_copy_if( str2, " ", is_punct() )=="2x x x x2" ) ;
|
||||
|
||||
// spaces-only string test
|
||||
BOOST_CHECK( trim_fill_copy( str3, " " )=="" );
|
||||
|
||||
// empty string check
|
||||
BOOST_CHECK( trim_fill_copy( string(""), " " )=="" );
|
||||
|
||||
// general string test
|
||||
trim_fill( str1, "-" );
|
||||
BOOST_CHECK( str1=="1x-x-x-x1" ) ;
|
||||
trim_fill_if( str2, "", is_punct() );
|
||||
BOOST_CHECK( str2=="2xxxx2" ) ;
|
||||
|
||||
// spaces-only string test
|
||||
str3 = " "; trim_fill( str3, "" );
|
||||
BOOST_CHECK( str3=="" );
|
||||
|
||||
// empty string check
|
||||
str3 = ""; trim_fill( str3, "" );
|
||||
BOOST_CHECK( str3=="" );
|
||||
BOOST_CHECK( str3=="" );
|
||||
|
||||
// *** non-standard predicate tests *** //
|
||||
BOOST_CHECK(
|
||||
trim_fill_copy_if(
|
||||
string("123abc127deb456"),
|
||||
"+",
|
||||
is_classified(std::ctype_base::digit) )=="abc+deb" );
|
||||
BOOST_CHECK( trim_fill_copy_if( string("<>abc<>def<>"), "-", is_any_of( "<<>>" ) )=="abc-def" );
|
||||
}
|
||||
|
||||
// test main
|
||||
int test_main( int, char*[] )
|
||||
{
|
||||
trim_test();
|
||||
trim_all_test();
|
||||
trim_fill_test();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user