Compare commits

..

75 Commits

Author SHA1 Message Date
84a2aaeae1 Branch for working on the documentation tools documentation.
[SVN r68640]
2011-02-04 21:18:24 +00:00
caea7bd125 trim_all test fixed
[SVN r68173]
2011-01-15 18:37:46 +00:00
81b04cde96 Revert [67111] (addition of boost/detail/iomanip.hpp) and all the commits that depend on it. ([68137], [68140], [68141], [68154], and [68165]).
[SVN r68168]
2011-01-15 08:11:51 +00:00
276073ca64 tabs removed
[SVN r68162]
2011-01-14 23:12:32 +00:00
a7f5bdd781 trim_all algorithm added
[SVN r68161]
2011-01-14 23:06:14 +00:00
0c0a866f07 Replacing the use of <iomanip> with <boost/detail/iomanip.hpp> across Boost.
On Linux, GNU's libstdc++, which is the default stdlib for icc and clang,
cannot parse the <iomanip> header in version 4.5+ (which thankfully neither
compiler advises the use of yet), as it's original C++98-friendly
implementation has been replaced with a gnu++0x implementation.
<boost/detail/iomanip.hpp> is a portable implementation of <iomanip>, providing
boost::detail::setfill, boost::detail::setbase, boost::detail::setw,
boost::detail::setprecision, boost::detail::setiosflags and
boost::detail::resetiosflags. 



[SVN r68140]
2011-01-14 02:35:58 +00:00
9d25072f2f dissect formatter and tests added
[SVN r68124]
2011-01-13 21:21:37 +00:00
823b199df3 Fix typo. Fixes #4937.
[SVN r67106]
2010-12-08 17:37:52 +00:00
fecd440527 Fix some links I missed in string algorithms
[SVN r66278]
2010-10-30 15:53:41 +00:00
3325d3a3f8 Link fixes.
[SVN r66273]
2010-10-30 14:32:50 +00:00
ebf104c127 test for empty string split added
[SVN r66221]
2010-10-27 20:42:22 +00:00
3b76763807 fixed the empty string handling for the split iterator
[SVN r66220]
2010-10-27 20:40:37 +00:00
62df1eb048 Fix #4551,#4553,#4575 by removing unused parameter.
[SVN r65004]
2010-08-25 20:01:38 +00:00
f5dd47883f Update various libraries' documentation build.
Mostly to use the images and css files under doc/src instead of
doc/html, usually be deleting the settings in order to use the defaults.
Also add 'boost.root' to some builds in order to fix links which rely on
it.

[SVN r63146]
2010-06-20 18:00:48 +00:00
9d68c4280c Fix license per inspection report.
[SVN r62814]
2010-06-11 19:52:26 +00:00
1e8b3ee752 Make to_upperF and to_lowerF assignable. Fixes #3161.
[SVN r62697]
2010-06-09 23:23:56 +00:00
42147c8385 Copy m_bEof in the split_iterator copy constructor. Fixes #4271
[SVN r62696]
2010-06-09 23:12:56 +00:00
672775545d Avoid calling the formatter with an invalid match. Fixes #2777
[SVN r62695]
2010-06-09 23:04:24 +00:00
46ed1bf987 Assign the iterator returned by std::copy back to Output, so that string algorithms will work with iterators other than inserters
[SVN r62694]
2010-06-09 21:12:06 +00:00
6289ed7f98 Trim the correct string. Fixes #3860
[SVN r62692]
2010-06-09 20:42:46 +00:00
8e97668b1f Tail not head. Fixes #3314
[SVN r62690]
2010-06-09 20:31:26 +00:00
e7c23d2f13 Tail not head. Fixes #2124
[SVN r62689]
2010-06-09 20:26:36 +00:00
a1e7512012 Use result_type instead of sig for predicates. Fixes #2868
[SVN r62688]
2010-06-09 20:16:21 +00:00
31b5842441 Typo.
[SVN r62461]
2010-06-06 07:18:24 +00:00
4515bc182e Fix example. Fixes #4206
[SVN r61931]
2010-05-12 12:56:16 +00:00
7e2e6856cc Remove duplicate closing angle brackets. Fixes #4198
[SVN r61856]
2010-05-08 18:27:44 +00:00
235c81be61 Fixed various issues in docs (mostly duplicate bookmarks and broken links) found by inspect tool
[SVN r61437]
2010-04-20 18:49:18 +00:00
1eb3d83534 Fix links for string algorithm to range documentation.
[SVN r61351]
2010-04-18 12:17:36 +00:00
8f2b8d4888 rm cmake from trunk. I'm not entirely sure this is necessary to satisfy the inspect script, but I'm not taking any chances, and it is easy to put back
[SVN r56942]
2009-10-17 02:07:38 +00:00
6c0f953c01 GCC compilation errors caused be the recent update fixed
[SVN r55434]
2009-08-06 19:52:08 +00:00
e439792494 Merged ADL protection patch from Neil Groves
[SVN r55424]
2009-08-05 20:01:10 +00:00
236b142308 Copyrights on CMakeLists.txt to keep them from clogging up the inspect
reports.  This is essentially the same commit as r55095 on the release
branch.



