"in*****@gmail.com" <in*****@gmail.com> writes:
Randy wrote: How do you do this? getline() *extracts* the characters. peek()
only reads a character at a time. Sure would be nice to have
a "peekline()".
What do you need it for?
Hi Andre,
Thanks for your response.
I'm creating a set of classes for some functions that require
lots of parameters. A simple, human-readable and -controllable
way to do this is to overload the inserter and extractor
operators to report and control these parameters as
property/value pairs, e.g., "ParameterA=value1".
The idea is to feed a list of property/value pairs to the top-level
class, have his extractor interpret and set the properties that
pertain to it (and ignore those that don't), then pass the entire set
to the child classes, the children to their grandchildren, etc.
(speaking hierarchically and/or inheritance-wise).
So, I need to operate on an istream without wasting the
string (or stream) in it.
An alternative approach would be to something like this:
void peekline( ifstream & is, string & s )
{
streampos sp = is.tellg();
getline( is, s );
is.seekg( sp );
}
Yes, that would seem to work. Thanks for the hint. I'm amazed that
this type of function built into the class.
--
% Randy Yates % "...the answer lies within your soul
%% Fuquay-Varina, NC % 'cause no one knows which side
%%% 919-577-9882 % the coin will fall."
%%%% <ya***@ieee.org> % 'Big Wheels', *Out of the Blue*, ELO
http://home.earthlink.net/~yatescr