tokenizer.cc
Go to the documentation of this file.
00001 #include <iostream>
00002 #include <string>
00003 #include <vector>
00004 
00005 #include <boost/bind.hpp>
00006 #include <boost/function.hpp>
00007 #include <boost/algorithm/string.hpp>
00008 #include <boost/foreach.hpp>
00009 
00010 void
00011 _delimeter_tokenizer (std::string &data, std::vector<std::string> &tokens,
00012                       std::string delimeter)
00013 {
00014   boost::split(tokens, data, boost::is_any_of(delimeter));
00015 }
00016 
00017 typedef boost::function<void(std::string&,std::vector<std::string>&)> TokenizerType;
00018 
00019 int main(void) {
00020   std::string data = "a\rb\rc\r";
00021   std::vector<std::string> tokens;
00022   std::string delimeter = "\r";
00023   
00024   TokenizerType f = boost::bind(_delimeter_tokenizer, _1, _2, delimeter);
00025   f(data, tokens);
00026   
00027   BOOST_FOREACH(std::string token, tokens)
00028     std::cout << token << std::endl;
00029   
00030   return 0;
00031 }


serial
Author(s): William Woodall , John Harrison
autogenerated on Sat Jan 21 2017 03:55:47