[SVN r55159]
2009-07-26 00:49:56 +00:00
9bad789175 Fix operator precedence error in documentation. Fixes #2122
[SVN r53520]
2009-06-01 00:47:03 +00:00
d84f81d841 Fixed most tab and min/max issues from trunk inspection report
[SVN r53141]
2009-05-20 19:19:00 +00:00
ce98e8b87e Qualify minmax with boost:: to avoid ambiguity with std::minmax. Fixes #3023
[SVN r53062]
2009-05-17 00:39:22 +00:00
e8a2596637 Add PDF generation options to fix external links to point to the web site.
Added a few more Boostbook based libs that were missed first time around.
Fixed PDF naming issues.

[SVN r51284]
2009-02-17 10:05:58 +00:00
7b2754b937 Fix copy/paste error in minmax docs. Fixes #2500
[SVN r51045]
2009-02-06 03:45:09 +00:00
784402e5c0 Updating dependency information for modularized libraries.
[SVN r49628]
2008-11-07 17:05:27 +00:00
1188575e7b Updating CMake files to latest trunk. Added dependency information for regression tests and a few new macros for internal use.
[SVN r49627]
2008-11-07 17:02:56 +00:00
bff2a1e112 Continuing merge of CMake build system files into trunk with the encouragement of Doug Gregor
[SVN r49510]
2008-11-01 13:15:41 +00:00
6d5e7b5a04 self assignment problem in is_any_ofF fixed
[SVN r48281]
2008-08-21 14:46:15 +00:00
760af1798b removed static constant FIXED_STORAGE_SIZE from is_any_of to
make the code compile on borland compilers



[SVN r48218]
2008-08-19 14:32:59 +00:00
1f5542b44c predicate test improvements
[SVN r48199]
2008-08-18 18:33:40 +00:00
baf3dd99e2 fox for allocation bug in is_any_ofF
[SVN r48198]
2008-08-18 18:32:51 +00:00
7299b29bf8 fixind the problems in is_any_ofF spotted by gcc
[SVN r46498]
2008-06-18 22:07:32 +00:00
539c170b9d aditional tests added
[SVN r46497]
2008-06-18 21:55:38 +00:00
c81ee948b7 is_any_ofF performance improvements
tabs removed



