E
erikjalevik
I have a long string of quoted strings, like:
"string 1" "string 2" ...
and I need to split this up into the constituent quoted strings. I was
thinking it would be nice if I could somehow put it in an istringstream
and use operator>> to parse quoted strings instead of
whitespace-separated strings. Would it be at all possible to use a
manipulator for this? So that I could write:
is >> quoted >> s1;
is >> quoted >> s2;
and have s1 contain "string 1" and s2 "string 2". quoted() could easily
be implemented to read everything between the quotes, but I can't see a
way for it to hand over the parsed string to the s1 following it. Is it
possible to do this?
(I don't want to have to subclass string just to override its
operator>>. That seems wrong.)
Thanks,
Erik
"string 1" "string 2" ...
and I need to split this up into the constituent quoted strings. I was
thinking it would be nice if I could somehow put it in an istringstream
and use operator>> to parse quoted strings instead of
whitespace-separated strings. Would it be at all possible to use a
manipulator for this? So that I could write:
is >> quoted >> s1;
is >> quoted >> s2;
and have s1 contain "string 1" and s2 "string 2". quoted() could easily
be implemented to read everything between the quotes, but I can't see a
way for it to hand over the parsed string to the s1 following it. Is it
possible to do this?
(I don't want to have to subclass string just to override its
operator>>. That seems wrong.)
Thanks,
Erik