Ticket #2774: token.cpp

File token.cpp, 567 bytes (added by grumbel@…, 14 years ago)

Tokenizer Example

Line 
1#include <iostream>
2#include <boost/tokenizer.hpp>
3
4int main(int argc, char** argv)
5{
6 if (argc != 2)
7 {
8 std::cout << "Usage: " << argv[0] << " STRING" << std::endl;
9 }
10 else
11 {
12 boost::char_separator<char> sep(":", "", boost::keep_empty_tokens);
13 typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
14
15 tokenizer tokens(std::string(argv[1]), sep);
16 for(tokenizer::iterator i = tokens.begin(); i != tokens.end(); ++i)
17 {
18 std::cout << "Token: '" << *i << "'" << std::endl;
19 }
20 }
21}
22
23/* EOF */