fork(74) download
  1. #include <string>
  2. #include <iostream>
  3. using std::cout;
  4. using std::string;
  5.  
  6. #include <boost/tokenizer.hpp>
  7. using boost::tokenizer;
  8. using boost::escaped_list_separator;
  9.  
  10. typedef tokenizer<escaped_list_separator<char> > so_tokenizer;
  11.  
  12. int main()
  13. {
  14. string s("command_name first_argument "
  15. "\"Second argument which is a quoted string.\"");
  16.  
  17. so_tokenizer tok(s, escaped_list_separator<char>('\\', ' ', '\"'));
  18. for(so_tokenizer::iterator beg=tok.begin(); beg!=tok.end(); ++beg)
  19. {
  20. cout << *beg << "\n";
  21. }
  22.  
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0.01s 2864KB
stdin
Standard input is empty
stdout
command_name
first_argument
Second argument which is a quoted string.