Article View: comp.std.c++
Article #2887Re: streambuf derivation error or bug in istream::getline?
From: Christopher Barber
Date: Wed, 06 Dec 1995 22:26
Date: Wed, 06 Dec 1995 22:26
34 lines
2435 bytes
2435 bytes
>>>>> "CB" == Christopher Barber <cbarber@bbn.com>:
>>>>> "BE" == Bernd Eggink <admin@rzaix13.uni-hamburg.de>:
CB> I have derived a new class from streambuf and overloaded most of the
CB> virtual protected members (overflow, underflow, xsgetn, xsputn, etc)
CB> but do not touch the stream pointer methods (setg, gbump, setp, etc)
CB> and as far as I understand the standard I don't need to.
BE> You MUST call setp() and segp() from within your functions
BE> overflow() and underflow() in order to set up the put/get area and
BE> reflect the fact that the put area is now empty and ready to be
BE> filled again, rsp. that the get area has been filled from the
BE> source and characters may now be extracted.
Creating a single character get area and pointing the get pointers fixed my
problem. I can see why this is necessary for reads since a successful
return from underflow() essentially implies that gnext is valid.
However, in the case of writes, I see no reason that one is required to
call setp(). As far as I can see, there are no functions that guarantee
that there will be a position available in the put buffer. So if you never
call setp(), the pointers will always be null and ostream routines will
just keep calling overflow() or xsputn(). Once again, have I overlooked
something in the standard?
- Chris
--
Christopher Barber Software Engineer BBN, Systems and Technologies
mailto:cbarber@bbn.com http://malachite.bbn.com/~cbarber (within bbn)
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<CBARBER.95Dec6171211@figaro.bbn.com>Path:
arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamageReferences:
<CBARBER.95Dec1093812@figaro.bbn.com> <49um6d$dcd@rzsun02.rrz.uni-hamburg.de>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage From: cbarber@bbn.com (Christopher Barber) Newsgroups: comp.std.c++ Subject: Re: streambuf derivation error or bug in istream::getline? Date: 6 Dec 1995 22:26:24 GMT Organization: BBN Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <CBARBER.95Dec6171211@figaro.bbn.com> References: <CBARBER.95Dec1093812@figaro.bbn.com> <49um6d$dcd@rzsun02.rrz.uni-hamburg.de> NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text X-Nntp-Posting-Host: figaro.bbn.com In-Reply-To: admin@rzaix13.uni-hamburg.de's message of 04 Dec 1995 22:37:11 GMT Content-Length: 1517 X-Lines: 30 Originator: clamage@taumet