[SVN r46496]
2008-06-18 21:54:06 +00:00
ba5e4c30c6 fixed the rle example crash
[SVN r46463]
2008-06-17 21:58:58 +00:00
cd26ed816c patch from ticket #1152 applied
[SVN r46461]
2008-06-17 21:21:33 +00:00
4e15767bed simple_finder example fixed
[SVN r46460]
2008-06-17 21:13:25 +00:00
9fa2f90db4 begin() and end() calls made fully qualified
[SVN r46459]
2008-06-17 21:04:00 +00:00
35f317aeac unnecessary typedefs removed
[SVN r46458]
2008-06-17 20:31:41 +00:00
d0a03fdb4e Added missing include. This was already fixed on the 1.34 branch but never merged to the trunk.
[SVN r45857]
2008-05-28 08:32:12 +00:00
346f032be2 Quote href values - our tools don't support unquoted values.
[SVN r45283]
2008-05-11 13:49:20 +00:00
a389d768c4 Fix broken copyright urls. Fixes #1573.
[SVN r43422]
2008-02-27 18:51:14 +00:00
90fca39906 Point links to the pages that used to be in 'more' to the site.
[SVN r43210]
2008-02-10 15:02:17 +00:00
5b24f31486 merging changes from 1.34
[SVN r40698]
2007-11-02 21:00:08 +00:00
b25d6511b3 merging changes from 1.34
[SVN r40697]
2007-11-02 20:55:26 +00:00
1541a554f5 changed range_result_iterator to range_iterator
[SVN r40518]
2007-10-27 22:52:29 +00:00
7a97b3390e Added missing include.
[SVN r39586]
2007-09-28 07:19:29 +00:00
6e5a7497ae Added missing include.
[SVN r39519]
2007-09-25 08:46:31 +00:00
f0b8b60379 Update
[SVN r38522]
2007-08-08 19:24:04 +00:00
66019abb2f Update
[SVN r38521]
2007-08-08 19:23:38 +00:00
8758222006 Remove V1 Jamfiles
[SVN r38516]
2007-08-08 19:02:26 +00:00
4eef56761a find/split iterator tests added
[SVN r38126]
2007-07-01 22:24:29 +00:00
b94a3fbfba adapting to new range interface
[SVN r38125]
2007-07-01 22:23:55 +00:00
614cc2ebab adapting to new range interface
[SVN r38123]
2007-07-01 13:29:56 +00:00
869660ed14 adapted to the new range interface
[SVN r38122]
2007-07-01 13:12:57 +00:00
777f30780e Fix broken build of docs, it was missing a dependency to the doxygen docs.
[SVN r37466]
2007-04-17 17:19:25 +00:00
26aa37733b Fix a few more references to *.boosbook instead of *.xml generated files.
[SVN r37465]
2007-04-17 17:13:35 +00:00
f1e60579c2 documentation typo fixed
[SVN r36843]
2007-01-30 07:59:28 +00:00
389dd3c863 Add copyright, license
[SVN r35905]
2006-11-07 19:11:57 +00:00
f23f61ae9b License added to the xml doc files
[SVN r34895]
2006-08-16 07:17:49 +00:00
608112b112 boost guidelines (mainly from inspect tool: tabs, license reference text, etc.)
[SVN r34752]
2006-07-27 10:27:37 +00:00
b21b54dc4e Applying patch from Nicola Musatti
[SVN r33709]
2006-04-16 09:46:34 +00:00
12 changed files with 312 additions and 50 deletions

View File

@ -74,17 +74,17 @@ namespace boost {
const InputT& Input, const InputT& Input,
FormatterT Formatter, FormatterT Formatter,
const FindResultT& FindResult ) const FindResultT& FindResult )
{ {
if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) {
return ::boost::algorithm::detail::find_format_copy_impl2( return ::boost::algorithm::detail::find_format_copy_impl2(
Output, Output,
Input, Input,
Formatter, Formatter,
FindResult, FindResult,
Formatter(FindResult) ); Formatter(FindResult) );
} else { } else {
return std::copy( ::boost::begin(Input), ::boost::end(Input), Output ); return std::copy( ::boost::begin(Input), ::boost::end(Input), Output );
} }
} }
@ -137,14 +137,14 @@ namespace boost {
const FindResultT& FindResult) const FindResultT& FindResult)
{ {
if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) {
return ::boost::algorithm::detail::find_format_copy_impl2( return ::boost::algorithm::detail::find_format_copy_impl2(
Input, Input,
Formatter, Formatter,
FindResult, FindResult,
Formatter(FindResult) ); Formatter(FindResult) );
} else { } else {
return Input; return Input;
} }
} }
// replace implementation ----------------------------------------------------// // replace implementation ----------------------------------------------------//
@ -189,12 +189,12 @@ namespace boost {
const FindResultT& FindResult) const FindResultT& FindResult)
{ {
if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) {
::boost::algorithm::detail::find_format_impl2( ::boost::algorithm::detail::find_format_impl2(
Input, Input,
Formatter, Formatter,
FindResult, FindResult,
Formatter(FindResult) ); Formatter(FindResult) );
} }
} }
} // namespace detail } // namespace detail

View File

