[Boost] boost: string_algo details 3 -- simple application of Finder

Source: Internet
Author: User

My blog cannot be updated because I have been ill for many days. .
The Finder is an imitation function used to search any part of a container. It cannot be used independently. The search result is given in the form of an iterator_range that limits the selected part. Common functions
Find,
Find_format, find_format_copy,
Find_format_all, find_format_all_copy
Find_iterator factory method: make_find_iterator, make_split_iterator
Find_iterator constructor: find_iterator, split_iterator
Iter_find, iter_split

namespace boost {  namespace algorithm {    template<typename RangeT, typename FinderT>      iterator_range< typename range_iterator< RangeT >::type >      find(RangeT &, const FinderT &);  }}template<typename SequenceT, typename FinderT, typename FormatterT>  void find_format(SequenceT & Input, FinderT Finder, FormatterT 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);  }}template<typename SequenceT, typename FinderT, typename FormatterT>  void find_format_all(SequenceT & Input, FinderT Finder, FormatterT Formatter);template<typename OutputIteratorT, typename RangeT, typename FinderT, typename FormatterT>  OutputIteratorT  find_format_all_copy(OutputIteratorT Output, const RangeT & Input,                        FinderT Finder, FormatterT Formatter);                       template<typename SequenceT, typename FinderT, typename FormatterT>  SequenceT   find_format_all_copy(const SequenceT & Input, FinderT Finder,                       FormatterT Formatter);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);  }}template<typename IteratorT>class find_iterator {public:  // construct/copy/destruct  find_iterator();  find_iterator(const find_iterator &);  template<typename FinderT> find_iterator(IteratorT, IteratorT, FinderT);  template<typename FinderT, typename RangeT> find_iterator(RangeT &, FinderT);  // public member functions  bool eof() const;  // private member functions  const match_type & dereference() const;  void increment();  bool equal(const find_iterator &) const;};template<typename IteratorT>class split_iterator {public:  // construct/copy/destruct  split_iterator();  split_iterator(const split_iterator &);  template<typename FinderT> split_iterator(IteratorT, IteratorT, FinderT);  template<typename FinderT, typename RangeT>    split_iterator(RangeT &, FinderT);  // public member functions  bool eof() const;  // private member functions  const match_type & dereference() const;  void increment();  bool equal(const split_iterator &) const;};template<typename SequenceSequenceT, typename RangeT, typename FinderT>  SequenceSequenceT &  iter_find(SequenceSequenceT & Result, RangeT & Input, FinderT Finder);template<typename SequenceSequenceT, typename RangeT, typename FinderT>  SequenceSequenceT &  iter_split(SequenceSequenceT & Result, RangeT & Input, FinderT Finder);

Examples used on find_iterator and split_iterator

Void test_string_finder () {using namespace boost; // use STD: String strsrc1 = "this is a chair, and that is a desk in the find function. "; iterator_range <STD: String: iterator> ir = find (strsrc1, first_finder (" is "); // make_find_iterator, find_iteratorfind_iterator <STD: String :: iterator> fi1 = make_find_iterator (strsrc1, first_finder ("is"); find_iterator <STD: String: iterator> fi2 = find_iterator <STD: String: iterator Tor> (strsrc1, first_finder ("is"); // There are three isfor (fi1 ;! Fi1.eof (); ++ fi1) {STD: cout <* fi1 <STD: Endl;} // make_split_iterator, split_iteratorsplit_iterator <STD: String :: iterator> Si1 = make_split_iterator (strsrc1, first_finder ("is"); split_iterator <STD: String: iterator> I2 = split_iterator <STD: String :: iterator> (strsrc1, first_finder ("is"); For (Si1 ;! Si1.eof (); ++ Si1) {STD: String STR = copy_range <STD: String> (* Si1); STD: cout <* Si1 <": "<Str. length () <STD: Endl ;}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.