|
Boost : |
From: Pavol Droba (droba_at_[hidden])
Date: 2002-11-15 11:58:43
Hi Boosters,
I have developed a set of various string manipulating functions into a string_algo lib.
The choice is partly based on the discussion here in the boost list.
The implementaion is currently in the sandbox in the boost/string_algo.hpp header and
boost/string_algo dir.
There is a small example and tests in the sandbox/lib/string_algo.
Currently there is no real documentation, because the lib is in early stage of development
and so it could change quite repidly. The best source of usage scenario are the the tests.
Library has been tested with VC7 and gcc3.2 on cygwin.
As there has been an interest I'd like to ask you if such a library should become a part of boots
in the future. I'd be happy to hear any opinions and suggestions.
The library contains following functions divided by categories.
Functions with _in suffix provide in-place transformation.
For each Find-Replace category function there is a variant with implicit Comp predicate defaulting
to == operator functor
Trimming:
Iterator trim_begin( Iterator InBegin, Iterator InEnd, const std::locale& Loc=std::locale() )
Seq ltrim( const Seq& Input, const std::locale& Loc=std::locale() )
Seq& ltrim_in( Seq& Input, const std::locale& Loc=std::locale() )
Seq rtrim( const Seq& Input, const std::locale& Loc=std::locale() )
Seq& rtrim_in( Seq& Input, const std::locale& Loc=std::locale() )
Seq trim( const Seq& Input, const std::locale& Loc=std::locale() )
Seq& trim_in( Seq& Input, const std::locale& Loc=std::locale() )
Case conversion:
Seq tolower( const Seq& Input, const std::locale& Loc=std::locale() )
Seq& tolower_in( Seq& Input, const std::locale& Loc=std::locale() )
Seq toupper( const Seq& Input, const std::locale& Loc=std::locale() )
Seq& toupper_in( Seq& Input, const std::locale& Loc=std::locale() )
Predicates:
bool start_with(
InputIterator Begin, InputIterator End,
SubIterator SubBegin, SubIterator SubEnd,
BinaryPredicate Comp )
bool start_with( const Seq1& Input, const Seq2& Prefix, BinaryPredicate Comp )
bool end_with( const Seq1& Input, const Seq2& Prefix, BinaryPredicate Comp )
bool contains( const Seq1& Input, const Seq2& Prefix, BinaryPredicate Comp )
Find-Replace:
std::pair<InputIterator,InputIterator> find(
InputIterator Begin, InputIterator End,
SubIterator SubBegin, SubIterator SubEnd,
BinaryPredicate Comp )
std::pair<typename Seq1::const_iterator, typename Seq1::const_iterator> find_first(
const Seq1& Input,
const Seq2& Substr,
BinaryPredicate Comp )
std::pair<typename Seq1::iterator, typename Seq1::iterator> find_first(
Seq1& Input,
const Seq2& Substr,
BinaryPredicate Comp )
std::pair<typename Seq1::const_iterator, typename Seq1::const_iterator> find_last(
const Seq1& Input,
const Seq2& Substr,
BinaryPredicate Comp )
std::pair<typename Seq1::iterator, typename Seq1::iterator> find_last(
Seq1& Input,
const Seq2& Substr,
BinaryPredicate Comp )
typename InputSeq::iterator replace_substr(
InputSeq& Input,
typename InputSeq::iterator From,
typename InputSeq::iterator To,
ReplSeq& Repl )
void replace_first(
InputIterator Begin, InputIterator End,
MatchIterator MatchBegin, MatchIterator MatchEnd,
ReplIterator ReplBegin, ReplIterator ReplEnd,
OutputIterator Output,
BinaryPredicate Comp )
InputSeq replace_first(
const InputSeq& Input,
const MatchSeq& Match,
const ReplSeq& Repl,
BinaryPredicate Comp )
InputSeq& replace_first_in(
InputSeq& Input,
const MatchSeq& Match,
const ReplSeq& Repl,
BinaryPredicate Comp )
InputSeq& replace_first_in(
InputSeq& Input,
const MatchSeq& Match,
const ReplSeq& Repl )
void replace_all(
InputIterator Begin, InputIterator End,
MatchIterator MatchBegin, MatchIterator MatchEnd,
ReplIterator ReplBegin, ReplIterator ReplEnd,
OutputIterator Output,
BinaryPredicate Comp )
InputSeq replace_all(
const InputSeq& Input,
const MatchSeq& Match,
const ReplSeq& Repl,
BinaryPredicate Comp )
InputSeq& replace_all_in(
InputSeq& Input,
const MatchSeq& Match,
const ReplSeq& Repl,
BinaryPredicate Comp )
void erase_first(
InputIterator Begin, InputIterator End,
MatchIterator MatchBegin, MatchIterator MatchEnd,
OutputIterator Output,
BinaryPredicate Comp )
InputSeq erase_first(
const InputSeq& Input,
const MatchSeq& Match,
BinaryPredicate Comp )
InputSeq& erase_first_in(
InputSeq& Input,
const MatchSeq& Match,
BinaryPredicate Comp )
void erase_all(
InputIterator Begin, InputIterator End,
MatchIterator MatchBegin, MatchIterator MatchEnd,
OutputIterator Output,
BinaryPredicate Comp )
InputSeq erase_all(
const InputSeq& Input,
const MatchSeq& Match,
BinaryPredicate Comp )
InputSeq& erase_all_in(
InputSeq& Input,
const MatchSeq& Match,
BinaryPredicate Comp )
Regards,
Pavol Droba
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk