Boost logo

Boost Users :

Subject: [Boost-users] Matching constant input with input streams
From: Eugene Wee (crystalrecursion_at_[hidden])
Date: 2009-04-06 17:17:14


Hi,

A fellow user on an online forum that I frequent asked about the use of C++
input streams to replace the use of scanf() and family where the format
string included constant portions, e.g., the "a=" in "a=%d". The answer was
to read the input as a string and then parse it. Another user chimed in to
say that he preferred sscanf() for this reason, and that C++ input streams
would be more useful if such constant portions could be easily matched.

I wrote a manipulator that did just that as a proof of concept, but now I
wonder if Boost already provides such a manipulator, or if say, Boost.Spirit
with its file_iterator is deemed as the right solution. There certainly
seems to be a trade-off between these two choices: a manipulator would be a
simple add-on to existing standard library functionality, but Boost.Spirit
is much more powerful.

Thank you,
Eugene Wee



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net