From bbd3220a1e99a09bb9106160bce13f2010b18701 Mon Sep 17 00:00:00 2001
From: Pavol Droba
Date: Sat, 10 Jul 2010 20:29:03 +0000
Subject: [PATCH] Merging changes from trunk
[SVN r63824]
---
.../algorithm/string/detail/case_conv.hpp | 12 +-
.../string/detail/classification.hpp | 24 +--
.../algorithm/string/detail/find_format.hpp | 18 +-
.../string/detail/find_format_all.hpp | 16 +-
.../string/detail/find_format_store.hpp | 11 ++
include/boost/algorithm/string/erase.hpp | 4 +-
include/boost/algorithm/string/find.hpp | 2 +-
.../boost/algorithm/string/find_iterator.hpp | 2 +-
string/doc/external_concepts.html | 10 +-
string/doc/string_algo.xml | 2 +-
string/doc/usage.xml | 4 +-
string/test/Jamfile.v2 | 6 +
string/test/find_format_test.cpp | 163 ++++++++++++++++++
string/test/split_test.cpp | 1 +
14 files changed, 239 insertions(+), 36 deletions(-)
create mode 100644 string/test/find_format_test.cpp
diff --git a/include/boost/algorithm/string/detail/case_conv.hpp b/include/boost/algorithm/string/detail/case_conv.hpp
index 3440c27..5b0064f 100644
--- a/include/boost/algorithm/string/detail/case_conv.hpp
+++ b/include/boost/algorithm/string/detail/case_conv.hpp
@@ -31,7 +31,7 @@ namespace boost {
struct to_lowerF : public std::unary_function
{
// 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( Ch, m_Loc );
+ return std::tolower( 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
{
// 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( Ch, m_Loc );
+ return std::toupper( Ch, *m_Loc );
#endif
}
private:
- const std::locale& m_Loc;
+ const std::locale* m_Loc;
};
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
diff --git a/include/boost/algorithm/string/detail/classification.hpp b/include/boost/algorithm/string/detail/classification.hpp
index 9a34bf0..fb43955 100644
--- a/include/boost/algorithm/string/detail/classification.hpp
+++ b/include/boost/algorithm/string/detail/classification.hpp
@@ -32,8 +32,8 @@ namespace boost {
struct is_classifiedF :
public predicate_facade
{
- // Boost.Lambda support
- template struct sig { typedef bool type; };
+ // Boost.ResultOf support
+ typedef bool result_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::type set_value_type;
public:
- // Boost.Lambda support
- template struct sig { typedef bool type; };
+ // Boost.ResultOf support
+ typedef bool result_type;
// Constructor
template
@@ -253,8 +253,8 @@ namespace boost {
struct is_from_rangeF :
public predicate_facade< is_from_rangeF >
{
- // Boost.Lambda support
- template struct sig { typedef bool type; };
+ // Boost.ResultOf support
+ typedef bool result_type;
// Constructor
is_from_rangeF( CharT From, CharT To ) : m_From(From), m_To(To) {}
@@ -278,8 +278,8 @@ namespace boost {
{
public:
- // Boost.Lambda support
- template struct sig { typedef bool type; };
+ // Boost.ResultOf support
+ typedef bool result_type;
// Constructor
pred_andF( Pred1T Pred1, Pred2T Pred2 ) :
@@ -303,8 +303,8 @@ namespace boost {
public predicate_facade< pred_orF >
{
public:
- // Boost.Lambda support
- template struct sig { typedef bool type; };
+ // Boost.ResultOf support
+ typedef bool result_type;
// Constructor
pred_orF( Pred1T Pred1, Pred2T Pred2 ) :
@@ -328,8 +328,8 @@ namespace boost {
public predicate_facade< pred_notF >
{
public:
- // Boost.Lambda support
- template struct sig { typedef bool type; };
+ // Boost.ResultOf support
+ typedef bool result_type;
// Constructor
pred_notF( PredT Pred ) : m_Pred(Pred) {}
diff --git a/include/boost/algorithm/string/detail/find_format.hpp b/include/boost/algorithm/string/detail/find_format.hpp
index 0d8b104..7f5f780 100644
--- a/include/boost/algorithm/string/detail/find_format.hpp
+++ b/include/boost/algorithm/string/detail/find_format.hpp
@@ -49,17 +49,17 @@ namespace boost {
if ( !M )
{
// Match not found - return original sequence
- std::copy( ::boost::begin(Input), ::boost::end(Input), Output );
+ Output = std::copy( ::boost::begin(Input), ::boost::end(Input), Output );
return Output;
}
// Copy the beginning of the sequence
- std::copy( ::boost::begin(Input), ::boost::begin(M), Output );
+ Output = std::copy( ::boost::begin(Input), ::boost::begin(M), Output );
// Format find result
// Copy formated result
- std::copy( ::boost::begin(M.format_result()), ::boost::end(M.format_result()), Output );
+ Output = std::copy( ::boost::begin(M.format_result()), ::boost::end(M.format_result()), Output );
// Copy the rest of the sequence
- std::copy( M.end(), ::boost::end(Input), Output );
+ Output = std::copy( M.end(), ::boost::end(Input), Output );
return Output;
}
@@ -75,12 +75,16 @@ namespace boost {
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 );
+ }
}
@@ -132,11 +136,15 @@ 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;
+ }
}
// replace implementation ----------------------------------------------------//
@@ -180,12 +188,14 @@ 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) );
}
+ }
} // namespace detail
} // namespace algorithm
diff --git a/include/boost/algorithm/string/detail/find_format_all.hpp b/include/boost/algorithm/string/detail/find_format_all.hpp
index 36edf56..0f184a3 100644
--- a/include/boost/algorithm/string/detail/find_format_all.hpp
+++ b/include/boost/algorithm/string/detail/find_format_all.hpp
@@ -57,9 +57,9 @@ namespace boost {
while( M )
{
// Copy the beginning of the sequence
- std::copy( LastMatch, M.begin(), Output );
+ Output = std::copy( LastMatch, M.begin(), Output );
// Copy formated result
- std::copy( ::boost::begin(M.format_result()), ::boost::end(M.format_result()), Output );
+ 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
- std::copy( LastMatch, ::boost::end(Input), Output );
+ Output = std::copy( LastMatch, ::boost::end(Input), Output );
return Output;
}
@@ -85,6 +85,7 @@ 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(
Output,
Input,
@@ -92,6 +93,9 @@ namespace boost {
Formatter,
FindResult,
Formatter(FindResult) );
+ } else {
+ return std::copy( ::boost::begin(Input), ::boost::end(Input), Output );
+ }
}
// find_format_all_copy implementation ----------------------------------------------//
@@ -156,12 +160,16 @@ 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;
+ }
}
// find_format_all implementation ------------------------------------------------//
@@ -248,6 +256,7 @@ namespace boost {
FormatterT Formatter,
FindResultT FindResult)
{
+ if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) {
::boost::algorithm::detail::find_format_all_impl2(
Input,
Finder,
@@ -255,6 +264,7 @@ namespace boost {
FindResult,
Formatter(FindResult) );
}
+ }
} // namespace detail
} // namespace algorithm
diff --git a/include/boost/algorithm/string/detail/find_format_store.hpp b/include/boost/algorithm/string/detail/find_format_store.hpp
index 2260fc2..24fe374 100644
--- a/include/boost/algorithm/string/detail/find_format_store.hpp
+++ b/include/boost/algorithm/string/detail/find_format_store.hpp
@@ -52,7 +52,9 @@ namespace boost {
find_format_store& operator=( FindResultT FindResult )
{
iterator_range::operator=(FindResult);
+ if( !this->empty() ) {
m_FormatResult=m_Formatter(FindResult);
+ }
return *this;
}
@@ -68,6 +70,15 @@ namespace boost {
const formatter_type& m_Formatter;
};
+ template
+ bool check_find_result(InputT& Input, FindResultT& FindResult)
+ {
+ typedef BOOST_STRING_TYPENAME
+ range_const_iterator::type input_iterator_type;
+ iterator_range ResultRange(FindResult);
+ return !ResultRange.empty();
+ }
+
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(pop)
#endif
diff --git a/include/boost/algorithm/string/erase.hpp b/include/boost/algorithm/string/erase.hpp
index 0951b8a..e738b86 100644
--- a/include/boost/algorithm/string/erase.hpp
+++ b/include/boost/algorithm/string/erase.hpp
@@ -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 head.
+ \param N Length of the tail.
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 head
+ \param N Length of the tail
For N>=0, at most N characters are extracted.
For N<0, size(Input)-|N| characters are extracted.
*/
diff --git a/include/boost/algorithm/string/find.hpp b/include/boost/algorithm/string/find.hpp
index b282d1a..304646d 100644
--- a/include/boost/algorithm/string/find.hpp
+++ b/include/boost/algorithm/string/find.hpp
@@ -257,7 +257,7 @@ namespace boost {
//! Find tail algorithm
/*!
- Get the head of the input. Head is a suffix of the string of the
+ Get the tail of the input. Tail 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.
diff --git a/include/boost/algorithm/string/find_iterator.hpp b/include/boost/algorithm/string/find_iterator.hpp
index 4224a19..72696c7 100644
--- a/include/boost/algorithm/string/find_iterator.hpp
+++ b/include/boost/algorithm/string/find_iterator.hpp
@@ -240,7 +240,7 @@ namespace boost {
m_Match(Other.m_Match),
m_Next(Other.m_Next),
m_End(Other.m_End),
- m_bEof(false)
+ m_bEof(Other.m_bEof)
{}
//! Constructor
diff --git a/string/doc/external_concepts.html b/string/doc/external_concepts.html
index 7a4a502..af403be 100644
--- a/string/doc/external_concepts.html
+++ b/string/doc/external_concepts.html
@@ -32,7 +32,9 @@
free-standing functions and type-generators exists:
void foo( const T&, int );
int bar( T& );
foo_type_of< T >::type;
Literature
© Thorsten Ottosen 2003-2004 (nesotto_AT_cs.auc.dk).
- 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.