Topic: Why can't I ask an istream if it's buffer empty?


Author: boris@dontbother.com (Boris)
Date: Sat, 12 May 2001 20:16:32 GMT
Raw View
I'm interested in knowing why istream doesn't provide a means of determining
if it's buffer empty. It seems a simple enough request...is it just because
more data could be flowing in at any time? Or something else?

To me, taking user input in a console application seems very awkward! Does
everybody just  getline(char*,int) all the time? I would also appreciate any
references to show me the light! I can program OK but have never managed to
come up with a good stream input strategy.

Also, while I am here - why does putback(char) require the previously
extracted byte when it says it can only be that same byte anyway? It seems
very odd!

Thanks,
Boris.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: "R. Sinoradzki" <sinoradz@student.uni-kl.de>
Date: Sun, 13 May 2001 00:31:54 GMT
Raw View
Hi,
  doesn't peek() help?

bye, Ralf

Boris wrote:
>
> I'm interested in knowing why istream doesn't provide a means of determining
> if it's buffer empty. It seems a simple enough request...is it just because
> more data could be flowing in at any time? Or something else?

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: boris@dontbother.com (Boris)
Date: Sun, 13 May 2001 08:34:05 GMT
Raw View
"R. Sinoradzki" <sinoradz@student.uni-kl.de> wrote in
<3AFDA36B.988C93C6@student.uni-kl.de>:

>Hi,
>  doesn't peek() help?
>
>bye, Ralf
>
>Boris wrote:
>>
>> I'm interested in knowing why istream doesn't provide a means of
>> determining if it's buffer empty. It seems a simple enough
>> request...is it just because more data could be flowing in at any
>> time? Or something else?
>

Ralf,
Thanks...but no, it doesn't help me because it blocks. If it is empty it
will wait until it can extract more and then leave me asking again - is that
all there is? I suppose I am missing something!
Boris.

P.S. Hopefully this is not going OT...but I do still want to know WHY (not
just how to resolve)?


======================================= MODERATOR'S COMMENT:
 Maybe istream_instance.rdbuf()->showmanyc() would do?

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]