@ -84,18 +84,18 @@ namespace boost {
FinderT Finder, FinderT Finder,
FormatterT Formatter, FormatterT Formatter,
const FindResultT& FindResult ) const FindResultT& FindResult )
{ {
if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) {
return ::boost::algorithm::detail::find_format_all_copy_impl2( return ::boost::algorithm::detail::find_format_all_copy_impl2(
Output, Output,
Input, Input,
Finder, Finder,
Formatter, Formatter,
FindResult, FindResult,
Formatter(FindResult) ); Formatter(FindResult) );
} else { } else {
return std::copy( ::boost::begin(Input), ::boost::end(Input), Output ); return std::copy( ::boost::begin(Input), ::boost::end(Input), Output );
} }
} }
// find_format_all_copy implementation ----------------------------------------------// // find_format_all_copy implementation ----------------------------------------------//
@ -161,15 +161,15 @@ namespace boost {
const FindResultT& FindResult) const FindResultT& FindResult)
{ {
if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) {
return ::boost::algorithm::detail::find_format_all_copy_impl2( return ::boost::algorithm::detail::find_format_all_copy_impl2(
Input, Input,
Finder, Finder,
Formatter, Formatter,
FindResult, FindResult,
Formatter(FindResult) ); Formatter(FindResult) );
} else { } else {
return Input; return Input;
} }
} }
// find_format_all implementation ------------------------------------------------// // find_format_all implementation ------------------------------------------------//
@ -257,13 +257,13 @@ namespace boost {
FindResultT FindResult) FindResultT FindResult)
{ {
if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) {
::boost::algorithm::detail::find_format_all_impl2( ::boost::algorithm::detail::find_format_all_impl2(
Input, Input,
Finder, Finder,
Formatter, Formatter,
FindResult, FindResult,
Formatter(FindResult) ); Formatter(FindResult) );
} }
} }
} // namespace detail } // namespace detail

View File

