Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Custom output stream

Reply
Thread Tools

Custom output stream

 
 
Derek
Guest
Posts: n/a
 
      08-28-2006
>From reading countless posts here I seem to get the impression that to
roll your own output stream class, the minimum you would likely needed
to do would be to override the overflow() method, as it is apparently
the default action of sync() is to call overflow(EOF).

In my own testing under Linux with g++, it appears that it is the
sync() method that needs to be overridden, as it does not appear to
default to calling overflow(EOF)... but overflow() certainly appears to
default in calling sync() when it needs more room.

Is this a "bug" with g++, or have I been mistaken in my intepretation
of the general consensus here?

 
Reply With Quote
 
 
 
 
Bo Persson
Guest
Posts: n/a
 
      08-28-2006

"Derek" <(E-Mail Removed)> skrev i meddelandet
news:(E-Mail Removed) ps.com...
> >From reading countless posts here I seem to get the impression that
> >to

> roll your own output stream class, the minimum you would likely
> needed
> to do would be to override the overflow() method, as it is
> apparently
> the default action of sync() is to call overflow(EOF).


That is for basic_filebuf, but not for basic_streambuf. The filebuf is
possibly buffered, so it might need a sync() to force the buffer out
(to disk perhaps?).

Other streams might not be buffered.

>
> In my own testing under Linux with g++, it appears that it is the
> sync() method that needs to be overridden, as it does not appear to
> default to calling overflow(EOF)... but overflow() certainly appears
> to
> default in calling sync() when it needs more room.


At what level are you overriding?

In basic_streambuf, the default sync() does nothing, and overflow()
returns eof immediately. You must override whatever virtual functions
you need, to implement your special stream buffer. Exactly which ones
depends on what you are interfacing to.

>
> Is this a "bug" with g++, or have I been mistaken in my
> intepretation
> of the general consensus here?
>


Not really.


Bo Persson


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conversion from Input Stream to Output Stream Kashif Ur Rehman Java 2 05-17-2007 07:50 PM
what is the different between byte stream and character stream? dolphin Java 6 03-18-2007 01:58 PM
get stream mode flags from an opened stream Alexander Korsunsky C++ 1 02-17-2007 10:38 AM
How to GET multi-word input from a *file* stream as opposed to a *console* stream? sherifffruitfly@gmail.com C++ 9 04-27-2006 04:14 PM
Doing readline in a thread from a popen4('rsync ...') stream blocks when the stream ends. Rasmusson, Lars Python 1 04-30-2004 08:10 AM



Advertisments