Y
Y. H.
Hi,
I'm having the following problem. I'm trying to write a simple parser
for a script that looks like this:
<command> [<arg-1>], [<arg-2>], [<arg-3>], ...
Giving an argument is optional. If it's not present (meaning there are 2
commans in a row) we take a default value.
Naturally, I'm using an istream to parse each line.
My question is this: is there a way to make a seperation between spaces
and delimiters? The thing is,
that because I have commas between each argument, I want the comma to be
the delimiter, but I still
want to ignore the spaces.
The only two ways I know is either to use getline with ',' as a
delimiter - but that wouldn't ignore spaces.
The other is to write your own facet class which sets ',' as a space. -
but then after reading the first comma,
if there's another comma straight after it - the stream will read on -
taking it as a white space, instead of treating
it as a delimiter and stop there.
Any ideas?
Thanks,
Yaron
I'm having the following problem. I'm trying to write a simple parser
for a script that looks like this:
<command> [<arg-1>], [<arg-2>], [<arg-3>], ...
Giving an argument is optional. If it's not present (meaning there are 2
commans in a row) we take a default value.
Naturally, I'm using an istream to parse each line.
My question is this: is there a way to make a seperation between spaces
and delimiters? The thing is,
that because I have commas between each argument, I want the comma to be
the delimiter, but I still
want to ignore the spaces.
The only two ways I know is either to use getline with ',' as a
delimiter - but that wouldn't ignore spaces.
The other is to write your own facet class which sets ',' as a space. -
but then after reading the first comma,
if there's another comma straight after it - the stream will read on -
taking it as a white space, instead of treating
it as a delimiter and stop there.
Any ideas?
Thanks,
Yaron