#include <string>
#include <iostream>
using std::cout;
using std::string;
#include <boost/tokenizer.hpp>
using boost::tokenizer;
using boost::escaped_list_separator;
typedef tokenizer<escaped_list_separator<char> > so_tokenizer;
int main()
{
string s("command_name first_argument "
"\"Second argument which is a quoted string.\"");
so_tokenizer tok(s, escaped_list_separator<char>('\\', ' ', '\"'));
for(so_tokenizer::iterator beg=tok.begin(); beg!=tok.end(); ++beg)
{
cout << *beg << "\n";
}
return 0;
}
I2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBzdGQ6OmNvdXQ7CnVzaW5nIHN0ZDo6c3RyaW5nOwoKI2luY2x1ZGUgPGJvb3N0L3Rva2VuaXplci5ocHA+CnVzaW5nIGJvb3N0Ojp0b2tlbml6ZXI7CnVzaW5nIGJvb3N0Ojplc2NhcGVkX2xpc3Rfc2VwYXJhdG9yOwoKdHlwZWRlZiB0b2tlbml6ZXI8ZXNjYXBlZF9saXN0X3NlcGFyYXRvcjxjaGFyPiA+IHNvX3Rva2VuaXplcjsKCmludCBtYWluKCkKewogICAgc3RyaW5nIHMoImNvbW1hbmRfbmFtZSBmaXJzdF9hcmd1bWVudCAiCiAgICAgICAgICAgICAiXCJTZWNvbmQgYXJndW1lbnQgd2hpY2ggaXMgYSBxdW90ZWQgc3RyaW5nLlwiIik7CgogICAgc29fdG9rZW5pemVyIHRvayhzLCBlc2NhcGVkX2xpc3Rfc2VwYXJhdG9yPGNoYXI+KCdcXCcsICcgJywgJ1wiJykpOwogICAgZm9yKHNvX3Rva2VuaXplcjo6aXRlcmF0b3IgYmVnPXRvay5iZWdpbigpOyBiZWchPXRvay5lbmQoKTsgKytiZWcpCiAgICB7CiAgICAgICAgY291dCA8PCAqYmVnIDw8ICJcbiI7CiAgICB9CgogICAgcmV0dXJuIDA7Cn0K