delimited string to vector

I'm reading in a line of a text file using realine. The string contains values delimited by a single quote ('). The number of values varies so I don't know how many tokens are in each line. I need to put the values into the elements of a vector or array. I was going to use a vector because the size can shrink or grow. In Perl I can just use split to split a scalar into an array. I'm looking for a quick and efficient way to do this instead of writing my own code to parse the string myself. Is there an easy way to do this?
// Assume textLine contains the line of text to parse.
string textLine;
vector<string> tokens;

size_t pos = 0;
while( true ) {
size_t nextPos = textLine.find( pos, '\'' );
if( nextPos == textLine.npos )
break;
tokens.push_back( string( textLine.substr( pos, nextPos - pos ) ) );
pos = nextPos + 1;
}

Didn't check this for compilation, but the general algorithm should be ok.
Topic archived. No new replies allowed.