I'm currently trying to split up a text file into a vector of strings whenever a newline is encountered. Previously I have used boost tokenizer to do this with other delimiter characters but when I use the newline '\n' it throws an exception at runtime:
terminate called after throwing an instance of 'boost::escaped_list_error'
what(): unknown escape sequence
Aborted
Here's the code:
std::vector<std::string> parse_lines(const std::string& input_str){
using namespace boost;
std::vector<std::string> parsed;
tokenizer<escaped_list_separator<char> > tk(input_str, escaped_list_separator<char>('\n'));
for (tokenizer<escaped_list_separator<char> >::iterator i(tk3.begin());
i != tk.end(); ++i)
{
parsed.push_back(*i);
}
return parsed;
}
Any advice greatly appreciated!