• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // (c) Copyright Jeremy Siek 2002.
2 
3 // Distributed under the Boost Software License, Version 1.0. (See
4 // accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 
7 // Sample output:
8 //
9 // <> <> <Hello> <|> <world> <|> <> <|> <> <foo> <> <bar> <yow> <baz> <|> <>
10 
11 // char_sep_example_2.cpp
12 #include <iostream>
13 #include <boost/tokenizer.hpp>
14 #include <string>
15 
main()16 int main()
17 {
18   std::string str = ";;Hello|world||-foo--bar;yow;baz|";
19 
20   typedef boost::tokenizer<boost::char_separator<char> >
21     tokenizer;
22   boost::char_separator<char> sep("-;", "|", boost::keep_empty_tokens);
23   tokenizer tokens(str, sep);
24   for (tokenizer::iterator tok_iter = tokens.begin();
25        tok_iter != tokens.end(); ++tok_iter)
26     std::cout << "<" << *tok_iter << "> ";
27   std::cout << "\n";
28   return EXIT_SUCCESS;
29 }
30