I want to make an input stream parser capable of handling input in any of the following forms:

x y z
x,y,z
x, y, z
(x,y,z)
(x, y, z)

Is there a clever way to do this? Or do I have to check the first character, if it is '(' then do one thing, if it is not then read a double, then check if the next character is a ',', etc etc.

Is there a robust way to handle these types of inputs?

Thanks,
Dave

Recommended Answers

All 2 Replies

Simple: Take the input as a string. Then parse it to perform the desire operation.

I want to make an input stream parser capable of handling input in any of the following forms:

x y z
x,y,z
x, y, z
(x,y,z)
(x, y, z)

Is there a clever way to do this? Or do I have to check the first character, if it is '(' then do one thing, if it is not then read a double, then check if the next character is a ',', etc etc.

Is there a robust way to handle these types of inputs?

Of course, there is a robust way...
That's it:

I have to check the first character, if it is '(' then do one thing, if it is not then read a double, then check if the next character is a ',', etc etc.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.