![]() |
Home | Libraries | People | FAQ | More |
string_algo 庫的累積包含文件
定義序列大小寫轉換算法。該算法使用所提供的區域設置將輸入序列中的每一個元素轉換為所希望的大小寫。
namespace boost { namespace algorithm { template<typename OutputIteratorT, typename RangeT> OutputIteratorT to_lower_copy(OutputIteratorT, const RangeT &, const std::locale & = std::locale()); template<typename SequenceT> SequenceT to_lower_copy(const SequenceT &, const std::locale & = std::locale()); template<typename WritableRangeT> void to_lower(WritableRangeT &, const std::locale & = std::locale()); template<typename OutputIteratorT, typename RangeT> OutputIteratorT to_upper_copy(OutputIteratorT, const RangeT &, const std::locale & = std::locale()); template<typename SequenceT> SequenceT to_upper_copy(const SequenceT &, const std::locale & = std::locale()); template<typename WritableRangeT> void to_upper(WritableRangeT &, const std::locale & = std::locale()); } }
包括在本庫中的分類判斷式在使用類似 trim() 和 all() 這樣的算法時將提供更多的便利。它們將 STL 分類函數的機能(比如 std::isspace())包裝成通用的仿函數。
namespace boost { namespace algorithm { unspecified is_classified(std::ctype_base::mask, const std::locale & = std::locale()); unspecified is_space(const std::locale & = std::locale()); unspecified is_alnum(const std::locale & = std::locale()); unspecified is_alpha(const std::locale & = std::locale()); unspecified is_cntrl(const std::locale & = std::locale()); unspecified is_digit(const std::locale & = std::locale()); unspecified is_graph(const std::locale & = std::locale()); unspecified is_lower(const std::locale & = std::locale()); unspecified is_print(const std::locale & = std::locale()); unspecified is_punct(const std::locale & = std::locale()); unspecified is_upper(const std::locale & = std::locale()); unspecified is_xdigit(const std::locale & = std::locale()); template<typename RangeT> unspecified is_any_of(const RangeT &); template<typename CharT> unspecified is_from_range(CharT, CharT); template<typename Pred1T, typename Pred2T> unspecified operator&&(const predicate_facade< Pred1T > &, const predicate_facade< Pred2T > &); template<typename Pred1T, typename Pred2T> unspecified operator||(const predicate_facade< Pred1T > &, const predicate_facade< Pred2T > &); template<typename PredT> unspecified operator!(const predicate_facade< PredT > &); } }
定義元素比較判斷式。本庫中的很多算法可以持有一個額外的參數和一個用於比較元素的判斷式。這就使得,比如說,算法的大小寫無關版本成為可能。
namespace boost { namespace algorithm { struct is_equal; struct is_iequal; struct is_less; struct is_iless; struct is_not_greater; struct is_not_igreater; } }
定義 string_algo 庫中用到的概念
namespace boost { namespace algorithm { template<typename FinderT, typename IteratorT> struct FinderConcept; template<typename FormatterT, typename FinderT, typename IteratorT> struct FormatterConcept; } }
namespace boost { namespace algorithm { enum token_compress_mode_type; } }
定義各種刪除算法。每一個算法根據搜索條件移除輸入的一個或若干個部分。
namespace boost { namespace algorithm { template<typename OutputIteratorT, typename RangeT> OutputIteratorT erase_range_copy(OutputIteratorT, const RangeT &, const iterator_range< typename range_const_iterator< RangeT >::type > &); template<typename SequenceT> SequenceT erase_range_copy(const SequenceT &, const iterator_range< typename range_const_iterator< SequenceT >::type > &); template<typename SequenceT> void erase_range(SequenceT &, const iterator_range< typename range_iterator< SequenceT >::type > &); template<typename OutputIteratorT, typename Range1T, typename Range2T> OutputIteratorT erase_first_copy(OutputIteratorT, const Range1T &, const Range2T &); template<typename SequenceT, typename RangeT> SequenceT erase_first_copy(const SequenceT &, const RangeT &); template<typename SequenceT, typename RangeT> void erase_first(SequenceT &, const RangeT &); template<typename OutputIteratorT, typename Range1T, typename Range2T> OutputIteratorT ierase_first_copy(OutputIteratorT, const Range1T &, const Range2T &, const std::locale & = std::locale()); template<typename SequenceT, typename RangeT> SequenceT ierase_first_copy(const SequenceT &, const RangeT &, const std::locale & = std::locale()); template<typename SequenceT, typename RangeT> void ierase_first(SequenceT &, const RangeT &, const std::locale & = std::locale()); template<typename OutputIteratorT, typename Range1T, typename Range2T> OutputIteratorT erase_last_copy(OutputIteratorT, const Range1T &, const Range2T &); template<typename SequenceT, typename RangeT> SequenceT erase_last_copy(const SequenceT &, const RangeT &); template<typename SequenceT, typename RangeT> void erase_last(SequenceT &, const RangeT &); template<typename OutputIteratorT, typename Range1T, typename Range2T> OutputIteratorT ierase_last_copy(OutputIteratorT, const Range1T &, const Range2T &, const std::locale & = std::locale()); template<typename SequenceT, typename RangeT> SequenceT ierase_last_copy(const SequenceT &, const RangeT &, const std::locale & = std::locale()); template<typename SequenceT, typename RangeT> void ierase_last(SequenceT &, const RangeT &, const std::locale & = std::locale()); template<typename OutputIteratorT, typename Range1T, typename Range2T> OutputIteratorT erase_nth_copy(OutputIteratorT, const Range1T &, const Range2T &, int); template<typename SequenceT, typename RangeT> SequenceT erase_nth_copy(const SequenceT &, const RangeT &, int); template<typename SequenceT, typename RangeT> void erase_nth(SequenceT &, const RangeT &, int); template<typename OutputIteratorT, typename Range1T, typename Range2T> OutputIteratorT ierase_nth_copy(OutputIteratorT, const Range1T &, const Range2T &, int, const std::locale & = std::locale()); template<typename SequenceT, typename RangeT> SequenceT ierase_nth_copy(const SequenceT &, const RangeT &, int, const std::locale & = std::locale()); template<typename SequenceT, typename RangeT> void ierase_nth(SequenceT &, const RangeT &, int, const std::locale & = std::locale()); template<typename OutputIteratorT, typename Range1T, typename Range2T> OutputIteratorT erase_all_copy(OutputIteratorT, const Range1T &, const Range2T &); template<typename SequenceT, typename RangeT> SequenceT erase_all_copy(const SequenceT &, const RangeT &); template<typename SequenceT, typename RangeT> void erase_all(SequenceT &, const RangeT &); template<typename OutputIteratorT, typename Range1T, typename Range2T> OutputIteratorT ierase_all_copy(OutputIteratorT, const Range1T &, const Range2T &, const std::locale & = std::locale()); template<typename SequenceT, typename RangeT> SequenceT ierase_all_copy(const SequenceT &, const RangeT &, const std::locale & = std::locale()); template<typename SequenceT, typename RangeT> void ierase_all(SequenceT &, const RangeT &, const std::locale & = std::locale()); template<typename OutputIteratorT, typename RangeT> OutputIteratorT erase_head_copy(OutputIteratorT, const RangeT &, int); template<typename SequenceT> SequenceT erase_head_copy(const SequenceT &, int); template<typename SequenceT> void erase_head(SequenceT &, int); template<typename OutputIteratorT, typename RangeT> OutputIteratorT erase_tail_copy(OutputIteratorT, const RangeT &, int); template<typename SequenceT> SequenceT erase_tail_copy(const SequenceT &, int); template<typename SequenceT> void erase_tail(SequenceT &, int); } }
定義一套查找算法。這些算法在輸入中搜索一個 substring。結果以限定這個 substring 的 iterator_range 的形式給出。
namespace boost { namespace algorithm { template<typename RangeT, typename FinderT> iterator_range< typename range_iterator< RangeT >::type > find(RangeT &, const FinderT &); template<typename Range1T, typename Range2T> iterator_range< typename range_iterator< Range1T >::type > find_first(Range1T &, const Range2T &); template<typename Range1T, typename Range2T> iterator_range< typename range_iterator< Range1T >::type > ifind_first(Range1T &, const Range2T &, const std::locale & = std::locale()); template<typename Range1T, typename Range2T> iterator_range< typename range_iterator< Range1T >::type > find_last(Range1T &, const Range2T &); template<typename Range1T, typename Range2T> iterator_range< typename range_iterator< Range1T >::type > ifind_last(Range1T &, const Range2T &, const std::locale & = std::locale()); template<typename Range1T, typename Range2T> iterator_range< typename range_iterator< Range1T >::type > find_nth(Range1T &, const Range2T &, int); template<typename Range1T, typename Range2T> iterator_range< typename range_iterator< Range1T >::type > ifind_nth(Range1T &, const Range2T &, int, const std::locale & = std::locale()); template<typename RangeT> iterator_range< typename range_iterator< RangeT >::type > find_head(RangeT &, int); template<typename RangeT> iterator_range< typename range_iterator< RangeT >::type > find_tail(RangeT &, int); template<typename RangeT, typename PredicateT> iterator_range< typename range_iterator< RangeT >::type > find_token(RangeT &, PredicateT, token_compress_mode_type = token_compress_off); } }
定義通用的替換算法。每一個算法替換輸入的一個或若干個部分。被替換的部分由一個 Finder 對像查找。隨後,找到的結果被 Formatter 對像使用而發生替換。
namespace boost { namespace algorithm { template<typename OutputIteratorT, typename RangeT, typename FinderT, typename FormatterT> OutputIteratorT find_format_copy(OutputIteratorT, const RangeT &, FinderT, FormatterT); template<typename SequenceT, typename FinderT, typename FormatterT> SequenceT find_format_copy(const SequenceT &, FinderT, FormatterT); template<typename SequenceT, typename FinderT, typename FormatterT> void find_format(SequenceT &, FinderT, FormatterT); template<typename OutputIteratorT, typename RangeT, typename FinderT, typename FormatterT> OutputIteratorT find_format_all_copy(OutputIteratorT, const RangeT &, FinderT, FormatterT); template<typename SequenceT, typename FinderT, typename FormatterT> SequenceT find_format_all_copy(const SequenceT &, FinderT, FormatterT); template<typename SequenceT, typename FinderT, typename FormatterT> void find_format_all(SequenceT &, FinderT, FormatterT); } }
定義查找迭代器類。查找迭代器反覆應用一個 Finder 到指定輸入 string 中搜索匹配項。根據所使用的迭代器,解引用這個迭代器會得到當前匹配項或在末尾與當前匹配項之間的 range。
namespace boost { namespace algorithm { template<typename IteratorT> class find_iterator; template<typename IteratorT> class split_iterator; template<typename RangeT, typename FinderT> find_iterator< typename range_iterator< RangeT >::type > make_find_iterator(RangeT &, FinderT); template<typename RangeT, typename FinderT> split_iterator< typename range_iterator< RangeT >::type > make_split_iterator(RangeT &, FinderT); } }
定義 Finder 生成器。Finder 對象是一個能夠在輸入中找到與指定規則匹配的 substring 的仿函數。Finders 通常用作替換,查找和分割部件的可插入組件。這個頭文件包含本庫提供的 Finder 的生成器函數。
namespace boost { namespace algorithm { template<typename RangeT> unspecified first_finder(const RangeT &); template<typename RangeT, typename PredicateT> unspecified first_finder(const RangeT &, PredicateT); template<typename RangeT> unspecified last_finder(const RangeT &); template<typename RangeT, typename PredicateT> unspecified last_finder(const RangeT &, PredicateT); template<typename RangeT> unspecified nth_finder(const RangeT &, int); template<typename RangeT, typename PredicateT> unspecified nth_finder(const RangeT &, int, PredicateT); unspecified head_finder(int); unspecified tail_finder(int); template<typename PredicateT> unspecified token_finder(PredicateT, token_compress_mode_type = token_compress_off); template<typename ForwardIteratorT> unspecified range_finder(ForwardIteratorT, ForwardIteratorT); template<typename ForwardIteratorT> unspecified range_finder(iterator_range< ForwardIteratorT >); } }
定義 Formatter 生成器。Formatter 是一個根據給定參數格式化一個 string 的仿函數。Formatter 總是和 Finder 協力工作。Finder 能為特定的 Formatter 提供額外信息。這種合作的一個例子就是 regex_finder 和 regex_formatter。
Formatters 通常用作替換部件的可插入組件。這個頭文件包含本庫提供的 Formatters 的生成器函數。
namespace boost { namespace algorithm { template<typename RangeT> unspecified const_formatter(const RangeT &); template<typename RangeT> unspecified identity_formatter(); template<typename RangeT> unspecified empty_formatter(const RangeT &); } }
定義通用的分割算法。分割算法用來將一個序列根據給定規則分為若干個部分。結果以「容器的容器」的方式給出,它的元素是選取部分的拷貝或引用。
提供連個算法。一個迭代遍歷匹配的 substring,另一個遍歷這些匹配項之間的間隔。
namespace boost { namespace algorithm { template<typename SequenceSequenceT, typename RangeT, typename FinderT> SequenceSequenceT & iter_find(SequenceSequenceT &, RangeT &, FinderT); template<typename SequenceSequenceT, typename RangeT, typename FinderT> SequenceSequenceT & iter_split(SequenceSequenceT &, RangeT &, FinderT); } }
定義結合算法。
結合算法與分割算法相反。它將來自於一個 'list' 的 strings 連接在一起,並加入用戶定義的分隔符。另外,還有一個版本,可以根據給定的判斷式進行簡單的過濾。
namespace boost { namespace algorithm { template<typename SequenceSequenceT, typename Range1T> range_value< SequenceSequenceT >::type join(const SequenceSequenceT &, const Range1T &); template<typename SequenceSequenceT, typename Range1T, typename PredicateT> range_value< SequenceSequenceT >::type join_if(const SequenceSequenceT &, const Range1T &, PredicateT); } }
定義 string 相關的判斷式。判斷式用於判定在各種條件下,一個 substring 是否包含於輸入 string,條件為:一個 string 以這個 substring 開始,以這個 substring 結尾,直接包含這個 substring 以及兩個 string 是否相等。另外,算法 all() 檢查一個容器中的所有元素是否滿足一個條件。
所有的判斷式提供強異常保證。
namespace boost { namespace algorithm { template<typename Range1T, typename Range2T, typename PredicateT> bool starts_with(const Range1T &, const Range2T &, PredicateT); template<typename Range1T, typename Range2T> bool starts_with(const Range1T &, const Range2T &); template<typename Range1T, typename Range2T> bool istarts_with(const Range1T &, const Range2T &, const std::locale & = std::locale()); template<typename Range1T, typename Range2T, typename PredicateT> bool ends_with(const Range1T &, const Range2T &, PredicateT); template<typename Range1T, typename Range2T> bool ends_with(const Range1T &, const Range2T &); template<typename Range1T, typename Range2T> bool iends_with(const Range1T &, const Range2T &, const std::locale & = std::locale()); template<typename Range1T, typename Range2T, typename PredicateT> bool contains(const Range1T &, const Range2T &, PredicateT); template<typename Range1T, typename Range2T> bool contains(const Range1T &, const Range2T &); template<typename Range1T, typename Range2T> bool icontains(const Range1T &, const Range2T &, const std::locale & = std::locale()); template<typename Range1T, typename Range2T, typename PredicateT> bool equals(const Range1T &, const Range2T &, PredicateT); template<typename Range1T, typename Range2T> bool equals(const Range1T &, const Range2T &); template<typename Range1T, typename Range2T> bool iequals(const Range1T &, const Range2T &, const std::locale & = std::locale()); template<typename Range1T, typename Range2T, typename PredicateT> bool lexicographical_compare(const Range1T &, const Range2T &, PredicateT); template<typename Range1T, typename Range2T> bool lexicographical_compare(const Range1T &, const Range2T &); template<typename Range1T, typename Range2T> bool ilexicographical_compare(const Range1T &, const Range2T &, const std::locale & = std::locale()); template<typename RangeT, typename PredicateT> bool all(const RangeT &, PredicateT); } }
定義算法的 regex 變體。
namespace boost { namespace algorithm { template<typename RangeT, typename CharT, typename RegexTraitsT> iterator_range< typename range_iterator< RangeT >::type > find_regex(RangeT &, const basic_regex< CharT, RegexTraitsT > &, match_flag_type = match_default); template<typename OutputIteratorT, typename RangeT, typename CharT, typename RegexTraitsT, typename FormatStringTraitsT, typename FormatStringAllocatorT> OutputIteratorT replace_regex_copy(OutputIteratorT, const RangeT &, const basic_regex< CharT, RegexTraitsT > &, const std::basic_string< CharT, FormatStringTraitsT, FormatStringAllocatorT > &, match_flag_type = match_default|format_default); template<typename SequenceT, typename CharT, typename RegexTraitsT, typename FormatStringTraitsT, typename FormatStringAllocatorT> SequenceT replace_regex_copy(const SequenceT &, const basic_regex< CharT, RegexTraitsT > &, const std::basic_string< CharT, FormatStringTraitsT, FormatStringAllocatorT > &, match_flag_type = match_default|format_default); template<typename SequenceT, typename CharT, typename RegexTraitsT, typename FormatStringTraitsT, typename FormatStringAllocatorT> void replace_regex(SequenceT &, const basic_regex< CharT, RegexTraitsT > &, const std::basic_string< CharT, FormatStringTraitsT, FormatStringAllocatorT > &, match_flag_type = match_default|format_default); template<typename OutputIteratorT, typename RangeT, typename CharT, typename RegexTraitsT, typename FormatStringTraitsT, typename FormatStringAllocatorT> OutputIteratorT replace_all_regex_copy(OutputIteratorT, const RangeT &, const basic_regex< CharT, RegexTraitsT > &, const std::basic_string< CharT, FormatStringTraitsT, FormatStringAllocatorT > &, match_flag_type = match_default|format_default); template<typename SequenceT, typename CharT, typename RegexTraitsT, typename FormatStringTraitsT, typename FormatStringAllocatorT> SequenceT replace_all_regex_copy(const SequenceT &, const basic_regex< CharT, RegexTraitsT > &, const std::basic_string< CharT, FormatStringTraitsT, FormatStringAllocatorT > &, match_flag_type = match_default|format_default); template<typename SequenceT, typename CharT, typename RegexTraitsT, typename FormatStringTraitsT, typename FormatStringAllocatorT> void replace_all_regex(SequenceT &, const basic_regex< CharT, RegexTraitsT > &, const std::basic_string< CharT, FormatStringTraitsT, FormatStringAllocatorT > &, match_flag_type = match_default|format_default); template<typename OutputIteratorT, typename RangeT, typename CharT, typename RegexTraitsT> OutputIteratorT erase_regex_copy(OutputIteratorT, const RangeT &, const basic_regex< CharT, RegexTraitsT > &, match_flag_type = match_default); template<typename SequenceT, typename CharT, typename RegexTraitsT> SequenceT erase_regex_copy(const SequenceT &, const basic_regex< CharT, RegexTraitsT > &, match_flag_type = match_default); template<typename SequenceT, typename CharT, typename RegexTraitsT> void erase_regex(SequenceT &, const basic_regex< CharT, RegexTraitsT > &, match_flag_type = match_default); template<typename OutputIteratorT, typename RangeT, typename CharT, typename RegexTraitsT> OutputIteratorT erase_all_regex_copy(OutputIteratorT, const RangeT &, const basic_regex< CharT, RegexTraitsT > &, match_flag_type = match_default); template<typename SequenceT, typename CharT, typename RegexTraitsT> SequenceT erase_all_regex_copy(const SequenceT &, const basic_regex< CharT, RegexTraitsT > &, match_flag_type = match_default); template<typename SequenceT, typename CharT, typename RegexTraitsT> void erase_all_regex(SequenceT &, const basic_regex< CharT, RegexTraitsT > &, match_flag_type = match_default); template<typename SequenceSequenceT, typename RangeT, typename CharT, typename RegexTraitsT> SequenceSequenceT & find_all_regex(SequenceSequenceT &, const RangeT &, const basic_regex< CharT, RegexTraitsT > &, match_flag_type = match_default); template<typename SequenceSequenceT, typename RangeT, typename CharT, typename RegexTraitsT> SequenceSequenceT & split_regex(SequenceSequenceT &, const RangeT &, const basic_regex< CharT, RegexTraitsT > &, match_flag_type = match_default); template<typename SequenceSequenceT, typename Range1T, typename CharT, typename RegexTraitsT> range_value< SequenceSequenceT >::type join_if(const SequenceSequenceT &, const Range1T &, const basic_regex< CharT, RegexTraitsT > &, match_flag_type = match_default); } }
定義 regex_finder 和 regex_formatter 生成器。這兩個函數被設計用來一起工作。regex_formatter 需要使用包含於 regex_finder 搜索結果中的一個匹配項的額外信息。
namespace boost { namespace algorithm { template<typename CharT, typename RegexTraitsT> unspecified regex_finder(const basic_regex< CharT, RegexTraitsT > &, match_flag_type = match_default); template<typename CharT, typename TraitsT, typename AllocT> unspecified regex_formatter(const std::basic_string< CharT, TraitsT, AllocT > &, match_flag_type = format_default); } }
定義各種替換算法。每一個算法根據一套搜索和替換規則替換輸入項的一個或若干個部分。
namespace boost { namespace algorithm { template<typename OutputIteratorT, typename Range1T, typename Range2T> OutputIteratorT replace_range_copy(OutputIteratorT, const Range1T &, const iterator_range< typename range_const_iterator< Range1T >::type > &, const Range2T &); template<typename SequenceT, typename RangeT> SequenceT replace_range_copy(const SequenceT &, const iterator_range< typename range_const_iterator< SequenceT >::type > &, const RangeT &); template<typename SequenceT, typename RangeT> void replace_range(SequenceT &, const iterator_range< typename range_iterator< SequenceT >::type > &, const RangeT &); template<typename OutputIteratorT, typename Range1T, typename Range2T, typename Range3T> OutputIteratorT replace_first_copy(OutputIteratorT, const Range1T &, const Range2T &, const Range3T &); template<typename SequenceT, typename Range1T, typename Range2T> SequenceT replace_first_copy(const SequenceT &, const Range1T &, const Range2T &); template<typename SequenceT, typename Range1T, typename Range2T> void replace_first(SequenceT &, const Range1T &, const Range2T &); template<typename OutputIteratorT, typename Range1T, typename Range2T, typename Range3T> OutputIteratorT ireplace_first_copy(OutputIteratorT, const Range1T &, const Range2T &, const Range3T &, const std::locale & = std::locale()); template<typename SequenceT, typename Range2T, typename Range1T> SequenceT ireplace_first_copy(const SequenceT &, const Range2T &, const Range1T &, const std::locale & = std::locale()); template<typename SequenceT, typename Range1T, typename Range2T> void ireplace_first(SequenceT &, const Range1T &, const Range2T &, const std::locale & = std::locale()); template<typename OutputIteratorT, typename Range1T, typename Range2T, typename Range3T> OutputIteratorT replace_last_copy(OutputIteratorT, const Range1T &, const Range2T &, const Range3T &); template<typename SequenceT, typename Range1T, typename Range2T> SequenceT replace_last_copy(const SequenceT &, const Range1T &, const Range2T &); template<typename SequenceT, typename Range1T, typename Range2T> void replace_last(SequenceT &, const Range1T &, const Range2T &); template<typename OutputIteratorT, typename Range1T, typename Range2T, typename Range3T> OutputIteratorT ireplace_last_copy(OutputIteratorT, const Range1T &, const Range2T &, const Range3T &, const std::locale & = std::locale()); template<typename SequenceT, typename Range1T, typename Range2T> SequenceT ireplace_last_copy(const SequenceT &, const Range1T &, const Range2T &, const std::locale & = std::locale()); template<typename SequenceT, typename Range1T, typename Range2T> void ireplace_last(SequenceT &, const Range1T &, const Range2T &, const std::locale & = std::locale()); template<typename OutputIteratorT, typename Range1T, typename Range2T, typename Range3T> OutputIteratorT replace_nth_copy(OutputIteratorT, const Range1T &, const Range2T &, int, const Range3T &); template<typename SequenceT, typename Range1T, typename Range2T> SequenceT replace_nth_copy(const SequenceT &, const Range1T &, int, const Range2T &); template<typename SequenceT, typename Range1T, typename Range2T> void replace_nth(SequenceT &, const Range1T &, int, const Range2T &); template<typename OutputIteratorT, typename Range1T, typename Range2T, typename Range3T> OutputIteratorT ireplace_nth_copy(OutputIteratorT, const Range1T &, const Range2T &, int, const Range3T &, const std::locale & = std::locale()); template<typename SequenceT, typename Range1T, typename Range2T> SequenceT ireplace_nth_copy(const SequenceT &, const Range1T &, int, const Range2T &, const std::locale & = std::locale()); template<typename SequenceT, typename Range1T, typename Range2T> void ireplace_nth(SequenceT &, const Range1T &, int, const Range2T &, const std::locale & = std::locale()); template<typename OutputIteratorT, typename Range1T, typename Range2T, typename Range3T> OutputIteratorT replace_all_copy(OutputIteratorT, const Range1T &, const Range2T &, const Range3T &); template<typename SequenceT, typename Range1T, typename Range2T> SequenceT replace_all_copy(const SequenceT &, const Range1T &, const Range2T &); template<typename SequenceT, typename Range1T, typename Range2T> void replace_all(SequenceT &, const Range1T &, const Range2T &); template<typename OutputIteratorT, typename Range1T, typename Range2T, typename Range3T> OutputIteratorT ireplace_all_copy(OutputIteratorT, const Range1T &, const Range2T &, const Range3T &, const std::locale & = std::locale()); template<typename SequenceT, typename Range1T, typename Range2T> SequenceT ireplace_all_copy(const SequenceT &, const Range1T &, const Range2T &, const std::locale & = std::locale()); template<typename SequenceT, typename Range1T, typename Range2T> void ireplace_all(SequenceT &, const Range1T &, const Range2T &, const std::locale & = std::locale()); template<typename OutputIteratorT, typename Range1T, typename Range2T> OutputIteratorT replace_head_copy(OutputIteratorT, const Range1T &, int, const Range2T &); template<typename SequenceT, typename RangeT> SequenceT replace_head_copy(const SequenceT &, int, const RangeT &); template<typename SequenceT, typename RangeT> void replace_head(SequenceT &, int, const RangeT &); template<typename OutputIteratorT, typename Range1T, typename Range2T> OutputIteratorT replace_tail_copy(OutputIteratorT, const Range1T &, int, const Range2T &); template<typename SequenceT, typename RangeT> SequenceT replace_tail_copy(const SequenceT &, int, const RangeT &); template<typename SequenceT, typename RangeT> void replace_tail(SequenceT &, int, const RangeT &); } }
定義在這個頭文件中的 traits 被各種不同的算法使用,可以使特定的容器達到更好的性能。traits 缺省提供自動保險。如果一個容器支持這些特性中的某一些,它就有可以為這個容器指定特定的 trait。對於先天不足的編譯器,為一個特定的測試函數定義一個重載也是有可能的。
由於一個語言約束,現在還不可能不包含相應的頭文件就為 stl 容器定義特化。為了減少這種包含的成本,用戶可以為一個特定的容器選擇性地包含一個特化的頭文件。它們位於 boost/algorithm/string/stl 目錄。或者還可以包含 boost/algorithm/string/std_collection_traits.hpp 頭文件,它包含所有 stl 容器的特化。
namespace boost { namespace algorithm { template<typename T> class has_native_replace; template<typename T> class has_stable_iterators; template<typename T> class has_const_time_insert; template<typename T> class has_const_time_erase; } }
定義基本的分割算法。分割算法可以根據給定的規則將一個 string 分為若干個部分。
每一個部分被拷貝並作為一個新的元素加入到輸出容器中。因此結果容器必須能夠持有匹配項(類似於 std::string 這樣的兼容結構)的拷貝或引用(例如,使用迭代器範圍類)。這樣的容器的例子包括 std::vector<std::string> 或 std::list<boost::iterator_range<std::string::iterator>>。
namespace boost { namespace algorithm { template<typename SequenceSequenceT, typename Range1T, typename Range2T> SequenceSequenceT & find_all(SequenceSequenceT &, Range1T &, const Range2T &); template<typename SequenceSequenceT, typename Range1T, typename Range2T> SequenceSequenceT & ifind_all(SequenceSequenceT &, Range1T &, const Range2T &, const std::locale & = std::locale()); template<typename SequenceSequenceT, typename RangeT, typename PredicateT> SequenceSequenceT & split(SequenceSequenceT &, RangeT &, PredicateT, token_compress_mode_type = token_compress_off); } }
這個文件包含 stl 容器的序列特徵。
定義修剪算法。修剪算法用於從序列(string)中移除末尾的和開頭的空格。空格使用給定的地區設置進行識別。
參數化 (_if) 變體使用一個判斷式(仿函數)選擇哪些 characters 要被截斷。函數持有一個選擇判斷式作為一個參數,它用來判定一個 character 是否是一個空格。常用判斷式在 classification.hpp 頭文件中提供。
namespace boost { namespace algorithm { template<typename OutputIteratorT, typename RangeT, typename PredicateT> OutputIteratorT trim_left_copy_if(OutputIteratorT, const RangeT &, PredicateT); template<typename SequenceT, typename PredicateT> SequenceT trim_left_copy_if(const SequenceT &, PredicateT); template<typename SequenceT> SequenceT trim_left_copy(const SequenceT &, const std::locale & = std::locale()); template<typename SequenceT, typename PredicateT> void trim_left_if(SequenceT &, PredicateT); template<typename SequenceT> void trim_left(SequenceT &, const std::locale & = std::locale()); template<typename OutputIteratorT, typename RangeT, typename PredicateT> OutputIteratorT trim_right_copy_if(OutputIteratorT, const RangeT &, PredicateT); template<typename SequenceT, typename PredicateT> SequenceT trim_right_copy_if(const SequenceT &, PredicateT); template<typename SequenceT> SequenceT trim_right_copy(const SequenceT &, const std::locale & = std::locale()); template<typename SequenceT, typename PredicateT> void trim_right_if(SequenceT &, PredicateT); template<typename SequenceT> void trim_right(SequenceT &, const std::locale & = std::locale()); template<typename OutputIteratorT, typename RangeT, typename PredicateT> OutputIteratorT trim_copy_if(OutputIteratorT, const RangeT &, PredicateT); template<typename SequenceT, typename PredicateT> SequenceT trim_copy_if(const SequenceT &, PredicateT); template<typename SequenceT> SequenceT trim_copy(const SequenceT &, const std::locale & = std::locale()); template<typename SequenceT, typename PredicateT> void trim_if(SequenceT &, PredicateT); template<typename SequenceT> void trim(SequenceT &, const std::locale & = std::locale()); } }
string_algo 庫的累積包含文件。在 string.hpp 的基礎上還包含 regex 相關的內容。