DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
iostream examples

sync

The virtual function sync() is called to maintain synchronization between the various areas and the producer or consumer. It is also called by the streambuf() destructor.

   int fctbuf::sync()
   {
   	if ( gptr() && egptr() > gptr() ) {
   		// no way to return characters to producer
   		return EOF ;
   		}
   

if ( pptr() && pptr() > pbase() ) { // Flush waiting output return overflow(EOF) ; }

// nothing to do return 0 ; }

The virtual functions defined above implement a correct streambuf class. A possible refinement would be to provide implementations of the virtual xsputn() and xsgetn() functions. These functions are called when chunks of characters are being inserted and extracted respectively. Their default actions are to copy the data into the buffer. If they were defined in the fctbuf class they could call the functions directly and avoid the extra copy.


Next topic: Extending streams
Previous topic: underflow

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005