@ -53,7 +53,7 @@ namespace boost {
{ {
iterator_range<ForwardIteratorT>::operator=(FindResult); iterator_range<ForwardIteratorT>::operator=(FindResult);
if( !this->empty() ) { if( !this->empty() ) {
m_FormatResult=m_Formatter(FindResult); m_FormatResult=m_Formatter(FindResult);
} }
return *this; return *this;

View File

@ -87,6 +87,31 @@ 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 detail
} // namespace algorithm } // namespace algorithm
} // namespace boost } // namespace boost

View File

@ -259,7 +259,11 @@ namespace boost {
m_End(End), m_End(End),
m_bEof(false) m_bEof(false)
{ {
increment(); // force the correct behavior for empty sequences and yield at least one token
if(Begin!=End)
{
increment();
}
} }
//! Constructor //! Constructor
/*! /*!
@ -278,7 +282,11 @@ namespace boost {
m_Next=::boost::begin(lit_col); m_Next=::boost::begin(lit_col);
m_End=::boost::end(lit_col); m_End=::boost::end(lit_col);
increment(); // force the correct behavior for empty sequences and yield at least one token
if(m_Next!=m_End)
{
increment();
}
} }

View File

@ -36,7 +36,7 @@ namespace boost {
//! Constant formatter //! Constant formatter
/*! /*!
Construct the \c const_formatter. Const formatter always returns Constructs a \c const_formatter. Const formatter always returns
the same value, regardless of the parameter. the same value, regardless of the parameter.
\param Format A predefined value used as a result for formating \param Format A predefined value used as a result for formating
@ -55,7 +55,7 @@ namespace boost {
//! Identity formatter //! Identity formatter
/*! /*!
Construct the \c identity_formatter. Identity formatter always returns Constructs an \c identity_formatter. Identity formatter always returns
the parameter. the parameter.
\return An instance of the \c identity_formatter object. \return An instance of the \c identity_formatter object.
@ -73,7 +73,7 @@ namespace boost {
//! Empty formatter //! Empty formatter
/*! /*!
Construct the \c empty_formatter. Empty formatter always returns an empty Constructs an \c empty_formatter. Empty formatter always returns an empty
sequence. sequence.
\param Input container used to select a correct value_type for the \param Input container used to select a correct value_type for the
@ -89,6 +89,22 @@ namespace boost {
BOOST_STRING_TYPENAME range_value<RangeT>::type>(); 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 } // namespace algorithm
@ -96,6 +112,7 @@ namespace boost {
using algorithm::const_formatter; using algorithm::const_formatter;
using algorithm::identity_formatter; using algorithm::identity_formatter;
using algorithm::empty_formatter; using algorithm::empty_formatter;
using algorithm::dissect_formatter;
} // namespace boost } // namespace boost

View File

@ -0,0 +1,127 @@
// 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.
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 space.
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 space.
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 space.
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 space.
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));
}
} // 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;
} // namespace boost
#endif // BOOST_STRING_TRIM_ALL_HPP

View File

@ -338,7 +338,7 @@ most</i> instead of <i>exactly</i> in the odd case.
<b>Rationale:</b></h3> <b>Rationale:</b></h3>
<a name="two_headers"> <a name="two_headers">
<h4><b>Why not a single header <tt>&amp;boost/algorithm/minmax.hpp></tt>?</b></h4> <h4><b>Why not a single header <tt>&lt;boost/algorithm/minmax.hpp></tt>?</b></h4>
<p>This was the design originally proposed and approved in the formal <p>This was the design originally proposed and approved in the formal
review. As the need for Boost.tuple became clear (due to the limitations review. As the need for Boost.tuple became clear (due to the limitations
of <tt>std::pair</tt>), it became also annoying to require another of <tt>std::pair</tt>), it became also annoying to require another

View File

@ -43,6 +43,7 @@ doxygen autodoc
[ glob ../../../../boost/algorithm/string/formatter.hpp ] [ glob ../../../../boost/algorithm/string/formatter.hpp ]
[ glob ../../../../boost/algorithm/string/regex.hpp ] [ glob ../../../../boost/algorithm/string/regex.hpp ]
[ glob ../../../../boost/algorithm/string/regex_find_format.hpp ] [ glob ../../../../boost/algorithm/string/regex_find_format.hpp ]
[ glob ../../../../boost/algorithm/string/trim_all.hpp ]
: :
<doxygen:param>HIDE_UNDOC_MEMBERS=YES <doxygen:param>HIDE_UNDOC_MEMBERS=YES
<doxygen:param>EXTRACT_PRIVATE=NO <doxygen:param>EXTRACT_PRIVATE=NO

View File

@ -11,6 +11,9 @@
#include <boost/algorithm/string/erase.hpp> #include <boost/algorithm/string/erase.hpp>
#include <boost/algorithm/string/std/list_traits.hpp> #include <boost/algorithm/string/std/list_traits.hpp>
#include <boost/algorithm/string/std/string_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 unit test framework
#include <boost/test/included/test_exec_monitor.hpp> #include <boost/test/included/test_exec_monitor.hpp>
@ -285,6 +288,23 @@ 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 // test main
int test_main( int, char*[] ) int test_main( int, char*[] )
{ {
@ -297,6 +317,7 @@ int test_main( int, char*[] )
replace_tail_test(); replace_tail_test();
replace_range_test(); replace_range_test();
collection_comp_test(); collection_comp_test();
dissect_format_test();
return 0; return 0;
} }

View File

@ -40,6 +40,7 @@ void iterator_test()
string str1("xx-abc--xx-abb"); string str1("xx-abc--xx-abb");
string str2("Xx-abc--xX-abb-xx"); string str2("Xx-abc--xX-abb-xx");
string str3("xx"); string str3("xx");
string strempty("");
const char* pch1="xx-abc--xx-abb"; const char* pch1="xx-abc--xx-abb";
vector<string> tokens; vector<string> tokens;
vector< vector<int> > vtokens; vector< vector<int> > vtokens;
@ -123,6 +124,25 @@ void iterator_test()
BOOST_CHECK( tokens[3]==string("xx") ); BOOST_CHECK( tokens[3]==string("xx") );
BOOST_CHECK( tokens[4]==string("abb") ); 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")); find_iterator<string::iterator> fiter=make_find_iterator(str1, first_finder("xx"));
BOOST_CHECK(equals(*fiter, "xx")); BOOST_CHECK(equals(*fiter, "xx"));
++fiter; ++fiter;

View File

@ -8,6 +8,7 @@
// See http://www.boost.org for updates, documentation, and revision history. // See http://www.boost.org for updates, documentation, and revision history.
#include <boost/algorithm/string/trim.hpp> #include <boost/algorithm/string/trim.hpp>
#include <boost/algorithm/string/trim_all.hpp>
// Include unit test framework // Include unit test framework
#include <boost/test/included/test_exec_monitor.hpp> #include <boost/test/included/test_exec_monitor.hpp>
@ -109,10 +110,52 @@ void trim_test()
BOOST_CHECK( trim_copy_if( string("<>abc<>"), is_any_of( "<<>>" ) )=="abc" ); 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" );
}
// test main // test main
int test_main( int, char*[] ) int test_main( int, char*[] )
{ {
trim_test(); trim_test();
trim_all_test();
return 0; return 0;
} }